Changeset 28921 in webkit
- Timestamp:
- Dec 20, 2007 4:33:46 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r28865 r28921 1 2007-12-20 Alp Toker <alp@atoker.com> 2 3 Rubber-stamped by Maciej. 4 5 http://bugs.webkit.org/show_bug.cgi?id=16542 6 [GTK] Text is missing with old Pango version 7 8 Back out commits r28880, r28876, r28865, r28864 which added Pango font 9 selection support. These changes caused a regression where no text was 10 displayed with older Pango versions. 11 12 * WebKit.pri: 13 1 14 2007-12-19 Alp Toker <alp@atoker.com> 2 15 -
trunk/WebCore/ChangeLog
r28918 r28921 1 2007-12-20 Alp Toker <alp@atoker.com> 2 3 Rubber-stamped by Maciej. 4 5 http://bugs.webkit.org/show_bug.cgi?id=16542 6 [GTK] Text is missing with old Pango version 7 8 Back out commits r28880, r28876, r28865, r28864 which added Pango font 9 selection support. These changes caused a regression where no text was 10 displayed with older Pango versions. 11 12 * platform/graphics/gtk/FontCacheGtk.cpp: 13 (WebCore::FontCache::fontExists): 14 * platform/graphics/gtk/FontDataGtk.cpp: 15 (WebCore::FontData::platformDestroy): 16 (WebCore::FontData::containsCharacters): 17 * platform/graphics/gtk/FontPlatformData.h: 18 (WebCore::FontPlatformData::FontPlatformData): 19 (WebCore::FontPlatformData::hash): 20 * platform/graphics/gtk/FontPlatformDataGtk.cpp: 21 (WebCore::FontPlatformData::FontPlatformData): 22 (WebCore::FontPlatformData::init): 23 (WebCore::FontPlatformData::~FontPlatformData): 24 (WebCore::FontPlatformData::isFixedPitch): 25 (WebCore::FontPlatformData::operator==): 26 * platform/graphics/gtk/GlyphPageTreeNodeGtk.cpp: 27 (WebCore::GlyphPage::fill): 28 1 29 2007-12-20 Timothy Hatcher <timothy@apple.com> 2 30 -
trunk/WebCore/platform/graphics/gtk/FontCacheGtk.cpp
r28864 r28921 65 65 { 66 66 FontPlatformData platformData(fontDescription, family); 67 return platformData.m_ font!= 0;67 return platformData.m_pattern != 0; 68 68 } 69 69 -
trunk/WebCore/platform/graphics/gtk/FontDataGtk.cpp
r28864 r28921 4 4 * Copyright (C) 2007 Alp Toker <alp.toker@collabora.co.uk> 5 5 * Copyright (C) 2007 Holger Hans Peter Freyther 6 * Copyright (C) 2007 Pioneer Research Center USA, Inc.7 6 * All rights reserved. 8 7 * … … 64 63 void FontData::platformDestroy() 65 64 { 66 if (m_font.m_font && m_font.m_font != reinterpret_cast<PangoFont*>(-1)) 67 g_object_unref(m_font.m_font); 68 if (m_font.m_context) 69 g_object_unref(m_font.m_context); 65 if (m_font.m_pattern && ((FcPattern*)-1 != m_font.m_pattern)) 66 FcPatternDestroy(m_font.m_pattern); 70 67 71 68 if (m_font.m_scaledFont) … … 87 84 bool FontData::containsCharacters(const UChar* characters, int length) const 88 85 { 89 bool result = true;86 FT_Face face = cairo_ft_scaled_font_lock_face(m_font.m_scaledFont); 90 87 91 PangoCoverage* requested = pango_coverage_from_bytes((guchar*)characters, length); 92 PangoCoverage* available = pango_font_get_coverage(m_font.m_font, pango_language_get_default()); 93 pango_coverage_max(requested, available); 88 if (!face) 89 return false; 94 90 95 91 for (unsigned i = 0; i < length; i++) { 96 if ( PANGO_COVERAGE_NONE == pango_coverage_get(requested, i)) {97 result = false;98 break;92 if (FcFreeTypeCharIndex(face, characters[i]) == 0) { 93 cairo_ft_scaled_font_unlock_face(m_font.m_scaledFont); 94 return false; 99 95 } 100 96 } 101 97 102 pango_coverage_unref(available); 103 pango_coverage_unref(requested); 98 cairo_ft_scaled_font_unlock_face(m_font.m_scaledFont); 104 99 105 return result;100 return true; 106 101 } 107 102 -
trunk/WebCore/platform/graphics/gtk/FontPlatformData.h
r28864 r28921 6 6 * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com 7 7 * Copyright (C) 2007 Holger Hans Peter Freyther 8 * Copyright (C) 2007 Pioneer Research Center USA, Inc.9 8 * All rights reserved. 10 9 * … … 32 31 #include "FontDescription.h" 33 32 #include <cairo.h> 34 #include <pango/pangocairo.h> 33 #include <cairo-ft.h> 34 #include <fontconfig/fcfreetype.h> 35 35 36 36 namespace WebCore { … … 40 40 class Deleted {}; 41 41 FontPlatformData(Deleted) 42 : m_context(0) 43 , m_font(reinterpret_cast<PangoFont*>(-1)) 42 : m_pattern(reinterpret_cast<FcPattern*>(-1)) 44 43 , m_scaledFont(0) 45 44 { } 46 45 47 46 FontPlatformData() 48 : m_context(0) 49 , m_font(0) 47 : m_pattern(0) 50 48 , m_scaledFont(0) 51 49 { } … … 62 60 unsigned hash() const 63 61 { 64 uintptr_t hashCodes[1] = { reinterpret_cast<uintptr_t>(m_scaledFont)};65 return StringImpl::computeHash( reinterpret_cast<UChar*>(hashCodes), sizeof(hashCodes) / sizeof(UChar));62 uintptr_t hashCodes[1] = { reinterpret_cast<uintptr_t>(m_scaledFont) }; 63 return StringImpl::computeHash( reinterpret_cast<UChar*>(hashCodes), sizeof(hashCodes) / sizeof(UChar)); 66 64 } 67 65 68 66 bool operator==(const FontPlatformData&) const; 69 67 70 static PangoFontMap* m_fontMap; 71 static GHashTable * m_hashTable; 72 73 PangoContext* m_context; 74 PangoFont* m_font; 68 FcPattern* m_pattern; 75 69 FontDescription m_fontDescription; 76 70 cairo_scaled_font_t* m_scaledFont; -
trunk/WebCore/platform/graphics/gtk/FontPlatformDataGtk.cpp
r28880 r28921 7 7 * Copyright (C) 2007 Alp Toker <alp@atoker.com> 8 8 * Copyright (C) 2007 Holger Hans Peter Freyther 9 * Copyright (C) 2007 Pioneer Research Center USA, Inc.10 9 * All rights reserved. 11 10 * … … 27 26 */ 28 27 29 // Use the Pango backend API for compatibility with older Pango versions.30 #define PANGO_ENABLE_BACKEND31 32 28 #include "config.h" 33 29 #include "FontPlatformData.h" … … 36 32 #include "PlatformString.h" 37 33 #include "FontDescription.h" 34 35 #include <cairo-ft.h> 38 36 #include <cairo.h> 39 #include <assert.h> 40 41 #include <pango/pango.h> 42 #include <pango/pangocairo.h> 43 44 // Use cairo-ft if a recent enough Pango version isn't available. 45 #if !PANGO_VERSION_CHECK(1,18,0) 46 #include <cairo-ft.h> 47 #include <pango/pangofc-fontmap.h> 48 #endif 37 #include <fontconfig/fcfreetype.h> 49 38 50 39 namespace WebCore { 51 40 52 PangoFontMap* FontPlatformData::m_fontMap = 0;53 GHashTable* FontPlatformData::m_hashTable = 0;54 55 41 FontPlatformData::FontPlatformData(const FontDescription& fontDescription, const AtomicString& familyName) 56 : m_context(0) 57 , m_font(0) 42 : m_pattern(0) 58 43 , m_fontDescription(fontDescription) 59 44 , m_scaledFont(0) … … 61 46 FontPlatformData::init(); 62 47 63 CString stored_family = familyName.domString().utf8(); 64 gchar const* families[] = { 65 stored_family.data(), 66 NULL 67 }; 48 CString familyNameString = familyName.domString().utf8(); 49 const char* fcfamily = familyNameString.data(); 50 int fcslant = FC_SLANT_ROMAN; 51 int fcweight = FC_WEIGHT_NORMAL; 52 float fcsize = fontDescription.computedSize(); 53 if (fontDescription.italic()) 54 fcslant = FC_SLANT_ITALIC; 55 if (fontDescription.bold()) 56 fcweight = FC_WEIGHT_BOLD; 68 57 69 switch (fontDescription.genericFamily()) { 70 case FontDescription::SerifFamily: 71 families[1] = "serif"; 72 break; 73 case FontDescription::SansSerifFamily: 74 families[1] = "sans"; 75 break; 76 case FontDescription::MonospaceFamily: 77 families[1] = "monospace"; 78 break; 79 case FontDescription::NoFamily: 80 case FontDescription::StandardFamily: 81 default: 82 families[1] = "sans"; 83 break; 58 int type = fontDescription.genericFamily(); 59 60 FcPattern* pattern = FcPatternCreate(); 61 cairo_font_face_t* fontFace; 62 cairo_font_options_t* options; 63 cairo_matrix_t fontMatrix; 64 65 if (!FcPatternAddString(pattern, FC_FAMILY, reinterpret_cast<const FcChar8*>(fcfamily))) 66 goto freePattern; 67 68 switch (type) { 69 case FontDescription::SerifFamily: 70 fcfamily = "serif"; 71 break; 72 case FontDescription::SansSerifFamily: 73 fcfamily = "sans-serif"; 74 break; 75 case FontDescription::MonospaceFamily: 76 fcfamily = "monospace"; 77 break; 78 case FontDescription::NoFamily: 79 case FontDescription::StandardFamily: 80 default: 81 fcfamily = "sans-serif"; 84 82 } 85 83 86 PangoFontDescription* description = pango_font_description_new(); 87 pango_font_description_set_absolute_size(description, fontDescription.computedSize() * PANGO_SCALE); 84 if (!FcPatternAddString(pattern, FC_FAMILY, reinterpret_cast<const FcChar8*>(fcfamily))) 85 goto freePattern; 86 if (!FcPatternAddInteger(pattern, FC_SLANT, fcslant)) 87 goto freePattern; 88 if (!FcPatternAddInteger(pattern, FC_WEIGHT, fcweight)) 89 goto freePattern; 90 if (!FcPatternAddDouble(pattern, FC_PIXEL_SIZE, fcsize)) 91 goto freePattern; 88 92 89 if (fontDescription.bold()) 90 pango_font_description_set_weight(description, PANGO_WEIGHT_BOLD); 91 if (fontDescription.italic()) 92 pango_font_description_set_style(description, PANGO_STYLE_ITALIC); 93 FcConfigSubstitute(NULL, pattern, FcMatchPattern); 94 FcDefaultSubstitute(pattern); 93 95 94 m_context = pango_cairo_font_map_create_context(PANGO_CAIRO_FONT_MAP(m_fontMap)); 96 FcResult fcresult; 97 m_pattern = FcFontMatch(NULL, pattern, &fcresult); 98 // FIXME: should we set some default font? 99 if (!m_pattern) 100 goto freePattern; 101 fontFace = cairo_ft_font_face_create_for_pattern(m_pattern); 102 cairo_matrix_t ctm; 103 cairo_matrix_init_scale(&fontMatrix, m_fontDescription.computedSize(), m_fontDescription.computedSize()); 104 cairo_matrix_init_identity(&ctm); 105 options = cairo_font_options_create(); 106 m_scaledFont = cairo_scaled_font_create(fontFace, &fontMatrix, &ctm, options); 107 cairo_font_face_destroy(fontFace); 108 cairo_font_options_destroy(options); 95 109 96 for (unsigned int i = 0; !m_font && i < G_N_ELEMENTS(families); i++) { 97 pango_font_description_set_family(description, families[i]); 98 m_font = pango_font_map_load_font(m_fontMap, m_context, description); 99 } 100 101 // FIXME: should we set some default font? 102 #if PANGO_VERSION_CHECK(1,18,0) 103 if (m_font) 104 m_scaledFont = cairo_scaled_font_reference(pango_cairo_font_get_scaled_font(PANGO_CAIRO_FONT(m_font))); 105 #else 106 // This compatibility code for older versions of Pango is not well-tested. 107 if (m_font) { 108 PangoFcFont* fcfont = PANGO_FC_FONT(m_font); 109 cairo_font_face_t* face = cairo_ft_font_face_create_for_pattern(fcfont->font_pattern); 110 double size; 111 if (FcPatternGetDouble(fcfont->font_pattern, FC_PIXEL_SIZE, 0, &size) != FcResultMatch) 112 size = 12.0; 113 cairo_matrix_t fontMatrix; 114 cairo_matrix_init_scale(&fontMatrix, size, size); 115 cairo_font_options_t* fontOptions; 116 if (pango_cairo_context_get_font_options(m_context)) 117 fontOptions = cairo_font_options_copy(pango_cairo_context_get_font_options(m_context)); 118 else 119 fontOptions = cairo_font_options_create(); 120 cairo_matrix_t ctm; 121 cairo_matrix_init_identity(&ctm); 122 m_scaledFont = cairo_scaled_font_create(face, &fontMatrix, &ctm, fontOptions); 123 cairo_font_options_destroy(fontOptions); 124 cairo_font_face_destroy(face); 125 } 126 #endif 127 128 pango_font_description_free(description); 110 freePattern: 111 FcPatternDestroy(pattern); 129 112 } 130 113 … … 135 118 return true; 136 119 initialized = true; 137 138 if (!m_fontMap) 139 m_fontMap = pango_cairo_font_map_new(); 140 if (!m_hashTable) { 141 PangoFontFamily**families = 0; 142 int n_families = 0; 143 144 m_hashTable = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_object_unref); 145 146 pango_font_map_list_families(m_fontMap, &families, &n_families); 147 148 for (int family = 0; family < n_families; family++) 149 g_hash_table_insert(m_hashTable, 150 g_strdup(pango_font_family_get_name(families[family])), 151 g_object_ref(families[family])); 152 153 g_free(families); 120 if (!FcInit()) { 121 fprintf(stderr, "Can't init font config library\n"); 122 return false; 154 123 } 155 156 124 return true; 157 125 } … … 159 127 FontPlatformData::~FontPlatformData() 160 128 { 161 // Destroy takes place in FontData::platformDestroy().162 129 } 163 130 164 131 bool FontPlatformData::isFixedPitch() 165 132 { 166 PangoFontDescription* description = pango_font_describe_with_absolute_size(m_font); 167 PangoFontFamily* family = reinterpret_cast<PangoFontFamily*>(g_hash_table_lookup(m_hashTable, pango_font_description_get_family(description))); 168 pango_font_description_free(description); 169 170 return pango_font_family_is_monospace(family); 133 int spacing; 134 if (FcPatternGetInteger(m_pattern, FC_SPACING, 0, &spacing) == FcResultMatch) 135 return spacing == FC_MONO; 136 return false; 171 137 } 172 138 … … 180 146 bool FontPlatformData::operator==(const FontPlatformData& other) const 181 147 { 182 if (m_ font == other.m_font)148 if (m_pattern == other.m_pattern) 183 149 return true; 184 if (m_ font == 0 || m_font == reinterpret_cast<PangoFont*>(-1)185 || other.m_ font == 0 || other.m_font == reinterpret_cast<PangoFont*>(-1))150 if (m_pattern == 0 || m_pattern == reinterpret_cast<FcPattern*>(-1) 151 || other.m_pattern == 0 || other.m_pattern == reinterpret_cast<FcPattern*>(-1)) 186 152 return false; 187 188 PangoFontDescription* thisDesc = pango_font_describe(m_font); 189 PangoFontDescription* otherDesc = pango_font_describe(other.m_font); 190 bool result = pango_font_description_equal(thisDesc, otherDesc); 191 pango_font_description_free(otherDesc); 192 pango_font_description_free(thisDesc); 193 return result; 153 return FcPatternEqual(m_pattern, other.m_pattern); 194 154 } 195 155 -
trunk/WebCore/platform/graphics/gtk/GlyphPageTreeNodeGtk.cpp
r28864 r28921 3 3 * Copyright (C) 2006 Michael Emmel mike.emmel@gmail.com 4 4 * Copyright (C) 2007 Alp Toker <alp.toker@collabora.co.uk> 5 * Copyright (C) 2007 Pioneer Research Center USA, Inc.6 5 * 7 6 * Redistribution and use in source and binary forms, with or without … … 34 33 35 34 #include "FontData.h" 36 #include <pango/pango-font.h>37 35 38 36 namespace WebCore { 39 40 static PangoGlyph pango_font_get_glyph(PangoFont* font, PangoContext* context, gunichar wc)41 {42 PangoGlyph result = 0;43 gchar buffer[7];44 45 gint length = g_unichar_to_utf8(wc, buffer);46 g_return_val_if_fail(length, 0);47 48 GList* items = pango_itemize(context, buffer, 0, length, NULL, NULL);49 50 if (g_list_length(items) == 1) {51 PangoGlyphString* glyphs = pango_glyph_string_new();52 53 pango_shape(buffer, length, &((PangoItem*)items->data)->analysis, glyphs);54 55 if (glyphs->num_glyphs == 1)56 result = glyphs->glyphs[0].glyph;57 else58 g_warning("didn't get 1 glyph but %d", glyphs->num_glyphs);59 60 pango_glyph_string_free(glyphs);61 }62 63 g_list_foreach(items, (GFunc)pango_item_free, NULL);64 g_list_free(items);65 66 return result;67 }68 37 69 38 bool GlyphPage::fill(UChar* buffer, unsigned bufferLength, const FontData* fontData) … … 74 43 return false; 75 44 76 if (!fontData->m_font.m_font || fontData->m_font.m_font == reinterpret_cast<PangoFont*>(-1)) 45 FT_Face face = cairo_ft_scaled_font_lock_face(fontData->m_font.m_scaledFont); 46 if (!face) 77 47 return false; 78 48 79 49 bool haveGlyphs = false; 80 50 for (unsigned i = 0; i < GlyphPage::size; i++) { 81 Glyph glyph = pango_font_get_glyph(fontData->m_font.m_font, fontData->m_font.m_context, buffer[i]);51 Glyph glyph = FcFreeTypeCharIndex(face, buffer[i]); 82 52 if (!glyph) 83 53 setGlyphDataForIndex(i, 0, 0); … … 88 58 } 89 59 60 cairo_ft_scaled_font_unlock_face(fontData->m_font.m_scaledFont); 61 90 62 return haveGlyphs; 91 63 } -
trunk/WebKit.pri
r28865 r28921 25 25 26 26 DEFINES += BUILDING_CAIRO__=1 BUILDING_GTK__=1 27 28 # We use FreeType directly with Cairo 29 PKGCONFIG += cairo-ft 27 30 28 31 directfb: PKGCONFIG += cairo-directfb gtk+-directfb-2.0
Note: See TracChangeset
for help on using the changeset viewer.