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

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

Issue 175253002: Switch to HarfBuzz on Mac and remove CoreText shaper (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased on master, TestExpectations tuned, ready to land? 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"
31 #import "platform/fonts/harfbuzz/HarfBuzzFace.h" 33 #import "platform/fonts/harfbuzz/HarfBuzzFace.h"
32 #include "third_party/skia/include/ports/SkTypeface_mac.h" 34 #include "third_party/skia/include/ports/SkTypeface_mac.h"
33 35
36
37
34 namespace blink { 38 namespace blink {
35 39
36 unsigned FontPlatformData::hash() const 40 unsigned FontPlatformData::hash() const
37 { 41 {
38 ASSERT(m_font || !m_cgFont); 42 ASSERT(m_font || !m_cgFont);
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) }; 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) };
40 return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes); 44 return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes);
41 } 45 }
42 46
47 void FontPlatformData::setupPaint(SkPaint* paint, GraphicsContext*) const
48 {
49 bool shouldSmoothFonts = true;
50 bool shouldAntialias = true;
51
52 shouldAntialias = shouldAntialias && (!LayoutTestSupport::isRunningLayoutTes t() || LayoutTestSupport::isFontAntialiasingEnabledForTest());
eae 2014/09/26 14:32:08 Nit: you might want to wrap this line.
53 bool useSubpixelText = RuntimeEnabledFeatures::subpixelFontScalingEnabled();
54 shouldSmoothFonts = shouldSmoothFonts && !LayoutTestSupport::isRunningLayout Test();
55
56 paint->setAntiAlias(shouldAntialias);
57 paint->setEmbeddedBitmapText(false);
58 const float ts = m_textSize >= 0 ? m_textSize : 12;
59 paint->setTextSize(SkFloatToScalar(ts));
60 paint->setTypeface(typeface());
61 paint->setFakeBoldText(m_syntheticBold);
62 paint->setTextSkewX(m_syntheticItalic ? -SK_Scalar1 / 4 : 0);
63 paint->setAutohinted(false); // freetype specific
64 paint->setLCDRenderText(shouldSmoothFonts);
65 paint->setSubpixelText(useSubpixelText);
66 paint->setHinting(SkPaint::kNo_Hinting);
67 }
68
43 // These CoreText Text Spacing feature selectors are not defined in CoreText. 69 // These CoreText Text Spacing feature selectors are not defined in CoreText.
44 enum TextSpacingCTFeatureSelector { TextSpacingProportional, TextSpacingFullWidt h, TextSpacingHalfWidth, TextSpacingThirdWidth, TextSpacingQuarterWidth }; 70 enum TextSpacingCTFeatureSelector { TextSpacingProportional, TextSpacingFullWidt h, TextSpacingHalfWidth, TextSpacingThirdWidth, TextSpacingQuarterWidth };
45 71
46 FontPlatformData::FontPlatformData(NSFont *nsFont, float size, bool syntheticBol d, bool syntheticItalic, FontOrientation orientation, FontWidthVariant widthVari ant) 72 FontPlatformData::FontPlatformData(NSFont *nsFont, float size, bool syntheticBol d, bool syntheticItalic, FontOrientation orientation, FontWidthVariant widthVari ant)
47 : m_textSize(size) 73 : m_textSize(size)
48 , m_syntheticBold(syntheticBold) 74 , m_syntheticBold(syntheticBold)
49 , m_syntheticItalic(syntheticItalic) 75 , m_syntheticItalic(syntheticItalic)
50 , m_orientation(orientation) 76 , m_orientation(orientation)
51 , m_isColorBitmapFont(false) 77 , m_isColorBitmapFont(false)
52 , m_isCompositeFontReference(false) 78 , m_isCompositeFontReference(false)
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 RetainPtr<CTFontDescriptorRef> newDescriptor(AdoptCF, CTFontDescriptorCr eateCopyWithFeature(sourceDescriptor.get(), featureType.get(), featureSelector.g et())); 283 RetainPtr<CTFontDescriptorRef> newDescriptor(AdoptCF, CTFontDescriptorCr eateCopyWithFeature(sourceDescriptor.get(), featureType.get(), featureSelector.g et()));
258 RetainPtr<CTFontRef> newFont(AdoptCF, CTFontCreateWithFontDescriptor(new Descriptor.get(), m_textSize, 0)); 284 RetainPtr<CTFontRef> newFont(AdoptCF, CTFontCreateWithFontDescriptor(new Descriptor.get(), m_textSize, 0));
259 285
260 if (newFont) 286 if (newFont)
261 m_CTFont = newFont; 287 m_CTFont = newFont;
262 } 288 }
263 289
264 return m_CTFont.get(); 290 return m_CTFont.get();
265 } 291 }
266 292
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
282 } // namespace blink 293 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698