OLD | NEW |
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 22 matching lines...) Expand all Loading... |
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 #include "platform/fonts/opentype/FontSettings.h" | 40 #include "platform/fonts/opentype/FontSettings.h" |
41 #include "third_party/skia/include/core/SkStream.h" | 41 #include "third_party/skia/include/core/SkStream.h" |
42 #include "third_party/skia/include/core/SkTypeface.h" | 42 #include "third_party/skia/include/core/SkTypeface.h" |
| 43 #if OS(WIN) |
| 44 #include "third_party/skia/include/ports/SkFontMgr_empty.h" |
| 45 #endif |
43 #include "wtf/PtrUtil.h" | 46 #include "wtf/PtrUtil.h" |
44 | 47 |
45 namespace blink { | 48 namespace blink { |
46 | 49 |
47 FontCustomPlatformData::FontCustomPlatformData(sk_sp<SkTypeface> typeface, | 50 FontCustomPlatformData::FontCustomPlatformData(sk_sp<SkTypeface> typeface, |
48 size_t dataSize) | 51 size_t dataSize) |
49 : m_baseTypeface(typeface), m_dataSize(dataSize) {} | 52 : m_baseTypeface(std::move(typeface)), m_dataSize(dataSize) {} |
50 | 53 |
51 FontCustomPlatformData::~FontCustomPlatformData() {} | 54 FontCustomPlatformData::~FontCustomPlatformData() {} |
52 | 55 |
53 FontPlatformData FontCustomPlatformData::fontPlatformData( | 56 FontPlatformData FontCustomPlatformData::fontPlatformData( |
54 float size, | 57 float size, |
55 bool bold, | 58 bool bold, |
56 bool italic, | 59 bool italic, |
57 FontOrientation orientation, | 60 FontOrientation orientation, |
58 const FontVariationSettings* variationSettings) { | 61 const FontVariationSettings* variationSettings) { |
59 DCHECK(m_baseTypeface); | 62 DCHECK(m_baseTypeface); |
60 | 63 |
61 sk_sp<SkTypeface> returnTypeface = m_baseTypeface; | 64 sk_sp<SkTypeface> returnTypeface = m_baseTypeface; |
62 | 65 |
63 // Maximum axis count is maximum value for the OpenType USHORT, which is a | 66 // Maximum axis count is maximum value for the OpenType USHORT, which is a |
64 // 16bit unsigned. https://www.microsoft.com/typography/otspec/fvar.htm | 67 // 16bit unsigned. https://www.microsoft.com/typography/otspec/fvar.htm |
65 // Variation settings coming from CSS can have duplicate assignments and the | 68 // Variation settings coming from CSS can have duplicate assignments and the |
66 // list can be longer than UINT16_MAX, but ignoring this for now, going with a | 69 // list can be longer than UINT16_MAX, but ignoring this for now, going with a |
67 // reasonable upper limit and leaving the deduplication for TODO(drott), | 70 // reasonable upper limit and leaving the deduplication for TODO(drott), |
68 // crbug.com/674878 second duplicate value should supersede first.. | 71 // crbug.com/674878 second duplicate value should supersede first.. |
69 if (variationSettings && variationSettings->size() < UINT16_MAX) { | 72 if (variationSettings && variationSettings->size() < UINT16_MAX) { |
| 73 #if OS(WIN) |
| 74 sk_sp<SkFontMgr> fm(SkFontMgr_New_Custom_Empty()); |
| 75 #else |
70 sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault()); | 76 sk_sp<SkFontMgr> fm(SkFontMgr::RefDefault()); |
| 77 #endif |
71 Vector<SkFontMgr::FontParameters::Axis, 0> axes; | 78 Vector<SkFontMgr::FontParameters::Axis, 0> axes; |
72 axes.reserveCapacity(variationSettings->size()); | 79 axes.reserveCapacity(variationSettings->size()); |
73 for (size_t i = 0; i < variationSettings->size(); ++i) { | 80 for (size_t i = 0; i < variationSettings->size(); ++i) { |
74 SkFontMgr::FontParameters::Axis axis = { | 81 SkFontMgr::FontParameters::Axis axis = { |
75 atomicStringToFourByteTag(variationSettings->at(i).tag()), | 82 atomicStringToFourByteTag(variationSettings->at(i).tag()), |
76 SkFloatToScalar(variationSettings->at(i).value())}; | 83 SkFloatToScalar(variationSettings->at(i).value())}; |
77 axes.push_back(axis); | 84 axes.push_back(axis); |
78 } | 85 } |
79 | 86 |
80 sk_sp<SkTypeface> skVariationFont(fm->createFromStream( | 87 sk_sp<SkTypeface> skVariationFont(fm->createFromStream( |
(...skipping 30 matching lines...) Expand all Loading... |
111 new FontCustomPlatformData(std::move(typeface), decoder.decodedSize())); | 118 new FontCustomPlatformData(std::move(typeface), decoder.decodedSize())); |
112 } | 119 } |
113 | 120 |
114 bool FontCustomPlatformData::supportsFormat(const String& format) { | 121 bool FontCustomPlatformData::supportsFormat(const String& format) { |
115 return equalIgnoringCase(format, "truetype") || | 122 return equalIgnoringCase(format, "truetype") || |
116 equalIgnoringCase(format, "opentype") || | 123 equalIgnoringCase(format, "opentype") || |
117 WebFontDecoder::supportsFormat(format); | 124 WebFontDecoder::supportsFormat(format); |
118 } | 125 } |
119 | 126 |
120 } // namespace blink | 127 } // namespace blink |
OLD | NEW |