mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-21 15:55:02 +00:00
Implemented method of setting the default system font face. See http://groups.google.com/group/objectivej/browse_thread/thread/64f6a42d74d68386
This commit is contained in:
1 parent
91f14e38ef
commit
94ee852cfe
4 files changed
+52
-9
No files matched your search
@@ -43,6 +43,14 @@ var _CPFonts = {},
|
||||
CPString _cssString;
|
||||
}
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
var systemFont = [[CPBundle mainBundle] objectForInfoDictionaryKey:"CPSystemFontFace"];
|
||||
|
||||
if (systemFont)
|
||||
_CPFontSystemFontFace = systemFont;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a font with the specified name and size.
|
||||
@param aName the name of the font
|
||||
@@ -65,6 +73,15 @@ var _CPFonts = {},
|
||||
return _CPCachedFont(aName, aSize, YES) || [[CPFont alloc] _initWithName:aName size:aSize bold:YES];
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the name of the system font
|
||||
@return the configured system font
|
||||
*/
|
||||
+ (CPString)systemFontFace
|
||||
{
|
||||
return _CPFontSystemFontFace;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the system font scaled to the specified size
|
||||
@param aSize the size of the font (in points)
|
||||
|
||||
@@ -33,12 +33,24 @@ NibFormatIPhone = 2;
|
||||
|
||||
ConverterConversionException = @"ConverterConversionException";
|
||||
|
||||
SharedConverterInstance = nil;
|
||||
|
||||
|
||||
@implementation Converter : CPObject
|
||||
{
|
||||
NibFormat format @accessors;
|
||||
CPString inputPath @accessors;
|
||||
CPString outputPath @accessors;
|
||||
CPString resourcesPath @accessors;
|
||||
CPString systemFontFace @accessors;
|
||||
}
|
||||
|
||||
+ (Converter)sharedConverterInstance
|
||||
{
|
||||
if (!SharedConverterInstance)
|
||||
SharedConverterInstance = [[Converter alloc] init];
|
||||
|
||||
return SharedConverterInstance;
|
||||
}
|
||||
|
||||
- (id)init
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
@import <AppKit/CPFont.j>
|
||||
|
||||
@import "Converter.j"
|
||||
|
||||
|
||||
@implementation CPFont (NSCoding)
|
||||
|
||||
@@ -37,12 +39,12 @@
|
||||
return nil;
|
||||
}
|
||||
|
||||
// FIXME: Is this alwasy true?
|
||||
// FIXME: Is this always true?
|
||||
if (fontName.indexOf("-Bold") === fontName.length - "-Bold".length)
|
||||
isBold = YES;
|
||||
|
||||
|
||||
if (fontName === "LucidaGrande" || fontName === "LucidaGrande-Bold")
|
||||
fontName = "Arial";
|
||||
fontName = [[Converter sharedConverterInstance] systemFontFace];
|
||||
|
||||
return [self _initWithName:fontName size:size bold:isBold];
|
||||
}
|
||||
|
||||
+18
-6
@@ -30,6 +30,8 @@
|
||||
@import "Nib2CibKeyedUnarchiver.j"
|
||||
@import "Converter.j"
|
||||
|
||||
var DefaultSystemFontFace = "Arial, sans-serif";
|
||||
|
||||
var FILE = require("file");
|
||||
var OS = require("os");
|
||||
|
||||
@@ -45,6 +47,10 @@ parser.option("-R", "resources")
|
||||
.set()
|
||||
.help("Set the Resources directory");
|
||||
|
||||
parser.option("--systemFontFace", "systemFontFace")
|
||||
.set()
|
||||
.help("Set the default system font");
|
||||
|
||||
parser.option("--mac", "format")
|
||||
.set(NibFormatMac)
|
||||
.def(NibFormatUndetermined)
|
||||
@@ -91,6 +97,9 @@ function main(args)
|
||||
parser.printUsage(options);
|
||||
OS.exit(1);
|
||||
}
|
||||
|
||||
if (!options.systemFontFace)
|
||||
options.systemFontFace = [CPFont systemFontFace];
|
||||
|
||||
if (options.quiet) {}
|
||||
else if (options.verbose === 0)
|
||||
@@ -100,18 +109,21 @@ function main(args)
|
||||
else
|
||||
CPLogRegister(CPLogPrint);
|
||||
|
||||
CPLog.debug("Input: " + options.args[0]);
|
||||
CPLog.debug("Output: " + (options.args[1]||""));
|
||||
CPLog.debug("Format: " + ["Auto","Mac","iPhone"][options.format]);
|
||||
CPLog.debug("Resources: " + (options.resources||""));
|
||||
CPLog.debug("Frameworks: " + options.frameworks);
|
||||
CPLog.debug("Input: " + options.args[0]);
|
||||
CPLog.debug("Output: " + (options.args[1]||""));
|
||||
CPLog.debug("Format: " + ["Auto","Mac","iPhone"][options.format]);
|
||||
CPLog.debug("Resources: " + (options.resources||""));
|
||||
CPLog.debug("Frameworks: " + options.frameworks);
|
||||
CPLog.debug("System font: " + options.systemFontFace);
|
||||
|
||||
var converter = [[Converter alloc] init];
|
||||
var converter = [Converter sharedConverterInstance];
|
||||
|
||||
if (options.resources)
|
||||
[converter setResourcesPath:options.resources];
|
||||
|
||||
[converter setFormat:options.format];
|
||||
|
||||
[converter setSystemFontFace:options.systemFontFace];
|
||||
|
||||
[converter setInputPath:options.args[0]];
|
||||
|
||||
|
||||
Reference in new issue
Block a user