Commit 7be215a5 authored by mrobinson@webkit.org's avatar mrobinson@webkit.org

2010-12-10 Martin Robinson <mrobinson@igalia.com>

        Reviewed by Xan Lopez.

        [Gtk] style="font-family: courier" makes text disappear
        https://bugs.webkit.org/show_bug.cgi?id=47452

        Added a GTK+ test for invalid fonts.

        * platform/gtk/fonts/font-with-no-valid-encoding-expected.checksum: Added.
        * platform/gtk/fonts/font-with-no-valid-encoding-expected.png: Added.
        * platform/gtk/fonts/font-with-no-valid-encoding-expected.txt: Added.
        * platform/gtk/fonts/font-with-no-valid-encoding.html: Added.
2010-12-10  Martin Robinson  <mrobinson@igalia.com>

        Reviewed by Xan Lopez.

        [Gtk] style="font-family: courier" makes text disappear
        https://bugs.webkit.org/show_bug.cgi?id=47452

        Don't ever use fonts that do not have any of the three charmaps that
        Fontconfig supports (Unicode, Apple Roman and Symbol). If we select
        a font that doesn't have one of these charmaps, use the next font in
        the list.

        Test: platform/gtk/fonts/font-with-no-valid-encoding.html

        * platform/graphics/freetype/FontCacheFreeType.cpp:
        (WebCore::FontCache::createFontPlatformData): Check whether the
        font we selected has a valid Fontconfig charmap.
        * platform/graphics/freetype/FontPlatformData.h: Added new method definition.
        * platform/graphics/freetype/FontPlatformDataFreeType.cpp:
        (WebCore::FontPlatformData::hasCompatibleCharmap): Added this method which
        verifies that a font has a valid Fontconfig charmap.
2010-12-10  Martin Robinson  <mrobinson@igalia.com>

        Reviewed by Xan Lopez.

        [Gtk] style="font-family: courier" makes text disappear
        https://bugs.webkit.org/show_bug.cgi?id=47452

        Add a test that verifies that fonts without valid charmaps are
        never selected.

        * DumpRenderTree/gtk/DumpRenderTree.cpp:
        (initializeFonts): Initialize DRT with our font (derived from Ahem)
        that has no valid charmap.
        * DumpRenderTree/gtk/fonts/FontWithNoValidEncoding.fon: Added.
        * DumpRenderTree/gtk/fonts/fonts.conf: Updated settings to override users'
        settings which may disable selection of bitmap fonts.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73695 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b49bf8a0
2010-12-10 Martin Robinson <mrobinson@igalia.com>
Reviewed by Xan Lopez.
[Gtk] style="font-family: courier" makes text disappear
https://bugs.webkit.org/show_bug.cgi?id=47452
Added a GTK+ test for invalid fonts.
* platform/gtk/fonts/font-with-no-valid-encoding-expected.checksum: Added.
* platform/gtk/fonts/font-with-no-valid-encoding-expected.png: Added.
* platform/gtk/fonts/font-with-no-valid-encoding-expected.txt: Added.
* platform/gtk/fonts/font-with-no-valid-encoding.html: Added.
2010-12-10 Csaba Osztrogonác <ossy@webkit.org>
Unreviewed fix after r73687.
......
f62a0decb7c9782b09d44c378fa466b8
\ No newline at end of file
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x576
RenderBlock {DIV} at (0,0) size 784x54
RenderBlock {P} at (0,0) size 784x19
RenderText {#text} at (0,0) size 713x19
text run at (0,0) width 713: "This test verifies that the fonts which do not have an encoding that Fontconfig does not understand are not loaded"
RenderBlock {P} at (0,35) size 784x19
RenderText {#text} at (0,0) size 274x19
text run at (0,0) width 274: "The following text should be in a serif face."
<html>
<head>
</head>
<body>
<div>
<p>This test verifies that the fonts which do not have an encoding that Fontconfig
does not understand are not loaded</p>
<p style="font-family: FontWithNoValidEncoding,serif">The following text should be in a serif face.</p>
</div>
</body>
</html>
2010-12-10 Martin Robinson <mrobinson@igalia.com>
Reviewed by Xan Lopez.
[Gtk] style="font-family: courier" makes text disappear
https://bugs.webkit.org/show_bug.cgi?id=47452
Don't ever use fonts that do not have any of the three charmaps that
Fontconfig supports (Unicode, Apple Roman and Symbol). If we select
a font that doesn't have one of these charmaps, use the next font in
the list.
Test: platform/gtk/fonts/font-with-no-valid-encoding.html
* platform/graphics/freetype/FontCacheFreeType.cpp:
(WebCore::FontCache::createFontPlatformData): Check whether the
font we selected has a valid Fontconfig charmap.
* platform/graphics/freetype/FontPlatformData.h: Added new method definition.
* platform/graphics/freetype/FontPlatformDataFreeType.cpp:
(WebCore::FontPlatformData::hasCompatibleCharmap): Added this method which
verifies that a font has a valid Fontconfig charmap.
2010-12-09 Ryosuke Niwa <rniwa@webkit.org>
Reviewed by Ojan Vafai.
......
......@@ -181,19 +181,26 @@ FontPlatformData* FontCache::createFontPlatformData(const FontDescription& fontD
FcChar8* fontConfigFamilyNameAfterMatching;
FcPatternGetString(resultPattern.get(), FC_FAMILY, 0, &fontConfigFamilyNameAfterMatching);
String familyNameAfterMatching = String::fromUTF8(reinterpret_cast<char*>(fontConfigFamilyNameAfterMatching));
if (equalIgnoringCase(familyNameAfterConfiguration, familyNameAfterMatching))
return new FontPlatformData(resultPattern.get(), fontDescription);
// If Fontconfig gave use a different font family than the one we requested, we should ignore it
// and allow WebCore to give us the next font on the CSS fallback list. The only exception is if
// this family name is a commonly used generic family.
if (equalIgnoringCase(familyNameString, "sans") || equalIgnoringCase(familyNameString, "sans-serif")
|| equalIgnoringCase(familyNameString, "serif") || equalIgnoringCase(familyNameString, "monospace")
|| equalIgnoringCase(familyNameString, "fantasy") || equalIgnoringCase(familyNameString, "cursive"))
return new FontPlatformData(resultPattern.get(), fontDescription);
if (!equalIgnoringCase(familyNameAfterConfiguration, familyNameAfterMatching)
&& !(equalIgnoringCase(familyNameString, "sans") || equalIgnoringCase(familyNameString, "sans-serif")
|| equalIgnoringCase(familyNameString, "serif") || equalIgnoringCase(familyNameString, "monospace")
|| equalIgnoringCase(familyNameString, "fantasy") || equalIgnoringCase(familyNameString, "cursive")))
return 0;
// Fontconfig did not return a good match.
return 0;
// Verify that this font has an encoding compatible with Fontconfig. Fontconfig currently
// supports three encodings in FcFreeTypeCharIndex: Unicode, Symbol and AppleRoman.
// If this font doesn't have one of these three encodings, don't select it.
FontPlatformData* platformData = new FontPlatformData(resultPattern.get(), fontDescription);
if (!platformData->hasCompatibleCharmap()) {
delete platformData;
return 0;
}
return platformData;
}
}
......@@ -68,6 +68,7 @@ public:
void setSize(float size) { m_size = size; }
bool syntheticBold() const { return m_syntheticBold; }
bool syntheticOblique() const { return m_syntheticOblique; }
bool hasCompatibleCharmap();
FontOrientation orientation() const { return Horizontal; } // FIXME: Implement.
......
......@@ -272,5 +272,17 @@ void FontPlatformData::initializeWithFontFace(cairo_font_face_t* fontFace)
cairo_font_options_destroy(options);
}
bool FontPlatformData::hasCompatibleCharmap()
{
if (!m_scaledFont)
return false;
FT_Face freeTypeFace = cairo_ft_scaled_font_lock_face(m_scaledFont);
bool hasCompatibleCharmap = !(FT_Select_Charmap(freeTypeFace, ft_encoding_unicode)
&& FT_Select_Charmap(freeTypeFace, ft_encoding_symbol)
&& FT_Select_Charmap(freeTypeFace, ft_encoding_apple_roman));
cairo_ft_scaled_font_unlock_face(m_scaledFont);
return hasCompatibleCharmap;
}
}
2010-12-10 Martin Robinson <mrobinson@igalia.com>
Reviewed by Xan Lopez.
[Gtk] style="font-family: courier" makes text disappear
https://bugs.webkit.org/show_bug.cgi?id=47452
Add a test that verifies that fonts without valid charmaps are
never selected.
* DumpRenderTree/gtk/DumpRenderTree.cpp:
(initializeFonts): Initialize DRT with our font (derived from Ahem)
that has no valid charmap.
* DumpRenderTree/gtk/fonts/FontWithNoValidEncoding.fon: Added.
* DumpRenderTree/gtk/fonts/fonts.conf: Updated settings to override users'
settings which may disable selection of bitmap fonts.
2010-12-10 Eric Seidel <eric@webkit.org>
Unreviewed.
......
......@@ -231,6 +231,11 @@ static void initializeFonts(const char* testURL = 0)
if (!FcConfigAppFontAddFile(config, reinterpret_cast<FcChar8*>(ahemFontFilename.get())))
g_error("Could not load font at %s!", ahemFontFilename.get());
// A font with no valid Fontconfig encoding to test https://bugs.webkit.org/show_bug.cgi?id=47452
GOwnPtr<gchar> fontWithNoValidEncodingFilename(g_build_filename(FONTS_CONF_DIR, "FontWithNoValidEncoding.fon", NULL));
if (!FcConfigAppFontAddFile(config, reinterpret_cast<FcChar8*>(fontWithNoValidEncodingFilename.get())))
g_error("Could not load font at %s!", fontWithNoValidEncodingFilename.get());
if (!FcConfigSetCurrent(config))
g_error("Could not set the current font configuration!");
......
......@@ -15,6 +15,21 @@
</edit>
</match>
<!-- This system may have turned off selection of bitmap fonts, but
we must turn it on again, because we want to be able to test that
bitmap fonts with no valid encodings are *never* selected regardless
of the Fontconfig settings. So force Fontconfig to select our cruddy
bitmap font -->
<selectfont>
<acceptfont>
<pattern>
<patelt name="family">
<string>FontWithNoValidEncoding</string>
</patelt>
</pattern>
</acceptfont>
</selectfont>
<!-- The sans-serif font should be Liberation Serif -->
<match target="pattern">
<test qual="any" name="family">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment