Commit eaaeb59a authored by dino@apple.com's avatar dino@apple.com

[Mac] Use fontName rather than familyName for internal fonts

https://bugs.webkit.org/show_bug.cgi?id=113392
<rdar://problem/13474743>

Reviewed by Enrica Casucci.

Some internal fonts on OS X have a family name that
isn't listed in availableFontFamilies. In this case
we should use the font name rather than the family
name when looking for a match.

* platform/mac/ThemeMac.h: NSFont category to provide a web-friendly family name.
* platform/mac/ThemeMac.mm:
(-[NSFont webCoreFamilyName]): Returns the font name for internal fonts, otherwise the family name.
(WebCore::ThemeMac::controlFont):
* rendering/RenderThemeMacShared.mm: Use the webCoreFamilyName.
(WebCore::RenderThemeMacShared::systemFont): Ditto.
(WebCore::RenderThemeMacShared::setFontFromControlSize): Ditto.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@146995 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 4510cc69
2013-03-27 Dean Jackson <dino@apple.com>
[Mac] Use fontName rather than familyName for internal fonts
https://bugs.webkit.org/show_bug.cgi?id=113392
<rdar://problem/13474743>
Reviewed by Enrica Casucci.
Some internal fonts on OS X have a family name that
isn't listed in availableFontFamilies. In this case
we should use the font name rather than the family
name when looking for a match.
* platform/mac/ThemeMac.h: NSFont category to provide a web-friendly family name.
* platform/mac/ThemeMac.mm:
(-[NSFont webCoreFamilyName]): Returns the font name for internal fonts, otherwise the family name.
(WebCore::ThemeMac::controlFont):
* rendering/RenderThemeMacShared.mm: Use the webCoreFamilyName.
(WebCore::RenderThemeMacShared::systemFont): Ditto.
(WebCore::RenderThemeMacShared::setFontFromControlSize): Ditto.
2013-03-26 Jer Noble <jer.noble@apple.com>
Mac: Media Controls always hide time display elements
......@@ -28,6 +28,10 @@
#include "Theme.h"
@interface NSFont(WebCoreTheme)
- (NSString*)webCoreFamilyName;
@end
namespace WebCore {
class ThemeMac : public Theme {
......
......@@ -78,6 +78,18 @@ NSRect focusRingClipRect;
@end
@implementation NSFont (WebCoreTheme)
- (NSString*)webCoreFamilyName
{
if ([[self familyName] hasPrefix:@"."])
return [self fontName];
return [self familyName];
}
@end
// FIXME: Default buttons really should be more like push buttons and not like buttons.
namespace WebCore {
......@@ -595,7 +607,7 @@ FontDescription ThemeMac::controlFont(ControlPart part, const Font& font, float
fontDescription.setGenericFamily(FontDescription::SerifFamily);
NSFont* nsFont = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:controlSizeForFont(font)]];
fontDescription.firstFamily().setFamily([nsFont familyName]);
fontDescription.firstFamily().setFamily([nsFont webCoreFamilyName]);
fontDescription.setComputedSize([nsFont pointSize] * zoomFactor);
fontDescription.setSpecifiedSize([nsFont pointSize] * zoomFactor);
return fontDescription;
......
......@@ -282,7 +282,7 @@ void RenderThemeMacShared::systemFont(int cssValueId, FontDescription& fontDescr
NSFontManager *fontManager = [NSFontManager sharedFontManager];
cachedDesc->setIsAbsoluteSize(true);
cachedDesc->setGenericFamily(FontDescription::NoFamily);
cachedDesc->firstFamily().setFamily([font familyName]);
cachedDesc->firstFamily().setFamily([font webCoreFamilyName]);
cachedDesc->setSpecifiedSize([font pointSize]);
cachedDesc->setWeight(toFontWeight([fontManager weightOfFont:font]));
cachedDesc->setItalic([fontManager traitsOfFont:font] & NSItalicFontMask);
......@@ -689,7 +689,7 @@ void RenderThemeMacShared::setFontFromControlSize(StyleResolver*, RenderStyle* s
fontDescription.setGenericFamily(FontDescription::SerifFamily);
NSFont* font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:controlSize]];
fontDescription.firstFamily().setFamily([font familyName]);
fontDescription.firstFamily().setFamily([font webCoreFamilyName]);
fontDescription.setComputedSize([font pointSize] * style->effectiveZoom());
fontDescription.setSpecifiedSize([font pointSize] * style->effectiveZoom());
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment