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 23 matching lines...) Expand all Loading... |
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 #include "wtf/PtrUtil.h" | 43 #include "wtf/PtrUtil.h" |
44 #include <memory> | |
45 | 44 |
46 namespace blink { | 45 namespace blink { |
47 | 46 |
48 FontCustomPlatformData::FontCustomPlatformData(sk_sp<SkTypeface> typeface, | 47 FontCustomPlatformData::FontCustomPlatformData(sk_sp<SkTypeface> typeface, |
49 size_t dataSize) | 48 size_t dataSize) |
50 : m_baseTypeface(typeface), m_dataSize(dataSize) {} | 49 : m_baseTypeface(typeface), m_dataSize(dataSize) {} |
51 | 50 |
52 FontCustomPlatformData::~FontCustomPlatformData() {} | 51 FontCustomPlatformData::~FontCustomPlatformData() {} |
53 | 52 |
54 FontPlatformData FontCustomPlatformData::fontPlatformData( | 53 FontPlatformData FontCustomPlatformData::fontPlatformData( |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 LOG(ERROR) << "Unable for apply variation axis properties for font: " | 90 LOG(ERROR) << "Unable for apply variation axis properties for font: " |
92 << familyName.c_str(); | 91 << familyName.c_str(); |
93 } | 92 } |
94 } | 93 } |
95 | 94 |
96 return FontPlatformData(returnTypeface, "", size, | 95 return FontPlatformData(returnTypeface, "", size, |
97 bold && !m_baseTypeface->isBold(), | 96 bold && !m_baseTypeface->isBold(), |
98 italic && !m_baseTypeface->isItalic(), orientation); | 97 italic && !m_baseTypeface->isItalic(), orientation); |
99 } | 98 } |
100 | 99 |
101 std::unique_ptr<FontCustomPlatformData> FontCustomPlatformData::create( | 100 PassRefPtr<FontCustomPlatformData> FontCustomPlatformData::create( |
102 SharedBuffer* buffer, | 101 SharedBuffer* buffer, |
103 String& otsParseMessage) { | 102 String& otsParseMessage) { |
104 DCHECK(buffer); | 103 DCHECK(buffer); |
105 WebFontDecoder decoder; | 104 WebFontDecoder decoder; |
106 sk_sp<SkTypeface> typeface = decoder.decode(buffer); | 105 sk_sp<SkTypeface> typeface = decoder.decode(buffer); |
107 if (!typeface) { | 106 if (!typeface) { |
108 otsParseMessage = decoder.getErrorString(); | 107 otsParseMessage = decoder.getErrorString(); |
109 return nullptr; | 108 return nullptr; |
110 } | 109 } |
111 return WTF::wrapUnique( | 110 return adoptRef( |
112 new FontCustomPlatformData(std::move(typeface), decoder.decodedSize())); | 111 new FontCustomPlatformData(std::move(typeface), decoder.decodedSize())); |
113 } | 112 } |
114 | 113 |
115 bool FontCustomPlatformData::supportsFormat(const String& format) { | 114 bool FontCustomPlatformData::supportsFormat(const String& format) { |
116 return equalIgnoringCase(format, "truetype") || | 115 return equalIgnoringCase(format, "truetype") || |
117 equalIgnoringCase(format, "opentype") || | 116 equalIgnoringCase(format, "opentype") || |
118 WebFontDecoder::supportsFormat(format); | 117 WebFontDecoder::supportsFormat(format); |
119 } | 118 } |
120 | 119 |
121 } // namespace blink | 120 } // namespace blink |
OLD | NEW |