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 17 matching lines...) Expand all Loading... |
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
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 "config.h" | 33 #include "config.h" |
34 #include "platform/fonts/FontCustomPlatformData.h" | 34 #include "platform/fonts/FontCustomPlatformData.h" |
35 | 35 |
36 #include "platform/LayoutTestSupport.h" | 36 #include "platform/LayoutTestSupport.h" |
37 #include "platform/SharedBuffer.h" | 37 #include "platform/SharedBuffer.h" |
| 38 #include "platform/fonts/FontCache.h" |
38 #include "platform/fonts/FontPlatformData.h" | 39 #include "platform/fonts/FontPlatformData.h" |
39 #include "platform/fonts/opentype/OpenTypeSanitizer.h" | 40 #include "platform/fonts/opentype/OpenTypeSanitizer.h" |
40 #include "third_party/skia/include/core/SkStream.h" | 41 #include "third_party/skia/include/core/SkStream.h" |
41 #include "third_party/skia/include/core/SkTypeface.h" | 42 #include "third_party/skia/include/core/SkTypeface.h" |
42 #include "wtf/PassOwnPtr.h" | 43 #include "wtf/PassOwnPtr.h" |
43 | 44 |
44 namespace WebCore { | 45 namespace WebCore { |
45 | 46 |
46 FontCustomPlatformData::FontCustomPlatformData(PassRefPtr<SkTypeface> typeface) | 47 FontCustomPlatformData::FontCustomPlatformData(PassRefPtr<SkTypeface> typeface) |
47 : m_typeface(typeface) | 48 : m_typeface(typeface) |
(...skipping 14 matching lines...) Expand all Loading... |
62 { | 63 { |
63 ASSERT_ARG(buffer, buffer); | 64 ASSERT_ARG(buffer, buffer); |
64 | 65 |
65 OpenTypeSanitizer sanitizer(buffer); | 66 OpenTypeSanitizer sanitizer(buffer); |
66 RefPtr<SharedBuffer> transcodeBuffer = sanitizer.sanitize(); | 67 RefPtr<SharedBuffer> transcodeBuffer = sanitizer.sanitize(); |
67 if (!transcodeBuffer) | 68 if (!transcodeBuffer) |
68 return nullptr; // validation failed. | 69 return nullptr; // validation failed. |
69 buffer = transcodeBuffer.get(); | 70 buffer = transcodeBuffer.get(); |
70 | 71 |
71 RefPtr<SkMemoryStream> stream = adoptRef(new SkMemoryStream(buffer->getAsSkD
ata().get())); | 72 RefPtr<SkMemoryStream> stream = adoptRef(new SkMemoryStream(buffer->getAsSkD
ata().get())); |
| 73 #if OS(WIN) && !ENABLE(GDI_FONTS_ON_WINDOWS) |
| 74 RefPtr<SkTypeface> typeface = adoptRef(FontCache::fontCache()->fontManager()
->createFromStream(stream.get())); |
| 75 #else |
72 RefPtr<SkTypeface> typeface = adoptRef(SkTypeface::CreateFromStream(stream.g
et())); | 76 RefPtr<SkTypeface> typeface = adoptRef(SkTypeface::CreateFromStream(stream.g
et())); |
| 77 #endif |
73 if (!typeface) | 78 if (!typeface) |
74 return nullptr; | 79 return nullptr; |
75 | 80 |
76 return adoptPtr(new FontCustomPlatformData(typeface.release())); | 81 return adoptPtr(new FontCustomPlatformData(typeface.release())); |
77 } | 82 } |
78 | 83 |
79 bool FontCustomPlatformData::supportsFormat(const String& format) | 84 bool FontCustomPlatformData::supportsFormat(const String& format) |
80 { | 85 { |
81 return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "o
pentype") || OpenTypeSanitizer::supportsFormat(format); | 86 return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "o
pentype") || OpenTypeSanitizer::supportsFormat(format); |
82 } | 87 } |
83 | 88 |
84 } | 89 } |
OLD | NEW |