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