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 14 matching lines...) Expand all Loading... |
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 "platform/fonts/SimpleFontData.h" | 31 #include "platform/fonts/SimpleFontData.h" |
32 | 32 |
33 #include "wtf/MathExtras.h" | 33 #include "wtf/MathExtras.h" |
34 | 34 |
35 using namespace std; | |
36 | |
37 namespace blink { | 35 namespace blink { |
38 | 36 |
39 const float smallCapsFontSizeMultiplier = 0.7f; | 37 const float smallCapsFontSizeMultiplier = 0.7f; |
40 const float emphasisMarkFontSizeMultiplier = 0.5f; | 38 const float emphasisMarkFontSizeMultiplier = 0.5f; |
41 | 39 |
42 SimpleFontData::SimpleFontData(const FontPlatformData& platformData, PassRefPtr<
CustomFontData> customData, bool isTextOrientationFallback) | 40 SimpleFontData::SimpleFontData(const FontPlatformData& platformData, PassRefPtr<
CustomFontData> customData, bool isTextOrientationFallback) |
43 : m_maxCharWidth(-1) | 41 : m_maxCharWidth(-1) |
44 , m_avgCharWidth(-1) | 42 , m_avgCharWidth(-1) |
45 , m_platformData(platformData) | 43 , m_platformData(platformData) |
46 , m_treatAsFixedPitch(false) | 44 , m_treatAsFixedPitch(false) |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 Glyph digitZeroGlyph = glyphPageZero->glyphForCharacter(digitZeroChar); | 87 Glyph digitZeroGlyph = glyphPageZero->glyphForCharacter(digitZeroChar); |
90 if (digitZeroGlyph) | 88 if (digitZeroGlyph) |
91 m_avgCharWidth = widthForGlyph(digitZeroGlyph); | 89 m_avgCharWidth = widthForGlyph(digitZeroGlyph); |
92 } | 90 } |
93 | 91 |
94 // If we can't retrieve the width of a '0', fall back to the x height. | 92 // If we can't retrieve the width of a '0', fall back to the x height. |
95 if (m_avgCharWidth <= 0.f) | 93 if (m_avgCharWidth <= 0.f) |
96 m_avgCharWidth = m_fontMetrics.xHeight(); | 94 m_avgCharWidth = m_fontMetrics.xHeight(); |
97 | 95 |
98 if (m_maxCharWidth <= 0.f) | 96 if (m_maxCharWidth <= 0.f) |
99 m_maxCharWidth = max(m_avgCharWidth, m_fontMetrics.floatAscent()); | 97 m_maxCharWidth = std::max(m_avgCharWidth, m_fontMetrics.floatAscent()); |
100 } | 98 } |
101 | 99 |
102 void SimpleFontData::platformGlyphInit() | 100 void SimpleFontData::platformGlyphInit() |
103 { | 101 { |
104 GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->page(); | 102 GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->page(); |
105 if (!glyphPageZero) { | 103 if (!glyphPageZero) { |
106 WTF_LOG_ERROR("Failed to get glyph page zero."); | 104 WTF_LOG_ERROR("Failed to get glyph page zero."); |
107 m_spaceGlyph = 0; | 105 m_spaceGlyph = 0; |
108 m_spaceWidth = 0; | 106 m_spaceWidth = 0; |
109 m_zeroGlyph = 0; | 107 m_zeroGlyph = 0; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescri
ption& fontDescription, float scaleFactor) const | 255 PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescri
ption& fontDescription, float scaleFactor) const |
258 { | 256 { |
259 // FIXME: Support scaled SVG fonts. Given that SVG is scalable in general th
is should be achievable. | 257 // FIXME: Support scaled SVG fonts. Given that SVG is scalable in general th
is should be achievable. |
260 if (isSVGFont()) | 258 if (isSVGFont()) |
261 return nullptr; | 259 return nullptr; |
262 | 260 |
263 return platformCreateScaledFontData(fontDescription, scaleFactor); | 261 return platformCreateScaledFontData(fontDescription, scaleFactor); |
264 } | 262 } |
265 | 263 |
266 } // namespace blink | 264 } // namespace blink |
OLD | NEW |