Overhaul of system font handling

- System fonts now track the currently configured system font at runtime.
- You can specify CPFontCurrentSystemSize as a system font size to track the currently configured system font size at runtime.
- Theme fonts and nib2cib now determine face and size at runtime, there is no need to recompile if the system font is changed in Info.plist.
- All hard-coded references to 12.0 as a system font size have been replaced by the current system font size.
This commit is contained in:
Aparajita Fishman
2012-07-09 15:29:56 -07:00
parent 98fbf3abc1
commit 6b6f5d98e4
28 changed files with 2572 additions and 2307 deletions
+1 -1
View File
@@ -373,7 +373,7 @@ CPRunContinuesResponse = -1002;
standardPath = [[CPBundle bundleForClass:[self class]] pathForResource:@"standardApplicationIcon.png"];
// FIXME move this into the CIB eventually
[applicationLabel setFont:[CPFont boldSystemFontOfSize:14.0]];
[applicationLabel setFont:[CPFont boldSystemFontOfSize:[CPFont systemFontSize] + 2]];
[applicationLabel setAlignment:CPCenterTextAlignment];
[versionLabel setAlignment:CPCenterTextAlignment];
[copyrightLabel setAlignment:CPCenterTextAlignment];
+148 -66
View File
@@ -28,46 +28,83 @@
CPFontDefaultSystemFontFace = @"Arial, sans-serif";
CPFontDefaultSystemFontSize = 12;
var _CPFonts = {},
_CPFontSystemFontFace = CPFontDefaultSystemFontFace,
_CPFontSystemFontSize = 12,
_CPFontFallbackFaces = CPFontDefaultSystemFontFace.split(", "),
_CPFontStripRegExp = new RegExp("(^\\s*[\"']?|[\"']?\\s*$)", "g");
// To create a font of a size that will always reflect the current
// system font size, use this for the size argument.
CPFontCurrentSystemSize = -1;
// For internal use only by this class and subclasses
_CPFontSystemFacePlaceholder = "_CPFontSystemFacePlaceholder";
var _CPFontCache = {},
_CPSystemFontCache = {},
_CPFontSystemFontFace = CPFontDefaultSystemFontFace,
_CPFontSystemFontSize = 12,
_CPFontFallbackFaces = CPFontDefaultSystemFontFace.split(", "),
_CPFontStripRegExp = new RegExp("(^\\s*[\"']?|[\"']?\\s*$)", "g");
#define _CPRealFontSize(aSize) (aSize === CPFontCurrentSystemSize ? _CPFontSystemFontSize : aSize)
#define _CPFontNormalizedNames(aName) _CPFontNormalizedNameArray(aName).join(", ")
#define _CPCachedFont(aName, aSize, isBold, isItalic) _CPFonts[_CPFontCreateCSSString(_CPFontNormalizedNames(aName), aSize, isBold, isItalic)]
#define _CPCachedFont(aName, aSize, isBold, isItalic) _CPFontCache[_CPFontCreateCSSString(_CPFontNormalizedNames(aName), aSize, isBold, isItalic)]
#define _CPUserFont(aName, aSize, isBold, isItalic) _CPCachedFont(aName, aSize, isBold, isItalic) || [[CPFont alloc] _initWithName:aName size:aSize bold:isBold italic:isItalic system:NO]
#define _CPSystemFontCacheKey(aSize, isBold) (String(aSize) + (isBold ? "b" : ""))
#define _CPCachedSystemFont(aSize, isBold) _CPSystemFontCache[_CPSystemFontCacheKey(aSize, isBold)]
#define _CPSystemFont(aSize, isBold) (_CPCachedSystemFont(aSize, isBold) || [[CPFont alloc] _initWithName:_CPFontSystemFacePlaceholder size:aSize bold:isBold italic:NO system:YES])
/*!
@ingroup appkit
@class CPFont
@ingroup appkit
@class CPFont
The CPFont class allows control of the fonts used for displaying text anywhere on the screen.
The primary method for getting a particular font is through one of the class methods that take
a name and/or size as arguments, and return the appropriate CPFont.
The CPFont class allows control of the fonts used for displaying text anywhere on the screen.
The primary method for getting a particular font is through one of the class methods that take
a name and/or size as arguments, and return the appropriate CPFont.
By default the system font face/size is Arial 12px, with a fallback to sans-serif. You may
configure this at runtime in two ways:
### System fonts
When you create a font using \c -systemFontOfSize: or \c -boldSystemFontOfSize:, a proxy font is
created that always refers to the current system font face and size. By default the system
font face/size is Arial 12px, with a fallback to sans-serif 12px. You may configure this at
runtime in two ways:
- By sending [CPFont @link CPFont::setSystemFontFace: setSystemFontFace:@endlink] and/or [CPFont @link CPFont::setSystemFontSize: setSystemFontSize:@endlink].
- By configuring Info.plist for your application or for AppKit. You can set the font face
by adding a CPSystemFontFace string item to the Info.plist, and you can set the font size
by adding a CPSystemFontSize integer item to the Info.plist.
- By sending [CPFont setSystemFontFace:<face>] and/or [CPFont setSystemFontSize:<size>].
Note that if you change the system font face or size during runtime, the next time
any view using a system font is redrawn, it will show the new font.
- By configuring Info.plist for your application or for AppKit. You can set the font face
by adding a CPSystemFontFace string item to the Info.plist, and you can set the font size
by adding a CPSystemFontSize integer item to the Info.plist.
Note that in either case, you can specify a comma-delimited list of fonts as the font face.
The browser will use the first available font in the list. CPFont always ensures that Arial
and sans-serif are in the generated CSS string, so there is no need to add them to the end
of your font list.
Note that in either case, you can specify a comma-delimited list of fonts as the font face.
Do not quote enclose font faces that contain spaces, that is done automatically when a CSS
representation of a font is requested.
If you are using nib2cib, you should use the second method (using Info.plist),
and be sure to run nib2cib again any time you modify the CPSystemFontFace or CPSystemFontSize items.
For example, you might add this to your application's Info.plist to set the system font to Lucida Grande,
with an automatic fallback to Arial or sans-serif:
The browser will use the first available font in the list you supply. CPFont always ensures
that Arial and sans-serif are in the CSS representation of a font as a fallback, so there is
no need to add them to the end of your font list.
@code
### nib2cib conversion
Fonts are converted by nib2cib according to the following algorithm:
- If the font family is Lucida Grande, then a system font will be created.
- If the font is Lucida Grande 13 (plain), the "default" font will be used at runtime.
The default font is taken from the "font" theme attribute if one exists,
otherwise from the current system font face and size.
- Lucida Grande of any size other than 13 will retain its size.
- Fonts using any family other than Lucida Grande will be used as is, including the size.
### Using custom web fonts
The configurability of CPFont makes it easy to use a custom web font as the system font.
For example, if you want to use the google font Asap as the system font, you would do the
following:
- Add a <link> to the <head> of index-debug.html and index.html:
@code
<link href='http://fonts.googleapis.com/css?family=Asap:400,700' rel='stylesheet' type='text/css'>
@endcode
- Specify Asap as the system font in Info.plist by adding the following item:
@code
<key>CPSystemFontFace</key>
<string>Lucida Grande</string>
@endcode
<string>Asap</string>
@endcode
*/
@implementation CPFont : CPObject
{
@@ -78,6 +115,7 @@ var _CPFonts = {},
float _lineHeight;
BOOL _isBold @accessors(readonly, getter=isBold);
BOOL _isItalic @accessors(readonly, getter=isItalic);
BOOL _isSystem @accessors(readonly, getter=isSystem);
CPString _cssString;
}
@@ -93,7 +131,7 @@ var _CPFonts = {},
systemFontFace = [[CPBundle bundleForClass:[CPView class]] objectForInfoDictionaryKey:@"CPSystemFontFace"];
if (systemFontFace)
[self setSystemFontFace:systemFontFace];
_CPFontSystemFontFace = _CPFontNormalizedNames(systemFontFace);
var systemFontSize = [[CPBundle mainBundle] objectForInfoDictionaryKey:@"CPSystemFontSize"];
@@ -117,7 +155,13 @@ var _CPFonts = {},
*/
+ (CPString)setSystemFontFace:(CPString)aFace
{
_CPFontSystemFontFace = _CPFontNormalizedNames(aFace);
var normalizedFaces = _CPFontNormalizedNames(aFace);
if (normalizedFaces === _CPFontSystemFontFace)
return;
[self _invalidateSystemFontCache]
_CPFontSystemFontFace = aFace;
}
/*!
@@ -133,8 +177,26 @@ var _CPFonts = {},
*/
+ (float)setSystemFontSize:(float)size
{
if (size > 0)
if (size > 0 && size !== _CPFontSystemFontSize)
{
[self _invalidateSystemFontCache];
_CPFontSystemFontSize = size;
}
}
+ (void)_invalidateSystemFontCache
{
var systemSize = String(_CPFontSystemFontSize),
currentSize = String(CPFontCurrentSystemSize);
for (key in _CPSystemFontCache)
{
if (_CPSystemFontCache.hasOwnProperty(key) &&
(key.indexOf(systemSize) === 0 || key.indexOf(currentSize) === 0))
{
delete _CPSystemFontCache[key];
}
}
}
/*!
@@ -145,7 +207,7 @@ var _CPFonts = {},
*/
+ (CPFont)fontWithName:(CPString)aName size:(float)aSize
{
return [CPFont fontWithName:aName size:aSize bold:NO italic:NO];
return _CPUserFont(aName, aSize, NO, NO);
}
/*!
@@ -157,7 +219,7 @@ var _CPFonts = {},
*/
+ (CPFont)fontWithName:(CPString)aName size:(float)aSize italic:(BOOL)italic
{
return [CPFont fontWithName:aName size:aSize bold:NO italic:italic];
return _CPUserFont(aName, aSize, NO, italic);
}
/*!
@@ -168,7 +230,7 @@ var _CPFonts = {},
*/
+ (CPFont)boldFontWithName:(CPString)aName size:(float)aSize
{
return [CPFont fontWithName:aName size:aSize bold:YES italic:NO];
return _CPUserFont(aName, aSize, YES, NO);
}
/*!
@@ -180,7 +242,7 @@ var _CPFonts = {},
*/
+ (CPFont)boldFontWithName:(CPString)aName size:(float)aSize italic:(BOOL)italic
{
return [CPFont fontWithName:aName size:aSize bold:YES italic:italic];
return _CPUserFont(aName, aSize, YES, italic);
}
/*!
@@ -190,7 +252,7 @@ var _CPFonts = {},
*/
+ (CPFont)systemFontOfSize:(CPSize)aSize
{
return [CPFont fontWithName:_CPFontSystemFontFace size:aSize bold:NO italic:NO];
return _CPSystemFont(aSize, NO);
}
/*!
@@ -200,34 +262,35 @@ var _CPFonts = {},
*/
+ (CPFont)boldSystemFontOfSize:(CPSize)aSize
{
return [CPFont fontWithName:_CPFontSystemFontFace size:aSize bold:YES italic:NO];
return _CPSystemFont(aSize, YES);
}
/* FIXME Font Descriptor
@ignore
*/
+ (CPFont)fontWithName:(CPString)aName size:(float)aSize bold:(BOOL)bold italic:(BOOL)italic
{
return _CPCachedFont(aName, aSize, bold, italic) || [[CPFont alloc] _initWithName:aName size:aSize bold:bold italic:italic];
}
- (id)_initWithName:(CPString)aName size:(float)aSize bold:(BOOL)isBold italic:(BOOL)isItalic
- (id)_initWithName:(CPString)aName size:(float)aSize bold:(BOOL)isBold italic:(BOOL)isItalic system:(BOOL)isSystem
{
self = [super init];
if (self)
{
_name = _CPFontNormalizedNames(aName);
_size = aSize;
_ascender = 0;
_descender = 0;
_lineHeight = 0;
_isBold = isBold;
_isItalic = isItalic;
_isSystem = isSystem;
_cssString = _CPFontCreateCSSString(_name, _size, _isBold, _isItalic);
_CPFonts[_cssString] = self;
if (isSystem)
{
_name = aName;
_cssString = _CPFontCreateCSSString(_CPFontSystemFontFace, _size, _isBold, _isItalic);
_CPSystemFontCache[_CPSystemFontCacheKey(_size, _isBold)] = self;
}
else
{
_name = _CPFontNormalizedNames(aName);
_cssString = _CPFontCreateCSSString(_name, _size, _isBold, _isItalic);
_CPFontCache[_cssString] = self;
}
}
return self;
@@ -238,10 +301,12 @@ var _CPFonts = {},
*/
- (float)ascender
{
if (!_ascender)
[self _getMetrics];
var font = _isSystem ? _CPSystemFont(_size, _isBold) : self;
return _ascender;
if (!font._ascender)
[font _getMetrics];
return font._ascender;
}
/*!
@@ -250,10 +315,12 @@ var _CPFonts = {},
*/
- (float)descender
{
if (!_descender)
[self _getMetrics];
var font = _isSystem ? _CPSystemFont(_size, _isBold) : self;
return _descender;
if (!font._descender)
[font _getMetrics];
return font._descender;
}
/*!
@@ -263,10 +330,12 @@ var _CPFonts = {},
*/
- (float)defaultLineHeightForFont
{
if (!_lineHeight)
[self _getMetrics];
var font = _isSystem ? _CPSystemFont(_size, _isBold) : self;
return _lineHeight;
if (!font._lineHeight)
[font _getMetrics];
return font._lineHeight;
}
/*!
@@ -274,7 +343,7 @@ var _CPFonts = {},
*/
- (float)size
{
return _size;
return _CPRealFontSize(_size);
}
/*!
@@ -282,7 +351,9 @@ var _CPFonts = {},
*/
- (CPString)cssString
{
return _cssString;
var font = _isSystem ? _CPSystemFont(_size, _isBold) : self;
return font._cssString;
}
/*!
@@ -290,9 +361,17 @@ var _CPFonts = {},
*/
- (CPString)familyName
{
if (_isSystem)
return _CPFontSystemFontFace;
return _name;
}
- (BOOL)isSystemSize
{
return _size === CPFontCurrentSystemSize;
}
- (BOOL)isEqual:(id)anObject
{
return [anObject isKindOfClass:[CPFont class]] && [anObject cssString] === _cssString;
@@ -305,7 +384,7 @@ var _CPFonts = {},
- (id)copy
{
return [[CPFont alloc] _initWithName:_name size:_size bold:_isBold italic:_isItalic];
return [[CPFont alloc] _initWithName:_name size:_size bold:_isBold italic:_isItalic isSystem:_isSystem];
}
- (void)_getMetrics
@@ -322,7 +401,8 @@ var _CPFonts = {},
var CPFontNameKey = @"CPFontNameKey",
CPFontSizeKey = @"CPFontSizeKey",
CPFontIsBoldKey = @"CPFontIsBoldKey",
CPFontIsItalicKey = @"CPFontIsItalicKey";
CPFontIsItalicKey = @"CPFontIsItalicKey",
CPFontIsSystemKey = @"CPFontIsSystemKey";
@implementation CPFont (CPCoding)
@@ -336,9 +416,10 @@ var CPFontNameKey = @"CPFontNameKey",
var fontName = [aCoder decodeObjectForKey:CPFontNameKey],
size = [aCoder decodeFloatForKey:CPFontSizeKey],
isBold = [aCoder decodeBoolForKey:CPFontIsBoldKey],
isItalic = [aCoder decodeBoolForKey:CPFontIsItalicKey];
isItalic = [aCoder decodeBoolForKey:CPFontIsItalicKey],
isSystem = [aCoder decodeBoolForKey:CPFontIsSystemKey];
return [self _initWithName:fontName size:size bold:isBold italic:isItalic];
return [self _initWithName:fontName size:size bold:isBold italic:isItalic system:isSystem];
}
/*!
@@ -351,6 +432,7 @@ var CPFontNameKey = @"CPFontNameKey",
[aCoder encodeFloat:_size forKey:CPFontSizeKey];
[aCoder encodeBool:_isBold forKey:CPFontIsBoldKey];
[aCoder encodeBool:_isItalic forKey:CPFontIsItalicKey];
[aCoder encodeBool:_isSystem forKey:CPFontIsSystemKey];
}
@end
@@ -359,7 +441,7 @@ var CPFontNameKey = @"CPFontNameKey",
// aName must be normalized
var _CPFontCreateCSSString = function(aName, aSize, isBold, isItalic)
{
var properties = (isItalic ? "italic " : "") + (isBold ? "bold " : "") + aSize + "px ";
var properties = (isItalic ? "italic " : "") + (isBold ? "bold " : "") + _CPRealFontSize(aSize) + "px ";
return properties + _CPFontConcatNameWithFallback(aName);
};
+1 -1
View File
@@ -806,7 +806,7 @@ var _CPMenuBarVisible = NO,
[aMenu _menuWillOpen];
if (!aFont)
aFont = [CPFont systemFontOfSize:12.0];
aFont = [CPFont systemFontOfSize:[CPFont systemFontSize]];
var theWindow = [aView window],
menuWindow = [_CPMenuWindow menuWindowWithMenu:aMenu font:aFont];
+3 -3
View File
@@ -39,7 +39,7 @@ var _CPMenuBarWindowBackgroundColor = nil,
var bundle = [CPBundle bundleForClass:self];
_CPMenuBarWindowFont = [CPFont boldSystemFontOfSize:12.0];
_CPMenuBarWindowFont = [CPFont boldSystemFontOfSize:[CPFont systemFontSize]];
}
+ (CPFont)font
@@ -74,7 +74,7 @@ var _CPMenuBarWindowBackgroundColor = nil,
_titleField = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
[_titleField setFont:[CPFont boldSystemFontOfSize:13.0]];
[_titleField setFont:[CPFont boldSystemFontOfSize:[CPFont systemFontSize] + 1]];
[_titleField setAlignment:CPCenterTextAlignment];
[_titleField setTextShadowOffset:CGSizeMake(0, 1)];
@@ -335,7 +335,7 @@ var _CPMenuBarWindowBackgroundColor = nil,
- (CPFont)font
{
[CPFont systemFontOfSize:12.0];
[CPFont systemFontOfSize:[CPFont systemFontSize]];
}
- (void)tile
+1 -1
View File
@@ -281,7 +281,7 @@ var CPMenuItemStringRepresentationDictionary = [CPDictionary dictionary];
*/
- (void)setFont:(CPFont)aFont
{
if (_font == aFont)
if ([_font isEqual:aFont])
return;
_font = aFont;
+1 -1
View File
@@ -176,7 +176,7 @@ var _CPMenuItemSelectionColor = nil,
- (void)setFont:(CPFont)aFont
{
if (_font === aFont)
if ([_font isEqual:aFont])
return;
_font = aFont;
+3 -3
View File
@@ -40,7 +40,7 @@
+ (id)themeAttributes
{
return [CPDictionary dictionaryWithObjects:[[CPNull null], [CPNull null], CGInsetMakeZero(), [CPNull null], [CPNull null], [CPNull null], CGSizeMakeZero()]
forKeys:[@"background-color", @"text-alignment", @"text-inset", @"text-color", @"text-font", @"text-shadow-color", @"text-shadow-offset"]];
forKeys:[@"background-color", @"text-alignment", @"text-inset", @"text-color", @"font", @"text-shadow-color", @"text-shadow-offset"]];
}
- (void)initWithFrame:(CGRect)frame
@@ -74,7 +74,7 @@
[_textField setFrame:_CGRectMake(inset.right, inset.top, bounds.size.width - inset.right - inset.left, bounds.size.height - inset.top - inset.bottom)];
[_textField setTextColor:[self currentValueForThemeAttribute:@"text-color"]];
[_textField setFont:[self currentValueForThemeAttribute:@"text-font"]];
[_textField setFont:[self currentValueForThemeAttribute:@"font"]];
[_textField setTextShadowColor:[self currentValueForThemeAttribute:@"text-shadow-color"]];
[_textField setTextShadowOffset:[self currentValueForThemeAttribute:@"text-shadow-offset"]];
[_textField setAlignment:[self currentValueForThemeAttribute:@"text-alignment"]];
@@ -102,7 +102,7 @@
- (void)setFont:(CPFont)aFont
{
[self setValue:aFont forThemeAttribute:"text-font"];
[self setValue:aFont forThemeAttribute:"font"];
}
- (void)_setIndicatorImage:(CPImage)anImage
+1 -1
View File
@@ -487,7 +487,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
var element = [self _inputElement],
font = [self currentValueForThemeAttribute:@"font"],
lineHeight = ROUND([font defaultLineHeightForFont]);
lineHeight = [font defaultLineHeightForFont];
element.value = _stringValue;
element.style.color = [[self currentValueForThemeAttribute:@"text-color"] cssString];
+2 -2
View File
@@ -341,7 +341,7 @@ var CPScrollDestinationNone = 0,
element.style.top = CGRectGetMinY(contentRect) + "px";
element.style.left = (CGRectGetMinX(contentRect) - 1) + "px"; // <input> element effectively imposes a 1px left margin
element.style.width = CGRectGetWidth(contentRect) + "px";
element.style.height = ROUND([font defaultLineHeightForFont]) + "px";
element.style.height = [font defaultLineHeightForFont] + "px";
[_tokenScrollView documentView]._DOMElement.appendChild(element);
@@ -986,7 +986,7 @@ var CPScrollDestinationNone = 0,
isEditing = [[self window] firstResponder] == self,
tokenToken = [_CPTokenFieldToken new],
font = [self currentValueForThemeAttribute:@"font"],
lineHeight = ROUND([font defaultLineHeightForFont]),
lineHeight = [font defaultLineHeightForFont],
editorInset = [self currentValueForThemeAttribute:@"editor-inset"];
// Get the height of a typical token, or a token token if you will.
+1 -1
View File
@@ -127,7 +127,7 @@ var HUD_TITLEBAR_HEIGHT = 26.0;
_titleField = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
[_titleField setHitTests:NO];
[_titleField setFont:[CPFont systemFontOfSize:11.0]];
[_titleField setFont:[CPFont systemFontOfSize:[CPFont systemFontSize] - 1]];
[_titleField setTextColor:[CPColor whiteColor]];
[_titleField setTextShadowColor:[CPColor blackColor]];
[_titleField setTextShadowOffset:CGSizeMake(0.0, 1.0)];
+1 -1
View File
@@ -244,7 +244,7 @@ var STANDARD_GRADIENT_HEIGHT = 41.0,
_titleField = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
[_titleField setFont:[CPFont boldSystemFontOfSize:12.0]];
[_titleField setFont:[CPFont boldSystemFontOfSize:CPFontCurrentSystemSize]];
[_titleField setAutoresizingMask:CPViewWidthSizable];
// FIXME: Make this to CPLineBreakByTruncatingMiddle once it's implemented.
+10 -18
View File
@@ -33,6 +33,14 @@ var DOMFixedWidthSpanElement = nil,
{
}
+ (void)initialize
{
if (self !== [CPPlatformString class])
return;
DefaultFont = [CPFont systemFontOfSize:CPFontCurrentSystemSize];
}
+ (void)bootstrap
{
[self createDOMElements];
@@ -151,14 +159,6 @@ var DOMFixedWidthSpanElement = nil,
+ (CGSize)sizeOfString:(CPString)aString withFont:(CPFont)aFont forWidth:(float)aWidth
{
if (!aFont)
{
if (!DefaultFont)
DefaultFont = [CPFont systemFontOfSize:12.0];
aFont = DefaultFont;
}
if (!DOMIFrameElement)
[self createDOMElements];
@@ -172,7 +172,7 @@ var DOMFixedWidthSpanElement = nil,
span.style.width = ROUND(aWidth) + "px";
}
span.style.font = [aFont cssString];
span.style.font = [(aFont || DefaultFont) cssString];
if (CPFeatureIsCompatible(CPJavaScriptInnerTextFeature))
span.innerText = aString;
@@ -184,18 +184,10 @@ var DOMFixedWidthSpanElement = nil,
+ (CPDictionary)metricsOfFont:(CPFont)aFont
{
if (!aFont)
{
if (!DefaultFont)
DefaultFont = [CPFont systemFontOfSize:12.0];
aFont = DefaultFont;
}
if (!DOMMetricsDivElement)
[self createDOMMetricsElements];
DOMMetricsDivElement.style.font = [aFont cssString];
DOMMetricsDivElement.style.font = [(aFont || DefaultFont) cssString];
var baseline = DOMMetricsImgElement.offsetTop - DOMMetricsTextSpanElement.offsetTop + DOMMetricsImgElement.offsetHeight,
descender = baseline - DOMMetricsTextSpanElement.offsetHeight,
+17 -17
View File
@@ -443,7 +443,7 @@ var themedButtonValues = nil,
themedButtonValues =
[
[@"font", [CPFont boldSystemFontOfSize:12.0], CPThemeStateBordered],
[@"font", [CPFont boldSystemFontOfSize:CPFontCurrentSystemSize], CPThemeStateBordered],
[@"text-color", [CPColor colorWithCalibratedWhite:79.0 / 255.0 alpha:1.0]],
[@"text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0], CPThemeStateBordered],
[@"text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0], CPThemeStateBordered | CPThemeStateDisabled],
@@ -536,7 +536,7 @@ var themedButtonValues = nil,
[@"bezel-color", disabledColor, CPThemeStateBordered | CPThemeStateDisabled],
[@"content-inset", CGInsetMake(0, 21.0 + 5.0, 0, 5.0), CPThemeStateBordered],
[@"font", [CPFont boldSystemFontOfSize:12.0]],
[@"font", [CPFont boldSystemFontOfSize:CPFontCurrentSystemSize]],
[@"text-color", [CPColor colorWithCalibratedWhite:79.0 / 255.0 alpha:1.0]],
[@"text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0]],
@@ -580,7 +580,7 @@ var themedButtonValues = nil,
[@"bezel-color", disabledColor, CPPopUpButtonStatePullsDown | CPThemeStateBordered | CPThemeStateDisabled],
[@"content-inset", CGInsetMake(0, 27.0 + 5.0, 0, 5.0), CPThemeStateBordered],
[@"font", [CPFont boldSystemFontOfSize:12.0]],
[@"font", [CPFont boldSystemFontOfSize:CPFontCurrentSystemSize]],
[@"text-color", [CPColor colorWithCalibratedWhite:79.0 / 255.0 alpha:1.0]],
[@"text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0]],
@@ -909,11 +909,11 @@ var themedButtonValues = nil,
[@"bezel-color", bezelColor, CPThemeStateBezeled],
[@"bezel-color", bezelFocusedColor, CPThemeStateBezeled | CPThemeStateEditing],
[@"bezel-color", bezelDisabledColor, CPThemeStateBezeled | CPThemeStateDisabled],
[@"font", [CPFont systemFontOfSize:12.0], CPThemeStateBezeled],
[@"font", [CPFont systemFontOfSize:CPFontCurrentSystemSize], CPThemeStateBezeled],
// no border
[@"bezel-inset", CGInsetMakeZero()],
[@"content-inset", CGInsetMake(2.0, 2.0, 2.0, 2.0)], // as defined in [CPTextField +themeAttributes]
[@"content-inset", CGInsetMakeZero()],
// with border
[@"bezel-inset", CGInsetMakeZero(), CPThemeStateBezeled],
@@ -929,10 +929,10 @@ var themedButtonValues = nil,
[@"text-color", [CPColor colorWithCalibratedWhite:51.0 / 255.0 alpha:1.0], CPThemeStateTableDataView],
[@"text-color", [CPColor whiteColor], CPThemeStateTableDataView | CPThemeStateSelectedTableDataView],
[@"font", [CPFont boldSystemFontOfSize:12.0], CPThemeStateTableDataView | CPThemeStateSelectedTableDataView],
[@"font", [CPFont boldSystemFontOfSize:CPFontCurrentSystemSize], CPThemeStateTableDataView | CPThemeStateSelectedTableDataView],
[@"text-color", [CPColor blackColor], CPThemeStateTableDataView | CPThemeStateEditing],
[@"content-inset", CGInsetMake(8.0, 8.0, 7.0, 5.0), CPThemeStateTableDataView | CPThemeStateEditing],
[@"font", [CPFont systemFontOfSize:12.0], CPThemeStateTableDataView | CPThemeStateEditing],
[@"font", [CPFont systemFontOfSize:CPFontCurrentSystemSize], CPThemeStateTableDataView | CPThemeStateEditing],
[@"bezel-inset", CGInsetMake(-1.0, -1.0, -1.0, -1.0), CPThemeStateTableDataView | CPThemeStateEditing],
[@"text-color", [CPColor colorWithCalibratedWhite:125.0 / 255.0 alpha:1.0], CPThemeStateTableDataView | CPThemeStateGroupRow],
@@ -940,7 +940,7 @@ var themedButtonValues = nil,
[@"text-shadow-color", [CPColor whiteColor], CPThemeStateTableDataView | CPThemeStateGroupRow],
[@"text-shadow-offset", CGSizeMake(0,1), CPThemeStateTableDataView | CPThemeStateGroupRow],
[@"text-shadow-color", [CPColor colorWithCalibratedWhite:0.0 alpha:0.6], CPThemeStateTableDataView | CPThemeStateGroupRow | CPThemeStateSelectedTableDataView],
[@"font", [CPFont boldSystemFontOfSize:12.0], CPThemeStateTableDataView | CPThemeStateGroupRow]
[@"font", [CPFont boldSystemFontOfSize:CPFontCurrentSystemSize], CPThemeStateTableDataView | CPThemeStateGroupRow]
];
[self registerThemeValues:themedTextFieldValues forView:textfield];
@@ -987,7 +987,7 @@ var themedButtonValues = nil,
[@"bezel-color", bezelColor, CPTextFieldStateRounded | CPThemeStateBezeled],
[@"bezel-color", bezelFocusedColor, CPTextFieldStateRounded | CPThemeStateBezeled | CPThemeStateEditing],
[@"bezel-color", bezelDisabledColor, CPTextFieldStateRounded | CPThemeStateBezeled | CPThemeStateDisabled],
[@"font", [CPFont systemFontOfSize:12.0]],
[@"font", [CPFont systemFontOfSize:CPFontCurrentSystemSize]],
// The new bezel is one pixel shorter, so we add one extra empty pixel at the bottom
// for size compatibility with an earlier version.
@@ -1225,7 +1225,7 @@ var themedButtonValues = nil,
themeValues =
[
[@"alignment", CPLeftTextAlignment, CPThemeStateNormal],
[@"font", [CPFont systemFontOfSize:12.0], CPThemeStateNormal],
[@"font", [CPFont systemFontOfSize:CPFontCurrentSystemSize], CPThemeStateNormal],
[@"content-inset", CGInsetMake(0.0, 0.0, 0.0, 0.0), CPThemeStateNormal],
[@"image", imageNormal, CPThemeStateNormal],
@@ -1261,8 +1261,8 @@ var themedButtonValues = nil,
themeValues =
[
[@"alignment", CPLeftTextAlignment, CPThemeStateNormal],
[@"font", [CPFont systemFontOfSize:12.0], CPThemeStateNormal],
[@"content-inset", CGInsetMake(0.0, 0.0, 0.0, 0.0), CPThemeStateNormal],
[@"font", [CPFont systemFontOfSize:CPFontCurrentSystemSize], CPThemeStateNormal],
[@"content-inset", CGInsetMakeZero(), CPThemeStateNormal],
[@"image", imageNormal, CPThemeStateNormal],
[@"image", imageSelected, CPThemeStateSelected],
@@ -1388,7 +1388,7 @@ var themedButtonValues = nil,
[@"content-inset", CGInsetMake(0.0, 4.0, 0.0, 4.0), CPThemeStateNormal],
[@"bezel-inset", CGInsetMake(0.0, 0.0, 0.0, 0.0), CPThemeStateNormal],
[@"font", [CPFont boldSystemFontOfSize:12.0]],
[@"font", [CPFont boldSystemFontOfSize:CPFontCurrentSystemSize]],
[@"text-color", [CPColor colorWithCalibratedWhite:79.0 / 255.0 alpha:1.0]],
[@"text-color", [CPColor colorWithCalibratedWhite:0.6 alpha:1.0], CPThemeStateDisabled],
[@"text-shadow-color", [CPColor colorWithCalibratedWhite:240.0 / 255.0 alpha:1.0]],
@@ -1619,7 +1619,7 @@ var themedButtonValues = nil,
[@"text-inset", CGInsetMake(0, 5, 0, 5)],
[@"text-color", [CPColor colorWithCalibratedWhite:51.0 / 255.0 alpha:1.0]],
[@"text-font", [CPFont boldSystemFontOfSize:12.0]],
[@"font", [CPFont boldSystemFontOfSize:CPFontCurrentSystemSize]],
[@"text-shadow-color", [CPColor whiteColor]],
[@"text-shadow-offset", CGSizeMake(0.0, 1.0)],
[@"text-alignment", CPLeftTextAlignment],
@@ -1739,13 +1739,13 @@ var themedButtonValues = nil,
helpLeftOffset = 15,
imageOffset = CGPointMake(15, 18),
informationIcon = PatternImage("alert-info.png", 53.0, 46.0),
informativeFont = [CPFont systemFontOfSize:12.0],
informativeFont = [CPFont systemFontOfSize:CPFontCurrentSystemSize],
inset = CGInsetMake(15, 15, 15, 80),
messageFont = [CPFont boldSystemFontOfSize:13.0],
messageFont = [CPFont boldSystemFontOfSize:CPFontDefaultSystemFontSize + 1],
size = CGSizeMake(400.0, 110.0),
suppressionButtonXOffset = 2.0,
suppressionButtonYOffset = 10.0,
suppressionButtonFont = [CPFont systemFontOfSize:12.0],
suppressionButtonFont = [CPFont systemFontOfSize:CPFontCurrentSystemSize],
warningIcon = PatternImage("alert-warning.png", 53.0, 46.0);
themedAlertValues =
+9 -9
View File
@@ -98,7 +98,7 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
[self setLineBreakMode:CPLineBreakByClipping];
//[self setTextColor:[aControl textColor]];
[self setAlignment:CPCenterTextAlignment];
[self setFont:[CPFont systemFontOfSize:12.0]];
[self setFont:[CPFont systemFontOfSize:CPFontCurrentSystemSize]];
[self setImagePosition:CPNoImage];
[self setImageScaling:CPImageScaleNone];
}
@@ -242,7 +242,7 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
- (void)setFont:(CPFont)aFont
{
if (_font === aFont)
if ([_font isEqual:aFont])
return;
_font = aFont;
@@ -434,7 +434,7 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
var shadowStyle = _DOMTextShadowElement.style;
shadowStyle.font = [_font ? _font : [CPFont systemFontOfSize:12.0] cssString];
shadowStyle.font = [(_font || [CPFont systemFontOfSize:CPFontCurrentSystemSize]) cssString];
shadowStyle.position = "absolute";
shadowStyle.whiteSpace = textStyle.whiteSpace;
shadowStyle.wordWrap = textStyle.wordWrap;
@@ -484,7 +484,7 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
if (_flags & _CPImageAndTextViewFontChangedFlag)
{
var fontStyle = [(_font ? _font : [CPFont systemFontOfSize:12.0]) cssString];
var fontStyle = [(_font || [CPFont systemFontOfSize:CPFontCurrentSystemSize]) cssString];
textStyle.font = fontStyle;
if (shadowStyle)
@@ -700,8 +700,8 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
textStyle.top = ROUND(textRectY) + "px";
textStyle.left = ROUND(textRectX) + "px";
textStyle.width = MAX(ROUND(textRectWidth), 0) + "px";
textStyle.height = MAX(ROUND(textRectHeight), 0) + "px";
textStyle.width = MAX(CEIL(textRectWidth), 0) + "px";
textStyle.height = MAX(CEIL(textRectHeight), 0) + "px";
if (shadowStyle)
{
@@ -710,8 +710,8 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
shadowStyle.top = ROUND(textRectY + _textShadowOffset.height) + "px";
shadowStyle.left = ROUND(textRectX + _textShadowOffset.width) + "px";
shadowStyle.width = MAX(ROUND(textRectWidth), 0) + "px";
shadowStyle.height = MAX(ROUND(textRectHeight), 0) + "px";
shadowStyle.width = MAX(CEIL(textRectWidth), 0) + "px";
shadowStyle.height = MAX(CEIL(textRectHeight), 0) + "px";
}
}
#endif
@@ -734,7 +734,7 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
if ((_imagePosition !== CPImageOnly) && [_text length] > 0)
{
if (!_textSize)
_textSize = [_text sizeWithFont:_font ? _font : [CPFont systemFontOfSize:12.0]];
_textSize = [_text sizeWithFont:_font || [CPFont systemFontOfSize:CPFontCurrentSystemSize]];
if (!_image || _imagePosition === CPImageOverlaps)
{
@@ -7,6 +7,7 @@
*/
@import <Foundation/CPObject.j>
@import <AppKit/CPView.j>
var fontLabelField = nil,
@@ -15,17 +16,13 @@ var fontLabelField = nil,
@implementation AppController : CPObject
{
CPWindow theWindow; //this "outlet" is connected automatically by the Cib
CPTextField label1;
CPTextField fontLabel;
CPTableView theTableView;
CPRadio radio1;
CPRadio radio2;
}
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
{
// This is called when the application is done loading.
@outlet CPWindow theWindow;
@outlet CPTextField systemFontLabel;
@outlet CPTextField label1;
@outlet CPTextField fontLabel;
@outlet CPTableView theTableView;
@outlet CPRadio radio1;
@outlet CPRadio radio2;
}
- (void)awakeFromCib
@@ -44,6 +41,9 @@ var fontLabelField = nil,
[radio1 setFont:font];
[radio2 setFont:font];
var systemFont = [CPString stringWithFormat:@"System font: %@ %d", [CPFont systemFontFace], [CPFont systemFontSize]];
[systemFontLabel setStringValue:systemFont];
}
- (int)numberOfRowsInTableView:(id)aTableView
@@ -6,9 +6,5 @@
<string>MainMenu.cib</string>
<key>CPBundleName</key>
<string>FontEnhancementTest</string>
<key>CPSystemFontFace</key>
<string>Lucida Grande</string>
<key>CPSystemFontSize</key>
<string>12</string>
</dict>
</plist>
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
@@ -19,7 +19,8 @@
<link rel="apple-touch-icon" href="Resources/icon.png" />
<link rel="apple-touch-startup-image" href="Resources/default.png" />
<link href='http://fonts.googleapis.com/css?family=Ubuntu,Cabin' rel='stylesheet' type='text/css' />
<link href='http://fonts.googleapis.com/css?family=Ubuntu' rel='stylesheet' type='text/css'>
<title>FontEnhancementTest</title>
+2 -1
View File
@@ -19,7 +19,8 @@
<link rel="apple-touch-icon" href="Resources/icon.png" />
<link rel="apple-touch-startup-image" href="Resources/default.png" />
<link href='http://fonts.googleapis.com/css?family=Ubuntu,Cabin' rel='stylesheet' type='text/css' />
<link href='http://fonts.googleapis.com/css?family=Ubuntu' rel='stylesheet' type='text/css'>
<title>FontEnhancementTest</title>
File diff suppressed because one or more lines are too long
@@ -1,22 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1060</int>
<string key="IBDocument.SystemVersion">10F569</string>
<string key="IBDocument.InterfaceBuilderVersion">788</string>
<string key="IBDocument.AppKitVersion">1038.29</string>
<string key="IBDocument.HIToolboxVersion">461.00</string>
<int key="IBDocument.SystemTarget">1070</int>
<string key="IBDocument.SystemVersion">11E53</string>
<string key="IBDocument.InterfaceBuilderVersion">2182</string>
<string key="IBDocument.AppKitVersion">1138.47</string>
<string key="IBDocument.HIToolboxVersion">569.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">788</string>
<string key="NS.object.0">2182</string>
</object>
<array class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<integer value="372"/>
<array key="IBDocument.IntegratedClassDependencies">
<string>NSPopUpButton</string>
<string>NSMenuItem</string>
<string>NSMenu</string>
<string>NSTextFieldCell</string>
<string>NSSlider</string>
<string>NSSliderCell</string>
<string>NSCustomObject</string>
<string>NSCustomView</string>
<string>NSView</string>
<string>NSWindowTemplate</string>
<string>NSTextField</string>
<string>NSPopUpButtonCell</string>
</array>
<array key="IBDocument.PluginDependencies">
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</array>
<dictionary class="NSMutableDictionary" key="IBDocument.Metadata"/>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
<integer value="1" key="NS.object.0"/>
</object>
<array class="NSMutableArray" key="IBDocument.RootObjects" id="1048">
<object class="NSCustomObject" id="1021">
<string key="NSClassName">NSApplication</string>
@@ -35,7 +49,7 @@
<string key="NSWindowTitle">Font Metrics Explorer</string>
<string key="NSWindowClass">NSWindow</string>
<nil key="NSViewClass"/>
<string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string>
<nil key="NSUserInterfaceItemIdentifier"/>
<object class="NSView" key="NSWindowView" id="439893737">
<reference key="NSNextResponder"/>
<int key="NSvFlags">274</int>
@@ -45,6 +59,8 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{54, 206}, {243, 26}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="908680470"/>
<bool key="NSEnabled">YES</bool>
<object class="NSPopUpButtonCell" key="NSCell" id="443809738">
<int key="NSCellFlags">-2076049856</int>
@@ -98,6 +114,8 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{19, 210}, {38, 17}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="999404096"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="239508957">
<int key="NSCellFlags">68288064</int>
@@ -130,6 +148,8 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{19, 80}, {67, 17}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="725348302"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="994899642">
<int key="NSCellFlags">68288064</int>
@@ -146,6 +166,8 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{99, 80}, {35, 17}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="823167139"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="364967556">
<int key="NSCellFlags">68288064</int>
@@ -162,6 +184,8 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{99, 55}, {35, 17}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="417280360"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="264413839">
<int key="NSCellFlags">68288064</int>
@@ -178,6 +202,8 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{99, 30}, {35, 17}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="605512847"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="755927601">
<int key="NSCellFlags">68288064</int>
@@ -194,6 +220,8 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{19, 55}, {75, 17}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="730682452"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="223373694">
<int key="NSCellFlags">68288064</int>
@@ -210,6 +238,8 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{19, 30}, {80, 17}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="380300553"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="617236685">
<int key="NSCellFlags">68288064</int>
@@ -226,6 +256,8 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{146, 16}, {167, 14}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="508133354">
<int key="NSCellFlags">68288064</int>
@@ -246,6 +278,8 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{17, 250}, {72, 22}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="1039897555"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="297713421">
<int key="NSCellFlags">68288064</int>
@@ -266,6 +300,8 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{17, 115}, {72, 22}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="246524262"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="588810411">
<int key="NSCellFlags">68288064</int>
@@ -282,6 +318,8 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{19, 173}, {38, 17}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="42125743"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="938349708">
<int key="NSCellFlags">68288064</int>
@@ -298,6 +336,8 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{282, 173}, {31, 17}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="411217540"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="1067054775">
<int key="NSCellFlags">68288064</int>
@@ -314,6 +354,8 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{57, 174}, {214, 21}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="803856037"/>
<bool key="NSEnabled">YES</bool>
<object class="NSSliderCell" key="NSCell" id="275925957">
<int key="NSCellFlags">-2080244224</int>
@@ -339,6 +381,8 @@
<int key="NSvFlags">298</int>
<string key="NSFrame">{{-3, 40}, {169, 18}}</string>
<reference key="NSSuperview" ref="605512847"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="1067943843"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="331121288">
<int key="NSCellFlags">68288064</int>
@@ -357,6 +401,8 @@
</array>
<string key="NSFrame">{{149, 35}, {163, 100}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="654402926"/>
<string key="NSClassName">MetricsView</string>
</object>
<object class="NSCustomView" id="1067943843">
@@ -364,14 +410,19 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{149, 35}, {163, 100}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="553841872"/>
<string key="NSClassName">BaselineView</string>
</object>
</array>
<string key="NSFrameSize">{332, 290}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="138531732"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1680, 1028}}</string>
<string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string>
<string key="NSMaxSize">{10000000000000, 10000000000000}</string>
<bool key="NSWindowIsRestorable">YES</bool>
</object>
<object class="NSCustomObject" id="635946545">
<string key="NSClassName">AppController</string>
@@ -459,14 +510,6 @@
</object>
<int key="connectionID">1095</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">sampleText</string>
<reference key="source" ref="605512847"/>
<reference key="destination" ref="654402926"/>
</object>
<int key="connectionID">1103</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">metricsView</string>
@@ -483,6 +526,14 @@
</object>
<int key="connectionID">1109</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">sampleText</string>
<reference key="source" ref="605512847"/>
<reference key="destination" ref="654402926"/>
</object>
<int key="connectionID">1103</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
@@ -773,10 +824,11 @@
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="-3.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="1046.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="1047.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="1048.IBEditorWindowLastContentRect">{{451, 847}, {110, 23}}</string>
<string key="1048.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="1049.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="1052.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -806,16 +858,14 @@
<string key="1088.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="1098.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="1099.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="1106.IBEditorWindowLastContentRect">{{329, 888}, {163, 96}}</string>
<string key="1106.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="1110.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="1111.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="371.IBEditorWindowLastContentRect">{{884, 511}, {332, 290}}</string>
<string key="371.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="371.IBWindowTemplateEditedContentRect">{{884, 511}, {332, 290}}</string>
<integer value="1" key="371.NSWindowTemplate.visibleAtLaunch"/>
<string key="371.editorWindowContentRectSynchronizationRect">{{33, 99}, {480, 360}}</string>
<string key="372.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="450.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/>
@@ -828,20 +878,6 @@
<object class="IBPartialClassDescription">
<string key="className">AppController</string>
<string key="superclassName">NSObject</string>
<dictionary class="NSMutableDictionary" key="actions">
<string key="setFontFamily:">id</string>
<string key="setFontSize:">id</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="actionInfosByName">
<object class="IBActionInfo" key="setFontFamily:">
<string key="name">setFontFamily:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="setFontSize:">
<string key="name">setFontSize:</string>
<string key="candidateClassName">id</string>
</object>
</dictionary>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="ascenderText">NSTextField</string>
<string key="baselineView">BaselineView</string>
@@ -851,7 +887,6 @@
<string key="metricsView">MetricsView</string>
<string key="sizeSlider">NSSlider</string>
<string key="sizeText">NSTextField</string>
<string key="theWindow">NSWindow</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
<object class="IBToOneOutletInfo" key="ascenderText">
@@ -886,22 +921,18 @@
<string key="name">sizeText</string>
<string key="candidateClassName">NSTextField</string>
</object>
<object class="IBToOneOutletInfo" key="theWindow">
<string key="name">theWindow</string>
<string key="candidateClassName">NSWindow</string>
</object>
</dictionary>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBUserSource</string>
<string key="minorKey"/>
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/AppController.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">BaselineView</string>
<string key="superclassName">NSView</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBUserSource</string>
<string key="minorKey"/>
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/BaselineView.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
@@ -919,8 +950,8 @@
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBUserSource</string>
<string key="minorKey"/>
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/MetricsView.h</string>
</object>
</object>
</array>
@@ -928,11 +959,10 @@
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<string key="IBDocument.LastKnownRelativeProjectPath">../registration.xcodeproj</string>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<dictionary class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
<string key="NSMenuCheckmark">{9, 8}</string>
<string key="NSMenuMixedState">{7, 2}</string>
<string key="NSMenuCheckmark">{11, 11}</string>
<string key="NSMenuMixedState">{10, 3}</string>
</dictionary>
</data>
</archive>
@@ -86,6 +86,7 @@
buildPhases = (
E1D3CF6812AFEE3800CBB79E /* Sources */,
E1D3CF6912AFEE3800CBB79E /* Frameworks */,
E180EE6415AB52D500757AC7 /* ShellScript */,
);
buildRules = (
);
@@ -120,6 +121,23 @@
};
/* End PBXProject section */
/* Begin PBXShellScriptBuildPhase section */
E180EE6415AB52D500757AC7 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/bash;
shellScript = "if [[ -d \"$CAPP_BUILD\"/Debug/CommonJS/cappuccino/bin ]]; then\n\tcp \"$SYMROOT/$CONFIGURATION/$PRODUCT_NAME\" \"$CAPP_BUILD\"/Debug/CommonJS/cappuccino/bin\nfi\n\nif [[ -d \"$CAPP_BUILD\"/Release/CommonJS/cappuccino/bin ]]; then\n\tcp \"$SYMROOT/$CONFIGURATION/$PRODUCT_NAME\" \"$CAPP_BUILD\"/Release/CommonJS/cappuccino/bin\nfi\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
E1D3CF6812AFEE3800CBB79E /* Sources */ = {
isa = PBXSourcesBuildPhase;
@@ -163,23 +181,12 @@
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(NATIVE_ARCH_ACTUAL)";
CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)";
CONFIGURATION_TEMP_DIR = "$(CAPP_BUILD)";
DEPLOYMENT_LOCATION = NO;
DEPLOYMENT_POSTPROCESSING = NO;
DSTROOT = "/tmp/$(PROJECT_NAME).dst";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_PRECOMPILE_PREFIX_HEADER = NO;
GCC_PREFIX_HEADER = "";
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INSTALL_PATH = "";
OBJROOT = "$(CAPP_BUILD)";
ONLY_ACTIVE_ARCH = NO;
PREBINDING = NO;
PRODUCT_NAME = fontinfo;
SDKROOT = macosx10.5;
SYMROOT = "$(CAPP_BUILD)/Release/CommonJS/cappuccino/bin";
};
name = Release;
};
@@ -84,6 +84,7 @@
buildPhases = (
E1D3CF6812AFEE3800CBB79E /* Sources */,
E1D3CF6912AFEE3800CBB79E /* Frameworks */,
E180EE7A15AB561300757AC7 /* ShellScript */,
);
buildRules = (
);
@@ -118,6 +119,23 @@
};
/* End PBXProject section */
/* Begin PBXShellScriptBuildPhase section */
E180EE7A15AB561300757AC7 /* ShellScript */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 8;
files = (
);
inputPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 1;
shellPath = /bin/bash;
shellScript = "if [[ -d \"$CAPP_BUILD\"/Debug/CommonJS/cappuccino/bin ]]; then\n\tcp \"$SYMROOT/$CONFIGURATION/$PRODUCT_NAME\" \"$CAPP_BUILD\"/Debug/CommonJS/cappuccino/bin\nfi\n\nif [[ -d \"$CAPP_BUILD\"/Release/CommonJS/cappuccino/bin ]]; then\n\tcp \"$SYMROOT/$CONFIGURATION/$PRODUCT_NAME\" \"$CAPP_BUILD\"/Release/CommonJS/cappuccino/bin\nfi\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
E1D3CF6812AFEE3800CBB79E /* Sources */ = {
isa = PBXSourcesBuildPhase;
@@ -161,23 +179,15 @@
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(NATIVE_ARCH_ACTUAL)";
CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)";
CONFIGURATION_TEMP_DIR = "$(CAPP_BUILD)";
DEPLOYMENT_LOCATION = NO;
DEPLOYMENT_POSTPROCESSING = NO;
DSTROOT = "/tmp/$(PROJECT_NAME).dst";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_PRECOMPILE_PREFIX_HEADER = NO;
GCC_PREFIX_HEADER = "";
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INSTALL_PATH = "";
OBJROOT = "$(CAPP_BUILD)";
ONLY_ACTIVE_ARCH = NO;
PREBINDING = NO;
PRODUCT_NAME = imagesize;
SDKROOT = macosx10.5;
SYMROOT = "$(CAPP_BUILD)/Release/CommonJS/cappuccino/bin";
};
name = Release;
};
+11 -9
View File
@@ -118,10 +118,10 @@
{
var cibFont = nil;
if ([object respondsToSelector:@selector(cibFontForNibFont)])
cibFont = [object cibFontForNibFont];
if ([object respondsToSelector:@selector(cibFontForNibFont:)])
cibFont = [object cibFontForNibFont:[object font]];
else
cibFont = [NSFont cibFontForNibFont:[object font]];
cibFont = [[object font] cibFontForNibFont];
if (!cibFont || ![cibFont isEqual:nibFont])
{
@@ -143,22 +143,24 @@
}
}
// Substitute legacy theme fonts for the current system font
if (!cibFont || [cibFont familyName] === CPFontDefaultSystemFontFace)
if (!cibFont || [cibFont isSystem])
{
var size = [cibFont size] || CPFontDefaultSystemFontSize,
bold = cibFont ? [cibFont isBold] : bold;
var size = [cibFont size] || CPFontDefaultSystemFontSize;
bold = cibFont ? [cibFont isBold] : bold;
if (size === CPFontDefaultSystemFontSize)
size = [CPFont systemFontSize];
size = CPFontCurrentSystemSize;
cibFont = bold ? [CPFont boldSystemFontOfSize:size] : [CPFont systemFontOfSize:size];
}
}
var replacement = "System " + (bold ? "bold " : "") + ([cibFont isSystemSize] ? "(current size)" : [cibFont size]);
[object setFont:cibFont];
CPLog.debug("%s: substituted <%s>%s for <%fpx %s>", [object className], cibFont ? [cibFont cssString] : "theme default", source, [nibFont size], [nibFont familyName]);
CPLog.debug("%s: substituted <%s>%s for <%s>", [object className], replacement || [NSFont descriptorForFont:cibFont], source, [NSFont descriptorForFont:nibFont]);
}
}
+49 -15
View File
@@ -22,12 +22,12 @@
@import <AppKit/CPFont.j>
IBDefaultFontFace = @"Lucida Grande";
IBDefaultFontSize = 13.0;
var OS = require("os"),
fontinfo = require("cappuccino/fontinfo").fontinfo;
var IBDefaultFontFace = @"Lucida Grande",
IBDefaultFontSize = 13.0;
@implementation CPFont (NSCoding)
- (id)NS_initWithCoder:(CPCoder)aCoder
@@ -45,7 +45,33 @@ var IBDefaultFontFace = @"Lucida Grande",
isItalic = info.italic;
}
return [self _initWithName:name size:size bold:isBold italic:isItalic];
// NOTE: We save the nib fonts as is, and determine system status later
var font = [self _initWithName:name
size:size
bold:isBold
italic:isItalic
system:NO];
CPLog.debug("NSFont: %s", [NSFont descriptorForFont:font]);
return font;
}
- (id)cibFontForNibFont
{
if (_name === IBDefaultFontFace)
{
if (_size === IBDefaultFontSize && !_isBold && !_isItalic)
return nil;
else
return [[CPFont alloc] _initWithName:_CPFontSystemFacePlaceholder
size:_size == IBDefaultFontSize ? CPFontCurrentSystemSize : _size
bold:_isBold
italic:_isItalic
system:YES];
}
return self;
}
@end
@@ -60,23 +86,31 @@ var IBDefaultFontFace = @"Lucida Grande",
CPLog.debug("NSFont: default IB font: %s %f", IBDefaultFontFace, IBDefaultFontSize);
}
+ (id)cibFontForNibFont:(CPFont)aFont
+ (CPString)descriptorForFont:(CPFont)aFont
{
var name = [aFont familyName];
var styleAttributes = [];
if (name === IBDefaultFontFace)
if ([aFont isBold])
styleAttributes.push("bold");
if ([aFont isItalic])
styleAttributes.push("italic");
styleAttributes = styleAttributes.join(" ");
var systemAttributes = [];
if ([aFont isSystem])
{
var size = [aFont size],
bold = [aFont isBold],
italic = [aFont isItalic];
systemAttributes.push("system face");
if (size === IBDefaultFontSize && !bold && !italic)
return nil;
else
return [[CPFont alloc] _initWithName:[CPFont systemFontFace] size:(size == IBDefaultFontSize ? CPFontDefaultSystemFontSize : size) bold:bold italic:italic];
if ([aFont size] === IBDefaultFontSize)
systemAttributes.push("system size");
}
return [aFont copy];
systemAttributes = systemAttributes.join(", ");
return [CPString stringWithFormat:@"%s%s %d%s", [aFont familyName], styleAttributes ? " " + styleAttributes : "", [aFont size], systemAttributes ? " (" + systemAttributes + ")" : ""];
}
- (id)initWithCoder:(CPCoder)aCoder
+1 -1
View File
@@ -51,7 +51,7 @@
selectedFont = nil;
if (font)
font = [NSFont cibFontForNibFont:font];
font = [font cibFontForNibFont];
if (!font)
font = [CPFont systemFontOfSize:[CPFont systemFontSize]];
+10
View File
@@ -80,6 +80,7 @@ var FILE = require("file"),
var options = [self parseOptionsFromArgs:commandLineArgs];
[self setLogLevel:options.quiet ? -1 : options.verbosity];
[self checkPrerequisites];
if (options.watch)
[self watchWithOptions:options];
@@ -93,6 +94,15 @@ var FILE = require("file"),
}
}
- (void)checkPrerequisites
{
var fontinfo = require("cappuccino/fontinfo").fontinfo,
info = fontinfo("LucidaGrande", 13);
if (!info)
[self failWithMessage:@"fontinfo does not appear to be installed"];
}
- (BOOL)convertWithOptions:(JSObject)options inputFile:(CPString)inputFile
{
try