diff options
5 files changed, 98 insertions, 18 deletions
diff --git a/skia/ports/SkFontHost_fontconfig.cpp b/skia/ports/SkFontHost_fontconfig.cpp index cb95a60..f36bb2e 100644 --- a/skia/ports/SkFontHost_fontconfig.cpp +++ b/skia/ports/SkFontHost_fontconfig.cpp @@ -278,13 +278,8 @@ void SkFontHost::Serialize(const SkTypeface*, SkWStream*) { SkScalerContext* SkFontHost::CreateFallbackScalerContext (const SkScalerContext::Rec& rec) { - FcPattern* pattern = FcPatternCreate(); - FcConfigSubstitute(0, pattern, FcMatchPattern); - FcDefaultSubstitute(pattern); - - FcResult result; - FcPattern* match = FcFontMatch(0, pattern, &result); - FcPatternDestroy(pattern); + FcPattern* match = FontMatch(FC_FAMILY, FcTypeString, "serif", + NULL); // This will fail when we have no fonts on the system. SkASSERT(match); diff --git a/webkit/port/platform/graphics/chromium/FontPlatformDataLinux.cpp b/webkit/port/platform/graphics/chromium/FontPlatformDataLinux.cpp index b047cb334..a3d9dd0 100644 --- a/webkit/port/platform/graphics/chromium/FontPlatformDataLinux.cpp +++ b/webkit/port/platform/graphics/chromium/FontPlatformDataLinux.cpp @@ -58,7 +58,7 @@ void FontPlatformData::setupPaint(SkPaint* paint) const { const float ts = m_textSize > 0 ? m_textSize : 12; - paint->setAntiAlias(true); + paint->setAntiAlias(false); paint->setSubpixelText(false); paint->setTextSize(SkFloatToScalar(ts)); paint->setTypeface(m_typeface); diff --git a/webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp b/webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp index 7371275..29b5d74 100644 --- a/webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp +++ b/webkit/port/platform/graphics/chromium/SimpleFontDataLinux.cpp @@ -29,17 +29,13 @@ void SimpleFontData::platformInit() m_font.setupPaint(&paint); paint.getFontMetrics(&metrics); - // use ceil instead of round to favor descent, given a lot of accidental - // clipping of descenders (e.g. 14pt 'g') in textedit fields - const int descent = SkScalarCeil(metrics.fDescent); - const int span = SkScalarRound(metrics.fDescent - metrics.fAscent); - const int ascent = span - descent; - - m_ascent = ascent; - m_descent = descent; + // Beware those who step here: This code is designed to match Win32 font + // metrics *exactly*. + m_ascent = SkScalarCeil(-metrics.fAscent); + m_descent = SkScalarCeil(metrics.fDescent); m_xHeight = SkScalarToFloat(-metrics.fAscent) * 0.56f; // hack I stole from the Windows port - m_lineSpacing = ascent + descent; - m_lineGap = SkScalarRound(metrics.fLeading); + m_lineGap = SkScalarCeil(metrics.fLeading); + m_lineSpacing = m_ascent + m_descent + m_lineGap; // In WebKit/WebCore/platform/graphics/SimpleFontData.cpp, m_spaceWidth is // calculated for us, but we need to calculate m_maxCharWidth and diff --git a/webkit/tools/test_shell/resources/linux-fontconfig-config b/webkit/tools/test_shell/resources/linux-fontconfig-config new file mode 100644 index 0000000..57757c3 --- /dev/null +++ b/webkit/tools/test_shell/resources/linux-fontconfig-config @@ -0,0 +1,76 @@ +<?xml version="1.0"?> +<!DOCTYPE fontconfig SYSTEM "fonts.dtd"> +<!-- /etc/fonts/fonts.conf file to configure system font access --> +<fontconfig> + <match target="pattern"> + <test qual="any" name="family"> + <string>Times</string> + </test> + <edit name="family" mode="assign"> + <string>Times New Roman</string> + </edit> + </match> + + <match target="pattern"> + <test qual="any" name="family"> + <string>sans</string> + </test> + <edit name="family" mode="assign"> + <string>Arial</string> + </edit> + </match> + + <match target="pattern"> + <test qual="any" name="family"> + <string>sans serif</string> + </test> + <edit name="family" mode="assign"> + <string>Arial</string> + </edit> + </match> + + <match target="pattern"> + <test qual="any" name="family"> + <string>sans-serif</string> + </test> + <edit name="family" mode="assign"> + <string>Arial</string> + </edit> + </match> + + <match target="pattern"> + <test qual="any" name="family"> + <string>serif</string> + </test> + <edit name="family" mode="assign"> + <string>Times New Roman</string> + </edit> + </match> + + <match target="pattern"> + <test qual="any" name="family"> + <string>mono</string> + </test> + <edit name="family" mode="assign"> + <string>Courier New</string> + </edit> + </match> + + <match target="pattern"> + <test qual="any" name="family"> + <string>monospace</string> + </test> + <edit name="family" mode="assign"> + <string>Courier New</string> + </edit> + </match> + + <match target="pattern"> + <test qual="any" name="family"> + <string>Courier</string> + </test> + <edit name="family" mode="assign"> + <string>Courier New</string> + </edit> + </match> +</fontconfig> diff --git a/webkit/tools/test_shell/test_shell_gtk.cc b/webkit/tools/test_shell/test_shell_gtk.cc index 6f072b6..7ef9db3 100644 --- a/webkit/tools/test_shell/test_shell_gtk.cc +++ b/webkit/tools/test_shell/test_shell_gtk.cc @@ -61,8 +61,21 @@ void TestShell::InitializeTestShell(bool interactive) { NULL }; + // We have fontconfig parse a config file from our resources directory. This + // sets a number of aliases ("sans"->"Arial" etc), but doesn't include any + // font directories. + FilePath path; + PathService::Get(base::DIR_SOURCE_ROOT, &path); + path.Append("webkti/tools/test_shell/resources/linux-fontconfig-config"); + FcInit(); + FcConfig* fontcfg = FcConfigCreate(); + if (!FcConfigParseAndLoad(fontcfg, (const FcChar8*) path.value().c_str(), + true)) { + LOG(FATAL) << "Failed to parse fontconfig config file"; + } + for (unsigned i = 0; fonts[i]; ++i) { if (access(fonts[i], R_OK)) { LOG(FATAL) << "You are missing " << fonts[i] << ". " |