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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/FontCustomPlatformData.cpp

Issue 2858573002: Use FreeType for OpenType Variations on CoreText < 10.12 (Closed)
Patch Set: Use FreeType for OpenType Variations on CoreText < 10.12 Created 3 years, 7 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 * Copyright (C) 2007 Apple Computer, Inc. 2 * Copyright (C) 2007 Apple Computer, Inc.
3 * Copyright (c) 2007, 2008, 2009, Google Inc. All rights reserved. 3 * Copyright (c) 2007, 2008, 2009, Google Inc. All rights reserved.
4 * Copyright (C) 2010 Company 100, Inc. 4 * Copyright (C) 2010 Company 100, Inc.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are 7 * modification, are permitted provided that the following conditions are
8 * met: 8 * met:
9 * 9 *
10 * * Redistributions of source code must retain the above copyright 10 * * Redistributions of source code must retain the above copyright
(...skipping 19 matching lines...) Expand all
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */ 31 */
32 32
33 #include "platform/fonts/FontCustomPlatformData.h" 33 #include "platform/fonts/FontCustomPlatformData.h"
34 34
35 #include "platform/LayoutTestSupport.h" 35 #include "platform/LayoutTestSupport.h"
36 #include "platform/SharedBuffer.h" 36 #include "platform/SharedBuffer.h"
37 #include "platform/fonts/FontCache.h" 37 #include "platform/fonts/FontCache.h"
38 #include "platform/fonts/FontPlatformData.h" 38 #include "platform/fonts/FontPlatformData.h"
39 #include "platform/fonts/WebFontDecoder.h" 39 #include "platform/fonts/WebFontDecoder.h"
40 #if OS(MACOSX)
41 #include "platform/fonts/mac/CoreTextVariationsSupport.h"
42 #endif
40 #include "platform/fonts/opentype/FontSettings.h" 43 #include "platform/fonts/opentype/FontSettings.h"
41 #include "third_party/skia/include/core/SkStream.h" 44 #include "third_party/skia/include/core/SkStream.h"
42 #include "third_party/skia/include/core/SkTypeface.h" 45 #include "third_party/skia/include/core/SkTypeface.h"
43 #if OS(WIN) 46 #if OS(WIN) || OS(MACOSX)
44 #include "third_party/skia/include/ports/SkFontMgr_empty.h" 47 #include "third_party/skia/include/ports/SkFontMgr_empty.h"
45 #endif 48 #endif
46 #include "platform/wtf/PtrUtil.h" 49 #include "platform/wtf/PtrUtil.h"
47 50
48 namespace blink { 51 namespace blink {
49 52
50 FontCustomPlatformData::FontCustomPlatformData(sk_sp<SkTypeface> typeface, 53 FontCustomPlatformData::FontCustomPlatformData(sk_sp<SkTypeface> typeface,
51 size_t data_size) 54 size_t data_size)
52 : base_typeface_(std::move(typeface)), data_size_(data_size) {} 55 : base_typeface_(std::move(typeface)), data_size_(data_size) {}
53 56
(...skipping 13 matching lines...) Expand all
67 // which is a 16bit unsigned. 70 // which is a 16bit unsigned.
68 // https://www.microsoft.com/typography/otspec/fvar.htm Variation 71 // https://www.microsoft.com/typography/otspec/fvar.htm Variation
69 // settings coming from CSS can have duplicate assignments and the 72 // settings coming from CSS can have duplicate assignments and the
70 // list can be longer than UINT16_MAX, but ignoring the length for 73 // list can be longer than UINT16_MAX, but ignoring the length for
71 // now, going with a reasonable upper limit. Deduplication is 74 // now, going with a reasonable upper limit. Deduplication is
72 // handled by Skia with priority given to the last occuring 75 // handled by Skia with priority given to the last occuring
73 // assignment. 76 // assignment.
74 if (variation_settings && variation_settings->size() < UINT16_MAX) { 77 if (variation_settings && variation_settings->size() < UINT16_MAX) {
75 #if OS(WIN) 78 #if OS(WIN)
76 sk_sp<SkFontMgr> fm(SkFontMgr_New_Custom_Empty()); 79 sk_sp<SkFontMgr> fm(SkFontMgr_New_Custom_Empty());
80 #elif OS(MACOSX)
81 sk_sp<SkFontMgr> fm;
82 if (CoreTextVersionSupportsVariations())
83 fm = SkFontMgr::RefDefault();
84 else
85 fm = SkFontMgr_New_Custom_Empty();
77 #else 86 #else
78 sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault()); 87 sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault());
79 #endif 88 #endif
80 Vector<SkFontMgr::FontParameters::Axis, 0> axes; 89 Vector<SkFontMgr::FontParameters::Axis, 0> axes;
81 axes.ReserveCapacity(variation_settings->size()); 90 axes.ReserveCapacity(variation_settings->size());
82 for (size_t i = 0; i < variation_settings->size(); ++i) { 91 for (size_t i = 0; i < variation_settings->size(); ++i) {
83 SkFontMgr::FontParameters::Axis axis = { 92 SkFontMgr::FontParameters::Axis axis = {
84 AtomicStringToFourByteTag(variation_settings->at(i).Tag()), 93 AtomicStringToFourByteTag(variation_settings->at(i).Tag()),
85 SkFloatToScalar(variation_settings->at(i).Value())}; 94 SkFloatToScalar(variation_settings->at(i).Value())};
86 axes.push_back(axis); 95 axes.push_back(axis);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 new FontCustomPlatformData(std::move(typeface), decoder.DecodedSize())); 129 new FontCustomPlatformData(std::move(typeface), decoder.DecodedSize()));
121 } 130 }
122 131
123 bool FontCustomPlatformData::SupportsFormat(const String& format) { 132 bool FontCustomPlatformData::SupportsFormat(const String& format) {
124 return DeprecatedEqualIgnoringCase(format, "truetype") || 133 return DeprecatedEqualIgnoringCase(format, "truetype") ||
125 DeprecatedEqualIgnoringCase(format, "opentype") || 134 DeprecatedEqualIgnoringCase(format, "opentype") ||
126 WebFontDecoder::SupportsFormat(format); 135 WebFontDecoder::SupportsFormat(format);
127 } 136 }
128 137
129 } // namespace blink 138 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/BUILD.gn ('k') | third_party/WebKit/Source/platform/fonts/FontPlatformData.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698