Further CPFont work, don't print nib2cib version all the time.

This commit is contained in:
Aparajita Fishman committed 2011-03-09 14:33:11 -05:00
1 parent d303e6e96c
commit 120c06fcb2
2 files changed
+22 -7

No files matched your search

+16 -2
View File
@@ -29,6 +29,8 @@
var _CPFonts = {},
_CPFontSystemFontFace = @"Arial",
_CPFontSystemFontSize = 12,
_CPFontDefaultSystemFontFace = @"Arial, sans-serif",
_CPFontDefaultSystemFontSize = 12,
_CPFontFallbackFaces = [@"Arial", @"sans-serif"],
_CPFontStripRegExp = new RegExp("(^\\s*[\"']?|[\"']?\\s*$)", "g"),
_CPFontStripPropertiesRegExp = new RegExp("^(italic |bold )*\\d+px ");
@@ -63,7 +65,7 @@ var _CPFonts = {},
systemFontFace = [[CPBundle bundleForClass:[CPView class]] objectForInfoDictionaryKey:@"CPSystemFontFace"];
if (systemFontFace)
_CPFontSystemFontFace = systemFontFace;
[self setSystemFontFace:systemFontFace];
var systemFontSize = [[CPBundle mainBundle] objectForInfoDictionaryKey:@"CPSystemFontSize"];
@@ -87,8 +89,12 @@ var _CPFonts = {},
*/
+ (CPString)setSystemFontFace:(CPString)aFace
{
var names = _CPFontNormalizedNames(aFace);
_CPFontSystemFontFace = aFace;
_CPFontSystemFontFace = names.shift();
if (names.length)
_CPFontFallbackFaces = names;
}
/*!
@@ -312,6 +318,14 @@ var CPFontNameKey = @"CPFontNameKey",
isBold = [aCoder decodeBoolForKey:CPFontIsBoldKey],
isItalic = [aCoder decodeBoolForKey:CPFontIsItalicKey];
if (fontName === _CPFontDefaultSystemFontFace)
{
fontName = [_CPFontSystemFontFace].concat(_CPFontFallbackFaces).join(",");
if (size === _CPFontDefaultSystemFontSize)
size = _CPFontSystemFontSize;
}
return [self _initWithName:fontName size:size bold:isBold italic:isItalic];
}
+6 -5
View File
@@ -127,10 +127,8 @@ function main(args)
else
CPLogRegister(CPLogPrint, null, logFormatter);
printVersion();
if (options.showVersion)
OS.exit(0);
if (!options.quiet && options.verbose > 0)
printVersion(options.showVersion);
var inputFile = options.args[0];
@@ -348,7 +346,7 @@ function setSystemFontAndSize(configFile, inputFile)
return configPath;
}
function printVersion()
function printVersion(exitAfter)
{
// SYS.args[0] has the path to the nib2cib binary, from that we can get
// to the lib/nib2cib directory which the Info.plist for nib2cib.
@@ -376,6 +374,9 @@ function printVersion()
if (version)
print("nib2cib v" + version);
}
if (exitAfter)
OS.exit(0);
}
function fail(message)