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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/mac/FontPlatformDataMac.mm

Issue 2581083003: Initial OpenType Font Variations Support (Closed)
Patch Set: Fix makeUnique syntax Created 3 years, 12 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.
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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
162 FontPlatformData::FontPlatformData(NSFont* nsFont, 163 FontPlatformData::FontPlatformData(NSFont* nsFont,
163 float size, 164 float size,
164 bool syntheticBold, 165 bool syntheticBold,
165 bool syntheticItalic, 166 bool syntheticItalic,
166 FontOrientation orientation) 167 FontOrientation orientation,
168 FontVariationSettings* variationSettings)
167 : m_textSize(size), 169 : m_textSize(size),
168 m_syntheticBold(syntheticBold), 170 m_syntheticBold(syntheticBold),
169 m_syntheticItalic(syntheticItalic), 171 m_syntheticItalic(syntheticItalic),
170 m_orientation(orientation), 172 m_orientation(orientation),
171 m_isHashTableDeletedValue(false) { 173 m_isHashTableDeletedValue(false) {
172 DCHECK(nsFont); 174 DCHECK(nsFont);
173 if (canLoadInProcess(nsFont)) { 175 if (canLoadInProcess(nsFont)) {
174 m_typeface.reset(SkCreateTypefaceFromCTFont(toCTFontRef(nsFont))); 176 m_typeface.reset(SkCreateTypefaceFromCTFont(toCTFontRef(nsFont)));
175 } else { 177 } else {
176 // In process loading fails for cases where third party font manager 178 // In process loading fails for cases where third party font manager
177 // software registers fonts in non system locations such as /Library/Fonts 179 // software registers fonts in non system locations such as /Library/Fonts
178 // and ~/Library Fonts, see crbug.com/72727 or crbug.com/108645. 180 // and ~/Library Fonts, see crbug.com/72727 or crbug.com/108645.
179 m_typeface = loadFromBrowserProcess(nsFont, size); 181 m_typeface = loadFromBrowserProcess(nsFont, size);
180 } 182 }
183
184 if (variationSettings && variationSettings->size() < UINT16_MAX) {
185 SkFontMgr::FontParameters::Axis axes[variationSettings->size()];
186 for (size_t i = 0; i < variationSettings->size(); ++i) {
187 AtomicString featureTag = variationSettings->at(i).tag();
188 axes[i] = {atomicStringToFourByteTag(featureTag),
189 SkFloatToScalar(variationSettings->at(i).value())};
190 }
191 sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault());
192 // TODO crbug.com/670246: Refactor this to a future Skia API that acccepts
193 // axis parameters on system fonts directly.
194 m_typeface = sk_sp<SkTypeface>(fm->createFromStream(
195 m_typeface->openStream(nullptr)->duplicate(),
196 SkFontMgr::FontParameters().setAxes(axes, variationSettings->size())));
197 }
181 } 198 }
182 199
183 } // namespace blink 200 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698