| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 } | 51 } |
| 52 | 52 |
| 53 FontPlatformData FontCustomPlatformData::fontPlatformData(float size, bool bold,
bool italic, FontOrientation orientation) | 53 FontPlatformData FontCustomPlatformData::fontPlatformData(float size, bool bold,
bool italic, FontOrientation orientation) |
| 54 { | 54 { |
| 55 ASSERT(m_typeface); | 55 ASSERT(m_typeface); |
| 56 #if OS(WIN) | 56 #if OS(WIN) |
| 57 if (!FontCache::useDirectWrite()) { | 57 if (!FontCache::useDirectWrite()) { |
| 58 // FIXME: Skia currently renders synthetic bold and italics with | 58 // FIXME: Skia currently renders synthetic bold and italics with |
| 59 // hinting and without linear metrics on the windows GDI backend | 59 // hinting and without linear metrics on the windows GDI backend |
| 60 // while the DirectWrite backend does the right thing. Using | 60 // while the DirectWrite backend does the right thing. Using |
| 61 // CreateFromName and specifying the bold/italics style allows | 61 // legacyCreateTypeface and specifying the bold/italics style allows |
| 62 // for proper rendering of synthetic style. Once Skia has been | 62 // for proper rendering of synthetic style. Once Skia has been |
| 63 // updated this workaround will no longer be needed. | 63 // updated this workaround will no longer be needed. |
| 64 // http://crbug.com/332958 | 64 // http://crbug.com/332958 |
| 65 bool syntheticBold = bold && !m_typeface->isBold(); | 65 bool syntheticBold = bold && !m_typeface->isBold(); |
| 66 bool syntheticItalic = italic && !m_typeface->isItalic(); | 66 bool syntheticItalic = italic && !m_typeface->isItalic(); |
| 67 if (syntheticBold || syntheticItalic) { | 67 if (syntheticBold || syntheticItalic) { |
| 68 SkString name; | 68 SkString name; |
| 69 m_typeface->getFamilyName(&name); | 69 m_typeface->getFamilyName(&name); |
| 70 | 70 |
| 71 int style = SkTypeface::kNormal; | 71 SkFontStyle realStyle = m_typeface->fontStyle(); |
| 72 if (syntheticBold) | 72 SkFontStyle syntheticStyle = SkFontStyle( |
| 73 style |= SkTypeface::kBold; | 73 realStyle.weight() + (syntheticBold ? 200 : 0), |
| 74 if (syntheticItalic) | 74 realStyle.width(), |
| 75 style |= SkTypeface::kItalic; | 75 syntheticItalic ? SkFontStyle::kItalic_Slant : realStyle.slant()
); |
| 76 | 76 RefPtr<SkTypeface> typeface = adoptRef(FontCache::fontCache()->fontM
anager()->legacyCreateTypeface(name.c_str(), syntheticStyle)); |
| 77 RefPtr<SkTypeface> typeface = adoptRef(FontCache::fontCache()->fontM
anager()->legacyCreateTypeface(name.c_str(), static_cast<SkTypeface::Style>(styl
e))); | |
| 78 syntheticBold = false; | 77 syntheticBold = false; |
| 79 syntheticItalic = false; | 78 syntheticItalic = false; |
| 80 return FontPlatformData(typeface.release(), "", size, syntheticBold,
syntheticItalic, orientation); | 79 return FontPlatformData(typeface.release(), "", size, syntheticBold,
syntheticItalic, orientation); |
| 81 } | 80 } |
| 82 } | 81 } |
| 83 #endif | 82 #endif |
| 84 return FontPlatformData(m_typeface.get(), "", size, bold && !m_typeface->isB
old(), italic && !m_typeface->isItalic(), orientation); | 83 return FontPlatformData(m_typeface.get(), "", size, bold && !m_typeface->isB
old(), italic && !m_typeface->isItalic(), orientation); |
| 85 } | 84 } |
| 86 | 85 |
| 87 PassOwnPtr<FontCustomPlatformData> FontCustomPlatformData::create(SharedBuffer*
buffer, String& otsParseMessage) | 86 PassOwnPtr<FontCustomPlatformData> FontCustomPlatformData::create(SharedBuffer*
buffer, String& otsParseMessage) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 108 | 107 |
| 109 return adoptPtr(new FontCustomPlatformData(typeface.release())); | 108 return adoptPtr(new FontCustomPlatformData(typeface.release())); |
| 110 } | 109 } |
| 111 | 110 |
| 112 bool FontCustomPlatformData::supportsFormat(const String& format) | 111 bool FontCustomPlatformData::supportsFormat(const String& format) |
| 113 { | 112 { |
| 114 return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "o
pentype") || OpenTypeSanitizer::supportsFormat(format); | 113 return equalIgnoringCase(format, "truetype") || equalIgnoringCase(format, "o
pentype") || OpenTypeSanitizer::supportsFormat(format); |
| 115 } | 114 } |
| 116 | 115 |
| 117 } // namespace blink | 116 } // namespace blink |
| OLD | NEW |