diff options
author | Ben Murdoch <benm@google.com> | 2011-05-24 11:24:40 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-06-02 09:53:15 +0100 |
commit | 81bc750723a18f21cd17d1b173cd2a4dda9cea6e (patch) | |
tree | 7a9e5ed86ff429fd347a25153107221543909b19 /Source/WebCore/platform/graphics/freetype | |
parent | 94088a6d336c1dd80a1e734af51e96abcbb689a7 (diff) | |
download | external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.zip external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.gz external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.bz2 |
Merge WebKit at r80534: Intial merge by Git
Change-Id: Ia7a83357124c9e1cdb1debf55d9661ec0bd09a61
Diffstat (limited to 'Source/WebCore/platform/graphics/freetype')
-rw-r--r-- | Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp | 30 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp | 13 |
2 files changed, 34 insertions, 9 deletions
diff --git a/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp b/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp index 1430124..b27bead 100644 --- a/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp +++ b/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp @@ -142,6 +142,33 @@ static String getFamilyNameStringFromFontDescriptionAndFamily(const FontDescript } } +int fontWeightToFontconfigWeight(FontWeight weight) +{ + switch (weight) { + case FontWeight100: + return FC_WEIGHT_THIN; + case FontWeight200: + return FC_WEIGHT_ULTRALIGHT; + case FontWeight300: + return FC_WEIGHT_LIGHT; + case FontWeight400: + return FC_WEIGHT_REGULAR; + case FontWeight500: + return FC_WEIGHT_MEDIUM; + case FontWeight600: + return FC_WEIGHT_SEMIBOLD; + case FontWeight700: + return FC_WEIGHT_BOLD; + case FontWeight800: + return FC_WEIGHT_EXTRABOLD; + case FontWeight900: + return FC_WEIGHT_ULTRABLACK; + default: + ASSERT_NOT_REACHED(); + return FC_WEIGHT_REGULAR; + } +} + FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family) { // The CSS font matching algorithm (http://www.w3.org/TR/css3-fonts/#font-matching-algorithm) @@ -155,8 +182,7 @@ FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD bool italic = fontDescription.italic(); if (!FcPatternAddInteger(pattern.get(), FC_SLANT, italic ? FC_SLANT_ITALIC : FC_SLANT_ROMAN)) return 0; - bool bold = fontDescription.weight() >= FontWeightBold; - if (!FcPatternAddInteger(pattern.get(), FC_WEIGHT, bold ? FC_WEIGHT_BOLD : FC_WEIGHT_NORMAL)) + if (!FcPatternAddInteger(pattern.get(), FC_WEIGHT, fontWeightToFontconfigWeight(fontDescription.weight()))) return 0; if (!FcPatternAddDouble(pattern.get(), FC_PIXEL_SIZE, fontDescription.computedPixelSize())) return 0; diff --git a/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp b/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp index 7340e76..fbc7ac9 100644 --- a/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp +++ b/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp @@ -31,7 +31,7 @@ #include <cairo.h> #include <fontconfig/fcfreetype.h> -#if !PLATFORM(EFL) || ENABLE(GLIB_SUPPORT) +#if !PLATFORM(EFL) #include <gdk/gdk.h> #endif @@ -100,17 +100,16 @@ void setCairoFontOptionsFromFontConfigPattern(cairo_font_options_t* options, FcP cairo_font_options_set_hint_style(options, CAIRO_HINT_STYLE_NONE); } -static const cairo_font_options_t* getDefaultFontOptions() +static cairo_font_options_t* getDefaultFontOptions() { - static const cairo_font_options_t* options = cairo_font_options_create(); -#if PLATFORM(GTK) || ENABLE(GLIB_SUPPORT) +#if PLATFORM(GTK) if (GdkScreen* screen = gdk_screen_get_default()) { const cairo_font_options_t* screenOptions = gdk_screen_get_font_options(screen); if (screenOptions) - options = screenOptions; + return cairo_font_options_copy(screenOptions); } #endif - return options; + return cairo_font_options_create(); } FontPlatformData::FontPlatformData(FcPattern* pattern, const FontDescription& fontDescription) @@ -242,7 +241,7 @@ String FontPlatformData::description() const void FontPlatformData::initializeWithFontFace(cairo_font_face_t* fontFace) { - cairo_font_options_t* options = cairo_font_options_copy(getDefaultFontOptions()); + cairo_font_options_t* options = getDefaultFontOptions(); cairo_matrix_t ctm; cairo_matrix_init_identity(&ctm); |