Changeset 90041 in webkit
- Timestamp:
- Jun 29, 2011 2:03:13 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r90039 r90041 1 2011-06-29 Martin Robinson <mrobinson@igalia.com> 2 3 Reviewed by Xan Lopez. 4 5 [Freetype] Many tests report ERROR: Failed to get glyph page zero. 6 https://bugs.webkit.org/show_bug.cgi?id=63498 7 8 Instead of conditionally instantiating the m_scaledFont member of FontPlatformData, 9 always instantiate it. For times when the size is 0 and the instantiation would lead 10 to a Cairo error, we use size 1 and just make operations which would fail conditional 11 on the m_size > 0. 12 13 No new tests. This change is covered by existing tests. We should 14 observe no errors on the bots after landing. 15 16 * platform/graphics/cairo/FontCairo.cpp: 17 (WebCore::Font::drawGlyphs): Instead of looking at whether or not there is 18 a scaled font to determine whether to draw, just look at the size. 19 * platform/graphics/freetype/FontPlatformData.h: Remove the m_font member. 20 * platform/graphics/freetype/FontPlatformDataFreeType.cpp: Always instantiate 21 a scaled font member and remove references to m_font. If we are instantiating 22 a scaled font for a 0 size font, instantiate a size 1 font, so that we can 23 still use Cairo to query font properties. 24 * platform/graphics/freetype/GlyphPageTreeNodeFreeType.cpp: 25 (WebCore::GlyphPage::fill): We can assume there is always a scaled font now. 26 * platform/graphics/freetype/SimpleFontDataFreeType.cpp: 27 (WebCore::SimpleFontData::platformInit): Ditto. 28 (WebCore::SimpleFontData::createScaledFontData): Ditto. 29 (WebCore::SimpleFontData::containsCharacters): Ditto. 30 (WebCore::SimpleFontData::platformWidthForGlyph): Ditto. 31 1 32 2011-06-29 Eric Carlson <eric.carlson@apple.com> 2 33 -
trunk/Source/WebCore/platform/graphics/cairo/FontCairo.cpp
r89314 r90041 107 107 int from, int numGlyphs, const FloatPoint& point) const 108 108 { 109 if (!font->platformData().s caledFont())109 if (!font->platformData().size()) 110 110 return; 111 111 -
trunk/Source/WebCore/platform/graphics/freetype/FontPlatformData.h
r87523 r90041 98 98 bool m_syntheticOblique; 99 99 bool m_fixedWidth; 100 RefPtr<cairo_font_face_t> m_font;101 100 cairo_scaled_font_t* m_scaledFont; 102 101 -
trunk/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp
r89248 r90041 122 122 , m_scaledFont(0) 123 123 { 124 m_font= adoptRef(cairo_ft_font_face_create_for_pattern(m_pattern.get()));125 initializeWithFontFace( m_font.get());124 RefPtr<cairo_font_face_t> fontFace = adoptRef(cairo_ft_font_face_create_for_pattern(m_pattern.get())); 125 initializeWithFontFace(fontFace.get()); 126 126 127 127 int spacing; … … 154 154 , m_syntheticOblique(italic) 155 155 , m_fixedWidth(false) 156 , m_font(fontFace)157 156 , m_scaledFont(0) 158 157 { 159 158 initializeWithFontFace(fontFace); 160 159 161 if (m_scaledFont) { 162 FT_Face fontConfigFace = cairo_ft_scaled_font_lock_face(m_scaledFont); 163 if (fontConfigFace) { 164 m_fixedWidth = fontConfigFace->face_flags & FT_FACE_FLAG_FIXED_WIDTH; 165 cairo_ft_scaled_font_unlock_face(m_scaledFont); 166 } 160 FT_Face fontConfigFace = cairo_ft_scaled_font_lock_face(m_scaledFont); 161 if (fontConfigFace) { 162 m_fixedWidth = fontConfigFace->face_flags & FT_FACE_FLAG_FIXED_WIDTH; 163 cairo_ft_scaled_font_unlock_face(m_scaledFont); 167 164 } 168 165 } … … 189 186 cairo_scaled_font_destroy(m_scaledFont); 190 187 m_scaledFont = cairo_scaled_font_reference(other.m_scaledFont); 191 m_font = other.m_font;192 188 193 189 return *this; … … 231 227 return m_pattern == other.m_pattern 232 228 && m_scaledFont == other.m_scaledFont 233 && m_font == other.m_font234 229 && m_size == other.m_size 235 230 && m_syntheticOblique == other.m_syntheticOblique … … 246 241 void FontPlatformData::initializeWithFontFace(cairo_font_face_t* fontFace) 247 242 { 248 // Fonts with zero size lead to failed cairo_scaled_font_t instantiations. Instead249 // we just do not instantiate the scaled font at all. This will cause all renders250 // to be no-ops and all metrics to be zero, which is the desired behavior anyway.251 if (!m_size)252 return;253 254 243 cairo_font_options_t* options = getDefaultFontOptions(); 255 244 … … 257 246 cairo_matrix_init_identity(&ctm); 258 247 248 // Scaling a font with width zero size leads to a failed cairo_scaled_font_t instantiations. 249 // Instead we scale we scale the font to a very tiny size and just abort rendering later on. 250 float realSize = m_size ? m_size : 1; 251 259 252 cairo_matrix_t fontMatrix; 260 253 if (!m_pattern) 261 cairo_matrix_init_scale(&fontMatrix, m_size, m_size);254 cairo_matrix_init_scale(&fontMatrix, realSize, realSize); 262 255 else { 263 256 setCairoFontOptionsFromFontConfigPattern(options, m_pattern.get()); … … 274 267 -fontConfigMatrix.xy, fontConfigMatrix.yy, 0, 0); 275 268 276 // The matrix from FontConfig does not include the scale. 277 cairo_matrix_scale(&fontMatrix, m_size, m_size);269 // The matrix from FontConfig does not include the scale. 270 cairo_matrix_scale(&fontMatrix, realSize, realSize); 278 271 } 279 272 … … 284 277 bool FontPlatformData::hasCompatibleCharmap() 285 278 { 286 // If m_scaledFont is null, it means that this is a size zero font, which always 287 // has a compatible charmap since we never really read any font data from the font. 288 if (!m_scaledFont) 289 return true; 290 279 ASSERT(m_scaledFont); 291 280 FT_Face freeTypeFace = cairo_ft_scaled_font_lock_face(m_scaledFont); 292 281 bool hasCompatibleCharmap = !(FT_Select_Charmap(freeTypeFace, ft_encoding_unicode) -
trunk/Source/WebCore/platform/graphics/freetype/GlyphPageTreeNodeFreeType.cpp
r87523 r90041 47 47 48 48 cairo_scaled_font_t* scaledFont = fontData->platformData().scaledFont(); 49 if (!scaledFont) 50 return false; 49 ASSERT(scaledFont); 51 50 52 51 FT_Face face = cairo_ft_scaled_font_lock_face(scaledFont); -
trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp
r87523 r90041 48 48 void SimpleFontData::platformInit() 49 49 { 50 if (!m_platformData. scaledFont())50 if (!m_platformData.m_size) 51 51 return; 52 52 53 ASSERT(m_platformData.scaledFont()); 53 54 cairo_font_extents_t font_extents; 54 55 cairo_text_extents_t text_extents; … … 92 93 PassOwnPtr<SimpleFontData> SimpleFontData::createScaledFontData(const FontDescription& fontDescription, float scaleFactor) const 93 94 { 94 return adoptPtr(new SimpleFontData(FontPlatformData(m_platformData.m_font.get(), 95 ASSERT(m_platformData.scaledFont()); 96 return adoptPtr(new SimpleFontData(FontPlatformData(cairo_scaled_font_get_font_face(m_platformData.scaledFont()), 95 97 scaleFactor * fontDescription.computedSize(), 96 98 m_platformData.syntheticBold(), … … 122 124 bool SimpleFontData::containsCharacters(const UChar* characters, int length) const 123 125 { 124 // If this is a no-op font (zero size), then it should always contain the characters, 125 // since we never read from or render from this font. 126 if (!m_platformData.scaledFont()) 127 return true; 128 126 ASSERT(m_platformData.scaledFont()); 129 127 FT_Face face = cairo_ft_scaled_font_lock_face(m_platformData.scaledFont()); 130 128 if (!face) … … 154 152 float SimpleFontData::platformWidthForGlyph(Glyph glyph) const 155 153 { 156 if (!m_platformData.s caledFont())154 if (!m_platformData.size()) 157 155 return 0; 158 156
Note: See TracChangeset
for help on using the changeset viewer.