Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(216)

Side by Side Diff: Source/platform/fonts/cocoa/FontPlatformDataCocoa.mm

Issue 618723003: Revert of Switch to HarfBuzz on Mac and remove CoreText shaper (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * This file is part of the internal font implementation. 2 * This file is part of the internal font implementation.
3 * 3 *
4 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. 4 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
5 * Copyright (c) 2010 Google Inc. All rights reserved. 5 * Copyright (c) 2010 Google Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 10 matching lines...) Expand all
21 * 21 *
22 */ 22 */
23 23
24 #import "config.h" 24 #import "config.h"
25 #import "platform/fonts/FontPlatformData.h" 25 #import "platform/fonts/FontPlatformData.h"
26 26
27 #import <AppKit/NSFont.h> 27 #import <AppKit/NSFont.h>
28 #import <AvailabilityMacros.h> 28 #import <AvailabilityMacros.h>
29 #import <wtf/text/WTFString.h> 29 #import <wtf/text/WTFString.h>
30 30
31 #include "platform/LayoutTestSupport.h"
32 #include "platform/RuntimeEnabledFeatures.h"
33 #import "platform/fonts/harfbuzz/HarfBuzzFace.h" 31 #import "platform/fonts/harfbuzz/HarfBuzzFace.h"
34 #include "third_party/skia/include/ports/SkTypeface_mac.h" 32 #include "third_party/skia/include/ports/SkTypeface_mac.h"
35 33
36
37
38 namespace blink { 34 namespace blink {
39 35
40 unsigned FontPlatformData::hash() const 36 unsigned FontPlatformData::hash() const
41 { 37 {
42 ASSERT(m_font || !m_cgFont); 38 ASSERT(m_font || !m_cgFont);
43 uintptr_t hashCodes[3] = { (uintptr_t)m_font, m_widthVariant, static_cast<ui ntptr_t>(m_isHashTableDeletedValue << 3 | m_orientation << 2 | m_syntheticBold < < 1 | m_syntheticItalic) }; 39 uintptr_t hashCodes[3] = { (uintptr_t)m_font, m_widthVariant, static_cast<ui ntptr_t>(m_isHashTableDeletedValue << 3 | m_orientation << 2 | m_syntheticBold < < 1 | m_syntheticItalic) };
44 return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes); 40 return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes);
45 } 41 }
46 42
47 void FontPlatformData::setupPaint(SkPaint* paint, GraphicsContext*) const
48 {
49 bool shouldSmoothFonts = true;
50 bool shouldAntialias = true;
51
52 shouldAntialias = shouldAntialias && (!LayoutTestSupport::isRunningLayoutTes t()
53 || LayoutTestSupport::isFontAntialiasingEnabledForTest());
54 bool useSubpixelText = RuntimeEnabledFeatures::subpixelFontScalingEnabled();
55 shouldSmoothFonts = shouldSmoothFonts && !LayoutTestSupport::isRunningLayout Test();
56
57 paint->setAntiAlias(shouldAntialias);
58 paint->setEmbeddedBitmapText(false);
59 const float ts = m_textSize >= 0 ? m_textSize : 12;
60 paint->setTextSize(SkFloatToScalar(ts));
61 paint->setTypeface(typeface());
62 paint->setFakeBoldText(m_syntheticBold);
63 paint->setTextSkewX(m_syntheticItalic ? -SK_Scalar1 / 4 : 0);
64 paint->setAutohinted(false); // freetype specific
65 paint->setLCDRenderText(shouldSmoothFonts);
66 paint->setSubpixelText(useSubpixelText);
67 paint->setHinting(SkPaint::kNo_Hinting);
68 }
69
70 // These CoreText Text Spacing feature selectors are not defined in CoreText. 43 // These CoreText Text Spacing feature selectors are not defined in CoreText.
71 enum TextSpacingCTFeatureSelector { TextSpacingProportional, TextSpacingFullWidt h, TextSpacingHalfWidth, TextSpacingThirdWidth, TextSpacingQuarterWidth }; 44 enum TextSpacingCTFeatureSelector { TextSpacingProportional, TextSpacingFullWidt h, TextSpacingHalfWidth, TextSpacingThirdWidth, TextSpacingQuarterWidth };
72 45
73 FontPlatformData::FontPlatformData(NSFont *nsFont, float size, bool syntheticBol d, bool syntheticItalic, FontOrientation orientation, FontWidthVariant widthVari ant) 46 FontPlatformData::FontPlatformData(NSFont *nsFont, float size, bool syntheticBol d, bool syntheticItalic, FontOrientation orientation, FontWidthVariant widthVari ant)
74 : m_textSize(size) 47 : m_textSize(size)
75 , m_syntheticBold(syntheticBold) 48 , m_syntheticBold(syntheticBold)
76 , m_syntheticItalic(syntheticItalic) 49 , m_syntheticItalic(syntheticItalic)
77 , m_orientation(orientation) 50 , m_orientation(orientation)
78 , m_isColorBitmapFont(false) 51 , m_isColorBitmapFont(false)
79 , m_isCompositeFontReference(false) 52 , m_isCompositeFontReference(false)
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 RetainPtr<CTFontDescriptorRef> newDescriptor(AdoptCF, CTFontDescriptorCr eateCopyWithFeature(sourceDescriptor.get(), featureType.get(), featureSelector.g et())); 257 RetainPtr<CTFontDescriptorRef> newDescriptor(AdoptCF, CTFontDescriptorCr eateCopyWithFeature(sourceDescriptor.get(), featureType.get(), featureSelector.g et()));
285 RetainPtr<CTFontRef> newFont(AdoptCF, CTFontCreateWithFontDescriptor(new Descriptor.get(), m_textSize, 0)); 258 RetainPtr<CTFontRef> newFont(AdoptCF, CTFontCreateWithFontDescriptor(new Descriptor.get(), m_textSize, 0));
286 259
287 if (newFont) 260 if (newFont)
288 m_CTFont = newFont; 261 m_CTFont = newFont;
289 } 262 }
290 263
291 return m_CTFont.get(); 264 return m_CTFont.get();
292 } 265 }
293 266
267 bool FontPlatformData::isAATFont(CTFontRef ctFont) const
268 {
269 CFDataRef table = CTFontCopyTable(ctFont, kCTFontTableMort, 0);
270 if (table) {
271 CFRelease(table);
272 return true;
273 }
274 table = CTFontCopyTable(ctFont, kCTFontTableMorx, 0);
275 if (table) {
276 CFRelease(table);
277 return true;
278 }
279 return false;
280 }
281
294 } // namespace blink 282 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/fonts/FontPlatformData.cpp ('k') | Source/platform/fonts/harfbuzz/HarfBuzzFaceCoreText.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698