Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(437)

Side by Side Diff: Source/core/platform/graphics/SimpleFontData.cpp

Issue 23446007: Use unicode-range to prevent unnecessary @font-face donwnloads (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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_isCustomFont(isCustomFont)
51 , m_isLoading(isLoading) 52 , m_isLoadingFallback(isLoadingFallback)
52 , m_isTextOrientationFallback(isTextOrientationFallback) 53 , m_isTextOrientationFallback(isTextOrientationFallback)
53 , m_isBrokenIdeographFallback(false) 54 , m_isBrokenIdeographFallback(false)
54 #if ENABLE(OPENTYPE_VERTICAL) 55 #if ENABLE(OPENTYPE_VERTICAL)
55 , m_verticalData(0) 56 , m_verticalData(0)
56 #endif 57 #endif
57 , m_hasVerticalGlyphs(false) 58 , m_hasVerticalGlyphs(false)
59 , m_isUsed(false)
eseidel 2013/09/10 15:07:26 We should make this name more explicit so that we
Kunihiko Sakamoto 2013/09/11 13:28:09 Now it's m_customFontData.isUsed.
60 , m_fontFaceSource(0)
58 { 61 {
59 platformInit(); 62 platformInit();
60 platformGlyphInit(); 63 platformGlyphInit();
61 platformCharWidthInit(); 64 platformCharWidthInit();
62 #if ENABLE(OPENTYPE_VERTICAL) 65 #if ENABLE(OPENTYPE_VERTICAL)
63 if (platformData.orientation() == Vertical && !isTextOrientationFallback) { 66 if (platformData.orientation() == Vertical && !isTextOrientationFallback) {
64 m_verticalData = platformData.verticalData(); 67 m_verticalData = platformData.verticalData();
65 m_hasVerticalGlyphs = m_verticalData.get() && m_verticalData->hasVertica lMetrics(); 68 m_hasVerticalGlyphs = m_verticalData.get() && m_verticalData->hasVertica lMetrics();
66 } 69 }
67 #endif 70 #endif
68 } 71 }
69 72
70 SimpleFontData::SimpleFontData(PassOwnPtr<AdditionalFontData> fontData, float fo ntSize, bool syntheticBold, bool syntheticItalic) 73 SimpleFontData::SimpleFontData(PassOwnPtr<AdditionalFontData> fontData, float fo ntSize, bool syntheticBold, bool syntheticItalic)
71 : m_platformData(FontPlatformData(fontSize, syntheticBold, syntheticItalic)) 74 : m_platformData(FontPlatformData(fontSize, syntheticBold, syntheticItalic))
72 , m_fontData(fontData) 75 , m_fontData(fontData)
73 , m_treatAsFixedPitch(false) 76 , m_treatAsFixedPitch(false)
74 , m_isCustomFont(true) 77 , m_isCustomFont(true)
75 , m_isLoading(false) 78 , m_isLoadingFallback(false)
76 , m_isTextOrientationFallback(false) 79 , m_isTextOrientationFallback(false)
77 , m_isBrokenIdeographFallback(false) 80 , m_isBrokenIdeographFallback(false)
78 #if ENABLE(OPENTYPE_VERTICAL) 81 #if ENABLE(OPENTYPE_VERTICAL)
79 , m_verticalData(0) 82 , m_verticalData(0)
80 #endif 83 #endif
81 , m_hasVerticalGlyphs(false) 84 , m_hasVerticalGlyphs(false)
85 , m_isUsed(false)
86 , m_fontFaceSource(0)
82 { 87 {
83 m_fontData->initializeFontData(this, fontSize); 88 m_fontData->initializeFontData(this, fontSize);
84 } 89 }
85 90
86 // Estimates of avgCharWidth and maxCharWidth for platforms that don't support a ccessing these values from the font. 91 // Estimates of avgCharWidth and maxCharWidth for platforms that don't support a ccessing these values from the font.
87 void SimpleFontData::initCharWidths() 92 void SimpleFontData::initCharWidths()
88 { 93 {
89 GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->page(); 94 GlyphPage* glyphPageZero = GlyphPageTreeNode::getRootChild(this, 0)->page();
90 95
91 // Treat the width of a '0' as the avgCharWidth. 96 // Treat the width of a '0' as the avgCharWidth.
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 { 224 {
220 if (!m_derivedFontData) 225 if (!m_derivedFontData)
221 m_derivedFontData = DerivedFontData::create(isCustomFont()); 226 m_derivedFontData = DerivedFontData::create(isCustomFont());
222 if (!m_derivedFontData->brokenIdeograph) { 227 if (!m_derivedFontData->brokenIdeograph) {
223 m_derivedFontData->brokenIdeograph = create(m_platformData, isCustomFont (), false); 228 m_derivedFontData->brokenIdeograph = create(m_platformData, isCustomFont (), false);
224 m_derivedFontData->brokenIdeograph->m_isBrokenIdeographFallback = true; 229 m_derivedFontData->brokenIdeograph->m_isBrokenIdeographFallback = true;
225 } 230 }
226 return m_derivedFontData->brokenIdeograph; 231 return m_derivedFontData->brokenIdeograph;
227 } 232 }
228 233
234 void SimpleFontData::beginLoadIfNeeded() const
235 {
236 if (!m_isUsed && m_isLoadingFallback && m_fontFaceSource) {
237 m_isUsed = true;
238 m_fontFaceSource->beginLoadingFontSoon();
239 }
240 }
241
229 #ifndef NDEBUG 242 #ifndef NDEBUG
230 String SimpleFontData::description() const 243 String SimpleFontData::description() const
231 { 244 {
232 if (isSVGFont()) 245 if (isSVGFont())
233 return "[SVG font]"; 246 return "[SVG font]";
234 if (isCustomFont()) 247 if (isCustomFont())
235 return "[custom font]"; 248 return "[custom font]";
236 249
237 return platformData().description(); 250 return platformData().description();
238 } 251 }
(...skipping 24 matching lines...) Expand all
263 PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescri ption& fontDescription, float scaleFactor) const 276 PassRefPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescri ption& fontDescription, float scaleFactor) const
264 { 277 {
265 // FIXME: Support scaled fonts that used AdditionalFontData. 278 // FIXME: Support scaled fonts that used AdditionalFontData.
266 if (m_fontData) 279 if (m_fontData)
267 return 0; 280 return 0;
268 281
269 return platformCreateScaledFontData(fontDescription, scaleFactor); 282 return platformCreateScaledFontData(fontDescription, scaleFactor);
270 } 283 }
271 284
272 } // namespace WebCore 285 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698