| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2008, 2010 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2006 Alexey Proskuryakov | 3 * Copyright (C) 2006 Alexey Proskuryakov |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 const float emphasisMarkFontSizeMultiplier = 0.5f; | 40 const float emphasisMarkFontSizeMultiplier = 0.5f; |
| 41 | 41 |
| 42 SimpleFontData::SimpleFontData(const FontPlatformData& platformData, PassRefPtr<
CustomFontData> customData, bool isTextOrientationFallback) | 42 SimpleFontData::SimpleFontData(const FontPlatformData& platformData, PassRefPtr<
CustomFontData> customData, bool isTextOrientationFallback) |
| 43 : m_maxCharWidth(-1) | 43 : m_maxCharWidth(-1) |
| 44 , m_avgCharWidth(-1) | 44 , m_avgCharWidth(-1) |
| 45 , m_platformData(platformData) | 45 , m_platformData(platformData) |
| 46 , m_treatAsFixedPitch(false) | 46 , m_treatAsFixedPitch(false) |
| 47 , m_isTextOrientationFallback(isTextOrientationFallback) | 47 , m_isTextOrientationFallback(isTextOrientationFallback) |
| 48 , m_isBrokenIdeographFallback(false) | 48 , m_isBrokenIdeographFallback(false) |
| 49 #if ENABLE(OPENTYPE_VERTICAL) | 49 #if ENABLE(OPENTYPE_VERTICAL) |
| 50 , m_verticalData(0) | 50 , m_verticalData(nullptr) |
| 51 #endif | 51 #endif |
| 52 , m_hasVerticalGlyphs(false) | 52 , m_hasVerticalGlyphs(false) |
| 53 , m_customFontData(customData) | 53 , m_customFontData(customData) |
| 54 { | 54 { |
| 55 platformInit(); | 55 platformInit(); |
| 56 platformGlyphInit(); | 56 platformGlyphInit(); |
| 57 platformCharWidthInit(); | 57 platformCharWidthInit(); |
| 58 #if ENABLE(OPENTYPE_VERTICAL) | 58 #if ENABLE(OPENTYPE_VERTICAL) |
| 59 if (platformData.orientation() == Vertical && !isTextOrientationFallback) { | 59 if (platformData.orientation() == Vertical && !isTextOrientationFallback) { |
| 60 m_verticalData = platformData.verticalData(); | 60 m_verticalData = platformData.verticalData(); |
| 61 m_hasVerticalGlyphs = m_verticalData.get() && m_verticalData->hasVertica
lMetrics(); | 61 m_hasVerticalGlyphs = m_verticalData.get() && m_verticalData->hasVertica
lMetrics(); |
| 62 } | 62 } |
| 63 #endif | 63 #endif |
| 64 } | 64 } |
| 65 | 65 |
| 66 SimpleFontData::SimpleFontData(PassRefPtr<CustomFontData> customData, float font
Size, bool syntheticBold, bool syntheticItalic) | 66 SimpleFontData::SimpleFontData(PassRefPtr<CustomFontData> customData, float font
Size, bool syntheticBold, bool syntheticItalic) |
| 67 : m_platformData(FontPlatformData(fontSize, syntheticBold, syntheticItalic)) | 67 : m_platformData(FontPlatformData(fontSize, syntheticBold, syntheticItalic)) |
| 68 , m_treatAsFixedPitch(false) | 68 , m_treatAsFixedPitch(false) |
| 69 , m_isTextOrientationFallback(false) | 69 , m_isTextOrientationFallback(false) |
| 70 , m_isBrokenIdeographFallback(false) | 70 , m_isBrokenIdeographFallback(false) |
| 71 #if ENABLE(OPENTYPE_VERTICAL) | 71 #if ENABLE(OPENTYPE_VERTICAL) |
| 72 , m_verticalData(0) | 72 , m_verticalData(nullptr) |
| 73 #endif | 73 #endif |
| 74 , m_hasVerticalGlyphs(false) | 74 , m_hasVerticalGlyphs(false) |
| 75 , m_customFontData(customData) | 75 , m_customFontData(customData) |
| 76 { | 76 { |
| 77 if (m_customFontData) | 77 if (m_customFontData) |
| 78 m_customFontData->initializeFontData(this, fontSize); | 78 m_customFontData->initializeFontData(this, fontSize); |
| 79 } | 79 } |
| 80 | 80 |
| 81 // Estimates of avgCharWidth and maxCharWidth for platforms that don't support a
ccessing these values from the font. | 81 // Estimates of avgCharWidth and maxCharWidth for platforms that don't support a
ccessing these values from the font. |
| 82 void SimpleFontData::initCharWidths() | 82 void SimpleFontData::initCharWidths() |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 return false; | 169 return false; |
| 170 } | 170 } |
| 171 | 171 |
| 172 PassRefPtr<SimpleFontData> SimpleFontData::verticalRightOrientationFontData() co
nst | 172 PassRefPtr<SimpleFontData> SimpleFontData::verticalRightOrientationFontData() co
nst |
| 173 { | 173 { |
| 174 if (!m_derivedFontData) | 174 if (!m_derivedFontData) |
| 175 m_derivedFontData = DerivedFontData::create(isCustomFont()); | 175 m_derivedFontData = DerivedFontData::create(isCustomFont()); |
| 176 if (!m_derivedFontData->verticalRightOrientation) { | 176 if (!m_derivedFontData->verticalRightOrientation) { |
| 177 FontPlatformData verticalRightPlatformData(m_platformData); | 177 FontPlatformData verticalRightPlatformData(m_platformData); |
| 178 verticalRightPlatformData.setOrientation(Horizontal); | 178 verticalRightPlatformData.setOrientation(Horizontal); |
| 179 m_derivedFontData->verticalRightOrientation = create(verticalRightPlatfo
rmData, isCustomFont() ? CustomFontData::create(false): 0, true); | 179 m_derivedFontData->verticalRightOrientation = create(verticalRightPlatfo
rmData, isCustomFont() ? CustomFontData::create(false): nullptr, true); |
| 180 } | 180 } |
| 181 return m_derivedFontData->verticalRightOrientation; | 181 return m_derivedFontData->verticalRightOrientation; |
| 182 } | 182 } |
| 183 | 183 |
| 184 PassRefPtr<SimpleFontData> SimpleFontData::uprightOrientationFontData() const | 184 PassRefPtr<SimpleFontData> SimpleFontData::uprightOrientationFontData() const |
| 185 { | 185 { |
| 186 if (!m_derivedFontData) | 186 if (!m_derivedFontData) |
| 187 m_derivedFontData = DerivedFontData::create(isCustomFont()); | 187 m_derivedFontData = DerivedFontData::create(isCustomFont()); |
| 188 if (!m_derivedFontData->uprightOrientation) | 188 if (!m_derivedFontData->uprightOrientation) |
| 189 m_derivedFontData->uprightOrientation = create(m_platformData, isCustomF
ont() ? CustomFontData::create(false): 0, true); | 189 m_derivedFontData->uprightOrientation = create(m_platformData, isCustomF
ont() ? CustomFontData::create(false): nullptr, true); |
| 190 return m_derivedFontData->uprightOrientation; | 190 return m_derivedFontData->uprightOrientation; |
| 191 } | 191 } |
| 192 | 192 |
| 193 PassRefPtr<SimpleFontData> SimpleFontData::smallCapsFontData(const FontDescripti
on& fontDescription) const | 193 PassRefPtr<SimpleFontData> SimpleFontData::smallCapsFontData(const FontDescripti
on& fontDescription) const |
| 194 { | 194 { |
| 195 if (!m_derivedFontData) | 195 if (!m_derivedFontData) |
| 196 m_derivedFontData = DerivedFontData::create(isCustomFont()); | 196 m_derivedFontData = DerivedFontData::create(isCustomFont()); |
| 197 if (!m_derivedFontData->smallCaps) | 197 if (!m_derivedFontData->smallCaps) |
| 198 m_derivedFontData->smallCaps = createScaledFontData(fontDescription, sma
llCapsFontSizeMultiplier); | 198 m_derivedFontData->smallCaps = createScaledFontData(fontDescription, sma
llCapsFontSizeMultiplier); |
| 199 | 199 |
| 200 return m_derivedFontData->smallCaps; | 200 return m_derivedFontData->smallCaps; |
| 201 } | 201 } |
| 202 | 202 |
| 203 PassRefPtr<SimpleFontData> SimpleFontData::emphasisMarkFontData(const FontDescri
ption& fontDescription) const | 203 PassRefPtr<SimpleFontData> SimpleFontData::emphasisMarkFontData(const FontDescri
ption& fontDescription) const |
| 204 { | 204 { |
| 205 if (!m_derivedFontData) | 205 if (!m_derivedFontData) |
| 206 m_derivedFontData = DerivedFontData::create(isCustomFont()); | 206 m_derivedFontData = DerivedFontData::create(isCustomFont()); |
| 207 if (!m_derivedFontData->emphasisMark) | 207 if (!m_derivedFontData->emphasisMark) |
| 208 m_derivedFontData->emphasisMark = createScaledFontData(fontDescription,
emphasisMarkFontSizeMultiplier); | 208 m_derivedFontData->emphasisMark = createScaledFontData(fontDescription,
emphasisMarkFontSizeMultiplier); |
| 209 | 209 |
| 210 return m_derivedFontData->emphasisMark; | 210 return m_derivedFontData->emphasisMark; |
| 211 } | 211 } |
| 212 | 212 |
| 213 PassRefPtr<SimpleFontData> SimpleFontData::brokenIdeographFontData() const | 213 PassRefPtr<SimpleFontData> SimpleFontData::brokenIdeographFontData() const |
| 214 { | 214 { |
| 215 if (!m_derivedFontData) | 215 if (!m_derivedFontData) |
| 216 m_derivedFontData = DerivedFontData::create(isCustomFont()); | 216 m_derivedFontData = DerivedFontData::create(isCustomFont()); |
| 217 if (!m_derivedFontData->brokenIdeograph) { | 217 if (!m_derivedFontData->brokenIdeograph) { |
| 218 m_derivedFontData->brokenIdeograph = create(m_platformData, isCustomFont
() ? CustomFontData::create(false): 0); | 218 m_derivedFontData->brokenIdeograph = create(m_platformData, isCustomFont
() ? CustomFontData::create(false): nullptr); |
| 219 m_derivedFontData->brokenIdeograph->m_isBrokenIdeographFallback = true; | 219 m_derivedFontData->brokenIdeograph->m_isBrokenIdeographFallback = true; |
| 220 } | 220 } |
| 221 return m_derivedFontData->brokenIdeograph; | 221 return m_derivedFontData->brokenIdeograph; |
| 222 } | 222 } |
| 223 | 223 |
| 224 #ifndef NDEBUG | 224 #ifndef NDEBUG |
| 225 String SimpleFontData::description() const | 225 String SimpleFontData::description() const |
| 226 { | 226 { |
| 227 if (isSVGFont()) | 227 if (isSVGFont()) |
| 228 return "[SVG font]"; | 228 return "[SVG font]"; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 252 if (verticalRightOrientation) | 252 if (verticalRightOrientation) |
| 253 GlyphPageTreeNode::pruneTreeCustomFontData(verticalRightOrientation.get(
)); | 253 GlyphPageTreeNode::pruneTreeCustomFontData(verticalRightOrientation.get(
)); |
| 254 if (uprightOrientation) | 254 if (uprightOrientation) |
| 255 GlyphPageTreeNode::pruneTreeCustomFontData(uprightOrientation.get()); | 255 GlyphPageTreeNode::pruneTreeCustomFontData(uprightOrientation.get()); |
| 256 } | 256 } |
| 257 | 257 |
| 258 PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescri
ption& fontDescription, float scaleFactor) const | 258 PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescri
ption& fontDescription, float scaleFactor) const |
| 259 { | 259 { |
| 260 // FIXME: Support scaled SVG fonts. Given that SVG is scalable in general th
is should be achievable. | 260 // FIXME: Support scaled SVG fonts. Given that SVG is scalable in general th
is should be achievable. |
| 261 if (isSVGFont()) | 261 if (isSVGFont()) |
| 262 return 0; | 262 return nullptr; |
| 263 | 263 |
| 264 return platformCreateScaledFontData(fontDescription, scaleFactor); | 264 return platformCreateScaledFontData(fontDescription, scaleFactor); |
| 265 } | 265 } |
| 266 | 266 |
| 267 } // namespace WebCore | 267 } // namespace WebCore |
| OLD | NEW |