OLD | NEW |
---|---|
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. |
11 * | 11 * |
12 * This library is distributed in the hope that it will be useful, | 12 * This library is distributed in the hope that it will be useful, |
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Library General Public License for more details. | 15 * Library General Public License for more details. |
16 * | 16 * |
17 * You should have received a copy of the GNU Library General Public License | 17 * You should have received a copy of the GNU Library General Public License |
18 * along with this library; see the file COPYING.LIB. If not, write to | 18 * along with this library; see the file COPYING.LIB. If not, write to |
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
20 * Boston, MA 02110-1301, USA. | 20 * Boston, MA 02110-1301, USA. |
21 * | 21 * |
22 */ | 22 */ |
23 | 23 |
24 #import "platform/fonts/FontPlatformData.h" | 24 #import "platform/fonts/FontPlatformData.h" |
25 | 25 |
26 #import "platform/LayoutTestSupport.h" | 26 #import "platform/LayoutTestSupport.h" |
27 #import "platform/fonts/Font.h" | 27 #import "platform/fonts/Font.h" |
28 #import "platform/fonts/opentype/FontSettings.h" | |
28 #import "platform/fonts/shaping/HarfBuzzFace.h" | 29 #import "platform/fonts/shaping/HarfBuzzFace.h" |
29 #import "platform/graphics/skia/SkiaUtils.h" | 30 #import "platform/graphics/skia/SkiaUtils.h" |
30 #import "public/platform/Platform.h" | 31 #import "public/platform/Platform.h" |
31 #import "public/platform/mac/WebSandboxSupport.h" | 32 #import "public/platform/mac/WebSandboxSupport.h" |
32 #import "third_party/skia/include/ports/SkTypeface_mac.h" | 33 #import "third_party/skia/include/ports/SkTypeface_mac.h" |
33 #import "wtf/RetainPtr.h" | 34 #import "wtf/RetainPtr.h" |
34 #import "wtf/text/WTFString.h" | 35 #import "wtf/text/WTFString.h" |
35 #import <AppKit/NSFont.h> | 36 #import <AppKit/NSFont.h> |
36 #import <AvailabilityMacros.h> | 37 #import <AvailabilityMacros.h> |
37 | 38 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
152 | 153 |
153 // When rendering using CoreGraphics, disable hinting when | 154 // When rendering using CoreGraphics, disable hinting when |
154 // webkit-font-smoothing:antialiased or text-rendering:geometricPrecision is | 155 // webkit-font-smoothing:antialiased or text-rendering:geometricPrecision is |
155 // used. See crbug.com/152304 | 156 // used. See crbug.com/152304 |
156 if (font && | 157 if (font && |
157 (font->getFontDescription().fontSmoothing() == Antialiased || | 158 (font->getFontDescription().fontSmoothing() == Antialiased || |
158 font->getFontDescription().textRendering() == GeometricPrecision)) | 159 font->getFontDescription().textRendering() == GeometricPrecision)) |
159 paint->setHinting(SkPaint::kNo_Hinting); | 160 paint->setHinting(SkPaint::kNo_Hinting); |
160 } | 161 } |
161 | 162 |
163 static SkFourByteTag atomicStringToFourByteTag(AtomicString tag) { | |
eae
2016/12/16 18:48:27
Given that we probably want a couple of checks in
drott
2016/12/19 14:12:34
Moved to FontSettings.h and cleared of Skia types
| |
164 return SkSetFourByteTag(tag[0], tag[1], tag[2], tag[3]); | |
165 } | |
166 | |
162 FontPlatformData::FontPlatformData(NSFont* nsFont, | 167 FontPlatformData::FontPlatformData(NSFont* nsFont, |
163 float size, | 168 float size, |
164 bool syntheticBold, | 169 bool syntheticBold, |
165 bool syntheticItalic, | 170 bool syntheticItalic, |
166 FontOrientation orientation) | 171 FontOrientation orientation, |
172 FontVariationSettings* variationSettings) | |
167 : m_textSize(size), | 173 : m_textSize(size), |
168 m_syntheticBold(syntheticBold), | 174 m_syntheticBold(syntheticBold), |
169 m_syntheticItalic(syntheticItalic), | 175 m_syntheticItalic(syntheticItalic), |
170 m_orientation(orientation), | 176 m_orientation(orientation), |
171 m_isHashTableDeletedValue(false) { | 177 m_isHashTableDeletedValue(false) { |
172 DCHECK(nsFont); | 178 DCHECK(nsFont); |
173 if (canLoadInProcess(nsFont)) { | 179 if (canLoadInProcess(nsFont)) { |
174 m_typeface.reset(SkCreateTypefaceFromCTFont(toCTFontRef(nsFont))); | 180 m_typeface.reset(SkCreateTypefaceFromCTFont(toCTFontRef(nsFont))); |
175 } else { | 181 } else { |
176 // In process loading fails for cases where third party font manager | 182 // In process loading fails for cases where third party font manager |
177 // software registers fonts in non system locations such as /Library/Fonts | 183 // software registers fonts in non system locations such as /Library/Fonts |
178 // and ~/Library Fonts, see crbug.com/72727 or crbug.com/108645. | 184 // and ~/Library Fonts, see crbug.com/72727 or crbug.com/108645. |
179 m_typeface = loadFromBrowserProcess(nsFont, size); | 185 m_typeface = loadFromBrowserProcess(nsFont, size); |
180 } | 186 } |
187 | |
188 if (variationSettings && variationSettings->size() < UINT16_MAX) { | |
189 SkFontMgr::FontParameters::Axis axes[variationSettings->size()]; | |
190 for (size_t i = 0; i < variationSettings->size(); ++i) { | |
191 AtomicString featureTag = variationSettings->at(i).tag(); | |
192 axes[i] = {atomicStringToFourByteTag(featureTag), | |
193 SkFloatToScalar(variationSettings->at(i).value())}; | |
194 } | |
195 RefPtr<SkFontMgr> fm = adoptRef(SkFontMgr::RefDefault()); | |
196 // TODO crbug.com/670246: Refactor this to a future Skia API that acccepts | |
197 // axis parameters on system fonts directly. | |
198 m_typeface = sk_sp<SkTypeface>(fm->createFromStream( | |
199 m_typeface->openStream(nullptr)->duplicate(), | |
200 SkFontMgr::FontParameters().setAxes(axes, variationSettings->size()))); | |
201 } | |
181 } | 202 } |
182 | 203 |
183 } // namespace blink | 204 } // namespace blink |
OLD | NEW |