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 12 matching lines...) Expand all Loading... |
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | 24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 */ | 28 */ |
29 | 29 |
30 #include "config.h" | 30 #include "config.h" |
31 #include "core/platform/graphics/SimpleFontData.h" | 31 #include "core/platform/graphics/SimpleFontData.h" |
32 | 32 |
| 33 #include "core/css/CSSFontFaceSource.h" |
33 #include "core/platform/graphics/opentype/OpenTypeVerticalData.h" | 34 #include "core/platform/graphics/opentype/OpenTypeVerticalData.h" |
34 | 35 |
35 #include "wtf/MathExtras.h" | 36 #include "wtf/MathExtras.h" |
36 #include "wtf/UnusedParam.h" | 37 #include "wtf/UnusedParam.h" |
37 | 38 |
38 using namespace std; | 39 using namespace std; |
39 | 40 |
40 namespace WebCore { | 41 namespace WebCore { |
41 | 42 |
42 const float smallCapsFontSizeMultiplier = 0.7f; | 43 const float smallCapsFontSizeMultiplier = 0.7f; |
43 const float emphasisMarkFontSizeMultiplier = 0.5f; | 44 const float emphasisMarkFontSizeMultiplier = 0.5f; |
44 | 45 |
45 SimpleFontData::SimpleFontData(const FontPlatformData& platformData, bool isCust
omFont, bool isLoading, bool isTextOrientationFallback) | 46 SimpleFontData::SimpleFontData(const FontPlatformData& platformData, bool isCust
omFont, bool isLoadingFallback, bool isTextOrientationFallback) |
46 : m_maxCharWidth(-1) | 47 : m_maxCharWidth(-1) |
47 , m_avgCharWidth(-1) | 48 , m_avgCharWidth(-1) |
48 , m_platformData(platformData) | 49 , m_platformData(platformData) |
49 , m_treatAsFixedPitch(false) | 50 , m_treatAsFixedPitch(false) |
50 , m_isCustomFont(isCustomFont) | |
51 , m_isLoading(isLoading) | |
52 , m_isTextOrientationFallback(isTextOrientationFallback) | 51 , m_isTextOrientationFallback(isTextOrientationFallback) |
53 , m_isBrokenIdeographFallback(false) | 52 , m_isBrokenIdeographFallback(false) |
54 #if ENABLE(OPENTYPE_VERTICAL) | 53 #if ENABLE(OPENTYPE_VERTICAL) |
55 , m_verticalData(0) | 54 , m_verticalData(0) |
56 #endif | 55 #endif |
57 , m_hasVerticalGlyphs(false) | 56 , m_hasVerticalGlyphs(false) |
| 57 , m_customFontData(isCustomFont, isLoadingFallback) |
58 { | 58 { |
59 platformInit(); | 59 platformInit(); |
60 platformGlyphInit(); | 60 platformGlyphInit(); |
61 platformCharWidthInit(); | 61 platformCharWidthInit(); |
62 #if ENABLE(OPENTYPE_VERTICAL) | 62 #if ENABLE(OPENTYPE_VERTICAL) |
63 if (platformData.orientation() == Vertical && !isTextOrientationFallback) { | 63 if (platformData.orientation() == Vertical && !isTextOrientationFallback) { |
64 m_verticalData = platformData.verticalData(); | 64 m_verticalData = platformData.verticalData(); |
65 m_hasVerticalGlyphs = m_verticalData.get() && m_verticalData->hasVertica
lMetrics(); | 65 m_hasVerticalGlyphs = m_verticalData.get() && m_verticalData->hasVertica
lMetrics(); |
66 } | 66 } |
67 #endif | 67 #endif |
68 } | 68 } |
69 | 69 |
70 SimpleFontData::SimpleFontData(PassOwnPtr<AdditionalFontData> fontData, float fo
ntSize, bool syntheticBold, bool syntheticItalic) | 70 SimpleFontData::SimpleFontData(PassOwnPtr<AdditionalFontData> fontData, float fo
ntSize, bool syntheticBold, bool syntheticItalic) |
71 : m_platformData(FontPlatformData(fontSize, syntheticBold, syntheticItalic)) | 71 : m_platformData(FontPlatformData(fontSize, syntheticBold, syntheticItalic)) |
72 , m_fontData(fontData) | 72 , m_fontData(fontData) |
73 , m_treatAsFixedPitch(false) | 73 , m_treatAsFixedPitch(false) |
74 , m_isCustomFont(true) | |
75 , m_isLoading(false) | |
76 , m_isTextOrientationFallback(false) | 74 , m_isTextOrientationFallback(false) |
77 , m_isBrokenIdeographFallback(false) | 75 , m_isBrokenIdeographFallback(false) |
78 #if ENABLE(OPENTYPE_VERTICAL) | 76 #if ENABLE(OPENTYPE_VERTICAL) |
79 , m_verticalData(0) | 77 , m_verticalData(0) |
80 #endif | 78 #endif |
81 , m_hasVerticalGlyphs(false) | 79 , m_hasVerticalGlyphs(false) |
| 80 , m_customFontData(true, false) |
82 { | 81 { |
83 m_fontData->initializeFontData(this, fontSize); | 82 m_fontData->initializeFontData(this, fontSize); |
84 } | 83 } |
85 | 84 |
86 // Estimates of avgCharWidth and maxCharWidth for platforms that don't support a
ccessing these values from the font. | 85 // Estimates of avgCharWidth and maxCharWidth for platforms that don't support a
ccessing these values from the font. |
87 void SimpleFontData::initCharWidths() | 86 void SimpleFontData::initCharWidths() |
88 { | 87 { |
89 GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->page(); | 88 GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->page(); |
90 | 89 |
91 // Treat the width of a '0' as the avgCharWidth. | 90 // Treat the width of a '0' as the avgCharWidth. |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 { | 218 { |
220 if (!m_derivedFontData) | 219 if (!m_derivedFontData) |
221 m_derivedFontData = DerivedFontData::create(isCustomFont()); | 220 m_derivedFontData = DerivedFontData::create(isCustomFont()); |
222 if (!m_derivedFontData->brokenIdeograph) { | 221 if (!m_derivedFontData->brokenIdeograph) { |
223 m_derivedFontData->brokenIdeograph = create(m_platformData, isCustomFont
(), false); | 222 m_derivedFontData->brokenIdeograph = create(m_platformData, isCustomFont
(), false); |
224 m_derivedFontData->brokenIdeograph->m_isBrokenIdeographFallback = true; | 223 m_derivedFontData->brokenIdeograph->m_isBrokenIdeographFallback = true; |
225 } | 224 } |
226 return m_derivedFontData->brokenIdeograph; | 225 return m_derivedFontData->brokenIdeograph; |
227 } | 226 } |
228 | 227 |
| 228 void SimpleFontData::beginLoadIfNeeded() const |
| 229 { |
| 230 if (!m_customFontData.isUsed && m_customFontData.isLoadingFallback && m_cust
omFontData.fontFaceSource) { |
| 231 m_customFontData.isUsed = true; |
| 232 m_customFontData.fontFaceSource->beginLoadingFontSoon(); |
| 233 } |
| 234 } |
| 235 |
229 #ifndef NDEBUG | 236 #ifndef NDEBUG |
230 String SimpleFontData::description() const | 237 String SimpleFontData::description() const |
231 { | 238 { |
232 if (isSVGFont()) | 239 if (isSVGFont()) |
233 return "[SVG font]"; | 240 return "[SVG font]"; |
234 if (isCustomFont()) | 241 if (isCustomFont()) |
235 return "[custom font]"; | 242 return "[custom font]"; |
236 | 243 |
237 return platformData().description(); | 244 return platformData().description(); |
238 } | 245 } |
(...skipping 24 matching lines...) Expand all Loading... |
263 PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescri
ption& fontDescription, float scaleFactor) const | 270 PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescri
ption& fontDescription, float scaleFactor) const |
264 { | 271 { |
265 // FIXME: Support scaled fonts that used AdditionalFontData. | 272 // FIXME: Support scaled fonts that used AdditionalFontData. |
266 if (m_fontData) | 273 if (m_fontData) |
267 return 0; | 274 return 0; |
268 | 275 |
269 return platformCreateScaledFontData(fontDescription, scaleFactor); | 276 return platformCreateScaledFontData(fontDescription, scaleFactor); |
270 } | 277 } |
271 | 278 |
272 } // namespace WebCore | 279 } // namespace WebCore |
OLD | NEW |