OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2010, 2011 Apple Inc. All rights reserved. |
3 * Copyright (C) 2006 Alexey Proskuryakov | 3 * Copyright (C) 2006 Alexey Proskuryakov |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 13 matching lines...) Expand all Loading... | |
24 * THE POSSIBILITY OF SUCH DAMAGE. | 24 * THE POSSIBILITY OF SUCH DAMAGE. |
25 */ | 25 */ |
26 | 26 |
27 #import "config.h" | 27 #import "config.h" |
28 #import "platform/fonts/SimpleFontData.h" | 28 #import "platform/fonts/SimpleFontData.h" |
29 | 29 |
30 #import <AppKit/AppKit.h> | 30 #import <AppKit/AppKit.h> |
31 #import <ApplicationServices/ApplicationServices.h> | 31 #import <ApplicationServices/ApplicationServices.h> |
32 #import <float.h> | 32 #import <float.h> |
33 #import <unicode/uchar.h> | 33 #import <unicode/uchar.h> |
34 #import "RuntimeEnabledFeatures.h" | |
35 #import "platform/LayoutTestSupport.h" | |
34 #import "platform/SharedBuffer.h" | 36 #import "platform/SharedBuffer.h" |
35 #import "platform/fonts/Font.h" | 37 #import "platform/fonts/Font.h" |
36 #import "platform/fonts/FontCache.h" | 38 #import "platform/fonts/FontCache.h" |
37 #import "platform/fonts/FontDescription.h" | 39 #import "platform/fonts/FontDescription.h" |
38 #import "platform/geometry/FloatRect.h" | 40 #import "platform/geometry/FloatRect.h" |
39 #import "platform/graphics/Color.h" | 41 #import "platform/graphics/Color.h" |
40 #import "platform/mac/BlockExceptions.h" | 42 #import "platform/mac/BlockExceptions.h" |
41 #import <wtf/Assertions.h> | 43 #import <wtf/Assertions.h> |
42 #import <wtf/RetainPtr.h> | 44 #import <wtf/RetainPtr.h> |
43 #import <wtf/StdLibExtras.h> | 45 #import <wtf/StdLibExtras.h> |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 | 101 |
100 return true; | 102 return true; |
101 } | 103 } |
102 | 104 |
103 static NSString *webFallbackFontFamily(void) | 105 static NSString *webFallbackFontFamily(void) |
104 { | 106 { |
105 DEFINE_STATIC_LOCAL(RetainPtr<NSString>, webFallbackFontFamily, ([[NSFont sy stemFontOfSize:16.0f] familyName])); | 107 DEFINE_STATIC_LOCAL(RetainPtr<NSString>, webFallbackFontFamily, ([[NSFont sy stemFontOfSize:16.0f] familyName])); |
106 return webFallbackFontFamily.get(); | 108 return webFallbackFontFamily.get(); |
107 } | 109 } |
108 | 110 |
111 static bool useHinting() | |
112 { | |
113 // Enable hinting when subpixel font scaling is disabled or | |
114 // when running the set of standard non-subpixel layout tests, | |
115 // otherwise use subpixel glyph positioning. | |
116 return (isRunningLayoutTest() && !isFontAntialiasingEnabledForTest()) || !Ru ntimeEnabledFeatures::subpixelFontScalingEnabled(); | |
117 } | |
118 | |
109 const SimpleFontData* SimpleFontData::getCompositeFontReferenceFontData(NSFont * key) const | 119 const SimpleFontData* SimpleFontData::getCompositeFontReferenceFontData(NSFont * key) const |
110 { | 120 { |
111 if (key && !CFEqual(RetainPtr<CFStringRef>(AdoptCF, CTFontCopyPostScriptName (CTFontRef(key))).get(), CFSTR("LastResort"))) { | 121 if (key && !CFEqual(RetainPtr<CFStringRef>(AdoptCF, CTFontCopyPostScriptName (CTFontRef(key))).get(), CFSTR("LastResort"))) { |
112 if (!m_derivedFontData) | 122 if (!m_derivedFontData) |
113 m_derivedFontData = DerivedFontData::create(isCustomFont()); | 123 m_derivedFontData = DerivedFontData::create(isCustomFont()); |
114 if (!m_derivedFontData->compositeFontReferences) | 124 if (!m_derivedFontData->compositeFontReferences) |
115 m_derivedFontData->compositeFontReferences.adoptCF(CFDictionaryCreat eMutable(kCFAllocatorDefault, 1, &kCFTypeDictionaryKeyCallBacks, NULL)); | 125 m_derivedFontData->compositeFontReferences.adoptCF(CFDictionaryCreat eMutable(kCFAllocatorDefault, 1, &kCFTypeDictionaryKeyCallBacks, NULL)); |
116 else { | 126 else { |
117 const SimpleFontData* found = static_cast<const SimpleFontData*>(CFD ictionaryGetValue(m_derivedFontData->compositeFontReferences.get(), static_cast< const void *>(key))); | 127 const SimpleFontData* found = static_cast<const SimpleFontData*>(CFD ictionaryGetValue(m_derivedFontData->compositeFontReferences.get(), static_cast< const void *>(key))); |
118 if (found) | 128 if (found) |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
308 if (isCustomFont()) { | 318 if (isCustomFont()) { |
309 FontPlatformData scaledFontData(m_platformData); | 319 FontPlatformData scaledFontData(m_platformData); |
310 scaledFontData.m_size = scaledFontData.m_size * scaleFactor; | 320 scaledFontData.m_size = scaledFontData.m_size * scaleFactor; |
311 return SimpleFontData::create(scaledFontData, CustomFontData::create()); | 321 return SimpleFontData::create(scaledFontData, CustomFontData::create()); |
312 } | 322 } |
313 | 323 |
314 BEGIN_BLOCK_OBJC_EXCEPTIONS; | 324 BEGIN_BLOCK_OBJC_EXCEPTIONS; |
315 float size = m_platformData.size() * scaleFactor; | 325 float size = m_platformData.size() * scaleFactor; |
316 FontPlatformData scaledFontData([[NSFontManager sharedFontManager] convertFo nt:m_platformData.font() toSize:size], size, false, false, m_platformData.orient ation()); | 326 FontPlatformData scaledFontData([[NSFontManager sharedFontManager] convertFo nt:m_platformData.font() toSize:size], size, false, false, m_platformData.orient ation()); |
317 | 327 |
318 // Until we replace AppKit API (NSFontManager etc.), we always want to disab le hinting, | 328 // AppKit forgets about hinting property when scaling, so we have to remind it. |
319 // so we use the printerFont here. | 329 scaledFontData.setFont(useHinting() ? [scaledFontData.font() screenFont] : [ scaledFontData.font() printerFont]); |
Dominik Röttsches
2014/05/28 14:33:51
This part should have been in the previous patch f
| |
320 scaledFontData.setFont([scaledFontData.font() printerFont]); | |
321 | 330 |
322 if (scaledFontData.font()) { | 331 if (scaledFontData.font()) { |
323 NSFontManager *fontManager = [NSFontManager sharedFontManager]; | 332 NSFontManager *fontManager = [NSFontManager sharedFontManager]; |
324 NSFontTraitMask fontTraits = [fontManager traitsOfFont:m_platformData.fo nt()]; | 333 NSFontTraitMask fontTraits = [fontManager traitsOfFont:m_platformData.fo nt()]; |
325 | 334 |
326 if (m_platformData.m_syntheticBold) | 335 if (m_platformData.m_syntheticBold) |
327 fontTraits |= NSBoldFontMask; | 336 fontTraits |= NSBoldFontMask; |
328 if (m_platformData.m_syntheticOblique) | 337 if (m_platformData.m_syntheticOblique) |
329 fontTraits |= NSItalicFontMask; | 338 fontTraits |= NSItalicFontMask; |
330 | 339 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
438 RetainPtr<CGFontRef> runCGFont(AdoptCF, CTFontCopyGraphicsFont(runFont, 0)); | 447 RetainPtr<CGFontRef> runCGFont(AdoptCF, CTFontCopyGraphicsFont(runFont, 0)); |
439 if (!CFEqual(runCGFont.get(), cgFont.get())) | 448 if (!CFEqual(runCGFont.get(), cgFont.get())) |
440 return false; | 449 return false; |
441 } | 450 } |
442 | 451 |
443 addResult.storedValue->value = true; | 452 addResult.storedValue->value = true; |
444 return true; | 453 return true; |
445 } | 454 } |
446 | 455 |
447 } // namespace WebCore | 456 } // namespace WebCore |
OLD | NEW |