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 21 matching lines...) Expand all Loading... |
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 #include "third_party/skia/include/core/SkStream.h" | 40 #include "third_party/skia/include/core/SkStream.h" |
41 #include "third_party/skia/include/core/SkTypeface.h" | 41 #include "third_party/skia/include/core/SkTypeface.h" |
42 #include "wtf/PassOwnPtr.h" | 42 #include "wtf/PtrUtil.h" |
| 43 #include <memory> |
43 | 44 |
44 namespace blink { | 45 namespace blink { |
45 | 46 |
46 FontCustomPlatformData::FontCustomPlatformData(PassRefPtr<SkTypeface> typeface) | 47 FontCustomPlatformData::FontCustomPlatformData(PassRefPtr<SkTypeface> typeface) |
47 : m_typeface(typeface) { } | 48 : m_typeface(typeface) { } |
48 | 49 |
49 FontCustomPlatformData::~FontCustomPlatformData() | 50 FontCustomPlatformData::~FontCustomPlatformData() |
50 { | 51 { |
51 } | 52 } |
52 | 53 |
53 FontPlatformData FontCustomPlatformData::fontPlatformData(float size, bool bold,
bool italic, FontOrientation orientation) | 54 FontPlatformData FontCustomPlatformData::fontPlatformData(float size, bool bold,
bool italic, FontOrientation orientation) |
54 { | 55 { |
55 ASSERT(m_typeface); | 56 ASSERT(m_typeface); |
56 return FontPlatformData(m_typeface.get(), "", size, bold && !m_typeface->isB
old(), italic && !m_typeface->isItalic(), orientation); | 57 return FontPlatformData(m_typeface.get(), "", size, bold && !m_typeface->isB
old(), italic && !m_typeface->isItalic(), orientation); |
57 } | 58 } |
58 | 59 |
59 PassOwnPtr<FontCustomPlatformData> FontCustomPlatformData::create(SharedBuffer*
buffer, String& otsParseMessage) | 60 std::unique_ptr<FontCustomPlatformData> FontCustomPlatformData::create(SharedBuf
fer* buffer, String& otsParseMessage) |
60 { | 61 { |
61 DCHECK(buffer); | 62 DCHECK(buffer); |
62 WebFontDecoder decoder; | 63 WebFontDecoder decoder; |
63 RefPtr<SkTypeface> typeface = decoder.decode(buffer); | 64 RefPtr<SkTypeface> typeface = decoder.decode(buffer); |
64 if (!typeface) { | 65 if (!typeface) { |
65 otsParseMessage = decoder.getErrorString(); | 66 otsParseMessage = decoder.getErrorString(); |
66 return nullptr; | 67 return nullptr; |
67 } | 68 } |
68 return adoptPtr(new FontCustomPlatformData(typeface.release())); | 69 return wrapUnique(new FontCustomPlatformData(typeface.release())); |
69 } | 70 } |
70 | 71 |
71 bool FontCustomPlatformData::supportsFormat(const String& format) | 72 bool FontCustomPlatformData::supportsFormat(const String& format) |
72 { | 73 { |
73 return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "o
pentype") || WebFontDecoder::supportsFormat(format); | 74 return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "o
pentype") || WebFontDecoder::supportsFormat(format); |
74 } | 75 } |
75 | 76 |
76 } // namespace blink | 77 } // namespace blink |
OLD | NEW |