Reviewed by Darin Adler and Dave Hyatt.
- Substitute the user's preferred standard font for an unknown primary
font before falling back on the platform's last resort font
Cannot be tested in DumpRenderTree because it sets the standard font to
Times, which is also the hard-coded last resort font on Mac.
* css/CSSFontSelector.cpp:
(WebCore::CSSFontSelector::getFontData): Changed the early bail out
condition to allow getting generic font families from settings even if
there are not @font-face rules. Fixed a typo that mapped fantasy to
cursive. Added a mapping from -webkit-standard to the standard family.
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::CSSStyleSelector): Changed to always create
a font selector.
(WebCore::CSSRuleSet::addRulesFromSheet):
(WebCore::CSSStyleSelector::applyProperty): Changed to always use the
font selector.
* css/CSSStyleSelector.h:
(WebCore::CSSStyleSelector::fontSelector):
* platform/graphics/FontCache.cpp:
(WebCore::FontCache::getFontData): Try the user's preferred standard
font before the platform's last resort font.
LayoutTests:
- remove passing tests following the change to font fallback
* platform/win/Skipped: Removed tests that failed only because they
specified as primary font family a font family that was not available
on Windows and therefore were rendered using the platform last resort
font, Times New Roman. Now they are rendered using the 'standard'
font family, which is set to Times on both Mac and Windows when running
the tests.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@28882
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2007-12-19 Dan Bernstein <mitz@apple.com>
+
+ - remove passing tests following the change to font fallback
+
+ * platform/win/Skipped: Removed tests that failed only because they
+ specified as primary font family a font family that was not available
+ on Windows and therefore were rendered using the platform last resort
+ font, Times New Roman. Now they are rendered using the 'standard'
+ font family, which is set to Times on both Mac and Windows when running
+ the tests.
+
2007-12-19 Alice Liu <alice.liu@apple.com>
Reviewed by Darin.
css2.1/t1202-counters-09-b.html
editing/deleting/5144139-2.html
fast/css/beforeSelectorOnCodeElement.html
-fast/css/font_property_normal.html
fast/css/rtl-ordering.html
fast/css/text-security.html
-fast/encoding/denormalised-voiced-japanese-chars.html
fast/encoding/invalid-UTF-8.html
fast/forms/select-visual-hebrew.html
fast/forms/select-writing-direction-natural.html
fast/lists/w3-list-styles.html
fast/text/international/bidi-neutral-run.html
fast/xsl/xslt-text.xml
-svg/W3C-SVG-1.1/animate-elem-03-t.svg
-svg/W3C-SVG-1.1/animate-elem-24-t.svg
-svg/W3C-SVG-1.1/animate-elem-36-t.svg
-svg/W3C-SVG-1.1/animate-elem-40-t.svg
svg/W3C-SVG-1.1/coords-viewattr-01-b.svg
-svg/W3C-SVG-1.1/fonts-desc-02-t.svg
svg/W3C-SVG-1.1/fonts-elem-01-t.svg
svg/W3C-SVG-1.1/fonts-elem-02-t.svg
svg/W3C-SVG-1.1/fonts-elem-03-b.svg
svg/W3C-SVG-1.1/fonts-elem-04-b.svg
-svg/W3C-SVG-1.1/fonts-elem-05-t.svg
-svg/W3C-SVG-1.1/fonts-elem-06-t.svg
svg/W3C-SVG-1.1/fonts-elem-07-b.svg
svg/W3C-SVG-1.1/fonts-glyph-02-t.svg
-svg/W3C-SVG-1.1/fonts-glyph-03-t.svg
-svg/W3C-SVG-1.1/fonts-glyph-04-t.svg
-svg/W3C-SVG-1.1/fonts-kern-01-t.svg
svg/W3C-SVG-1.1/interact-cursor-01-f.svg
-svg/W3C-SVG-1.1/masking-mask-01-b.svg
svg/W3C-SVG-1.1/metadata-example-01-b.svg
-svg/W3C-SVG-1.1/pservers-grad-08-b.svg
-svg/W3C-SVG-1.1/render-elems-06-t.svg
-svg/W3C-SVG-1.1/render-elems-07-t.svg
svg/W3C-SVG-1.1/render-elems-08-t.svg
svg/W3C-SVG-1.1/render-groups-01-b.svg
-svg/W3C-SVG-1.1/render-groups-03-t.svg
-svg/W3C-SVG-1.1/text-altglyph-01-b.svg
svg/W3C-SVG-1.1/text-fonts-01-t.svg
svg/W3C-SVG-1.1/text-intro-05-t.svg
-svg/W3C-SVG-1.1/text-text-04-t.svg
-svg/W3C-SVG-1.1/text-text-05-t.svg
-svg/W3C-SVG-1.1/text-text-06-t.svg
svg/W3C-SVG-1.1/text-tselect-02-f.svg
svg/W3C-SVG-1.1/animate-elem-06-t.svg
svg/W3C-SVG-1.1/animate-elem-07-t.svg
svg/batik/text/smallFonts.svg
svg/batik/text/textAnchor.svg
svg/batik/text/textBiDi.svg
-svg/batik/text/textEffect3.svg
-svg/batik/text/textEffect.svg
-svg/batik/text/textFeatures.svg
-svg/batik/text/textPosition2.svg
-svg/batik/text/textProperties2.svg
-svg/batik/text/textStyles.svg
svg/batik/paints/patternRegions.svg
svg/carto.net/button.svg
svg/carto.net/colourpicker.svg
svg/custom/control-points-for-S-and-T.svg
svg/custom/coords-relative-units-transforms.svg
svg/custom/marker-changes.svg
-svg/custom/scrolling-embedded-svg-file-image-repaint-problem.html
svg/custom/use-referencing-nonexisting-symbol.svg
svg/custom/width-full-percentage.svg
svg/hixie/text/003.html
svg/hixie/text/003a.xml
svg/hixie/viewbox/preserveAspectRatio/002.xml
-svg/text/text-altglyph-01-b.svg
svg/text/text-fonts-01-t.svg
svg/text/text-intro-05-t.svg
-svg/text/text-text-04-t.svg
-svg/text/text-text-05-t.svg
-svg/text/text-text-06-t.svg
svg/text/text-tselect-02-f.svg
tables/mozilla/core/bloomberg.html
-tables/mozilla/bugs/bug8381.html
tables/mozilla/bugs/bug10633.html
tables/mozilla/bugs/bug23151.html
tables/mozilla/bugs/bug113424.html
+2007-12-19 Dan Bernstein <mitz@apple.com>
+
+ Reviewed by Darin Adler and Dave Hyatt.
+
+ - Substitute the user's preferred standard font for an unknown primary
+ font before falling back on the platform's last resort font
+
+ Cannot be tested in DumpRenderTree because it sets the standard font to
+ Times, which is also the hard-coded last resort font on Mac.
+
+ * css/CSSFontSelector.cpp:
+ (WebCore::CSSFontSelector::getFontData): Changed the early bail out
+ condition to allow getting generic font families from settings even if
+ there are not @font-face rules. Fixed a typo that mapped fantasy to
+ cursive. Added a mapping from -webkit-standard to the standard family.
+ * css/CSSStyleSelector.cpp:
+ (WebCore::CSSStyleSelector::CSSStyleSelector): Changed to always create
+ a font selector.
+ (WebCore::CSSRuleSet::addRulesFromSheet):
+ (WebCore::CSSStyleSelector::applyProperty): Changed to always use the
+ font selector.
+ * css/CSSStyleSelector.h:
+ (WebCore::CSSStyleSelector::fontSelector):
+ * platform/graphics/FontCache.cpp:
+ (WebCore::FontCache::getFontData): Try the user's preferred standard
+ font before the platform's last resort font.
+
2007-12-19 Sven Herzberg <sven@imendio.com>
Reviewed by Alp Toker.
FontData* CSSFontSelector::getFontData(const FontDescription& fontDescription, const AtomicString& familyName)
{
- if (m_fonts.isEmpty())
+ if (m_fonts.isEmpty() && !familyName.startsWith("-webkit-"))
return 0;
bool bold = fontDescription.bold();
else if (familyName == "-webkit-cursive")
genericFamily = settings->cursiveFontFamily();
else if (familyName == "-webkit-fantasy")
- genericFamily = settings->cursiveFontFamily();
+ genericFamily = settings->fantasyFontFamily();
else if (familyName == "-webkit-monospace")
genericFamily = settings->fixedFontFamily();
+ else if (familyName == "-webkit-standard")
+ genericFamily = settings->standardFontFamily();
if (!genericFamily.isEmpty())
return FontCache::getCachedFontData(FontCache::getCachedFontPlatformData(fontDescription, genericFamily));
init();
m_document = doc;
+ m_fontSelector = new CSSFontSelector(doc);
m_matchAuthorAndUserStyles = matchAuthorAndUserStyles;
for (; it.current(); ++it)
if (it.current()->isCSSStyleSheet() && !it.current()->disabled())
m_authorStyle->addRulesFromSheet(static_cast<CSSStyleSheet*>(it.current()), *m_medium, this);
-
- // Just delete our font selector if we end up with nothing but invalid @font-face rules.
- if (m_fontSelector && m_fontSelector->isEmpty())
- m_fontSelector = 0;
}
void CSSStyleSelector::init()
} else if (item->isFontFaceRule() && styleSelector) {
// Add this font face to our set.
const CSSFontFaceRule* fontFaceRule = static_cast<CSSFontFaceRule*>(item);
- styleSelector->ensureFontSelector()->addFontFaceRule(fontFaceRule);
+ styleSelector->fontSelector()->addFontFaceRule(fontFaceRule);
}
} // for rules
} // if rules
} else if (item->isFontFaceRule() && styleSelector) {
// Add this font face to our set.
const CSSFontFaceRule* fontFaceRule = static_cast<CSSFontFaceRule*>(item);
- styleSelector->ensureFontSelector()->addFontFaceRule(fontFaceRule);
+ styleSelector->fontSelector()->addFontFaceRule(fontFaceRule);
}
}
}
face = settings->standardFontFamily();
break;
case CSS_VAL_SERIF:
- face = m_fontSelector ? "-webkit-serif" : settings->serifFontFamily();
+ face = "-webkit-serif";
fontDescription.setGenericFamily(FontDescription::SerifFamily);
break;
case CSS_VAL_SANS_SERIF:
- face = m_fontSelector ? "-webkit-sans-serif" : settings->sansSerifFontFamily();
+ face = "-webkit-sans-serif";
fontDescription.setGenericFamily(FontDescription::SansSerifFamily);
break;
case CSS_VAL_CURSIVE:
- face = m_fontSelector ? "-webkit-cursive" : settings->cursiveFontFamily();
+ face = "-webkit-cursive";
fontDescription.setGenericFamily(FontDescription::CursiveFamily);
break;
case CSS_VAL_FANTASY:
- face = m_fontSelector ? "-webkit-fantasy" : settings->fantasyFontFamily();
+ face = "-webkit-fantasy";
fontDescription.setGenericFamily(FontDescription::FantasyFamily);
break;
case CSS_VAL_MONOSPACE:
- face = m_fontSelector ? "-webkit-monospace" : settings->fixedFontFamily();
+ face = "-webkit-monospace";
fontDescription.setGenericFamily(FontDescription::MonospaceFamily);
break;
}
return m_selectorAttrs.contains(attrname.impl());
}
-CSSFontSelector* CSSStyleSelector::ensureFontSelector()
-{
- if (!m_fontSelector.get())
- m_fontSelector = new CSSFontSelector(m_document);
- return m_fontSelector.get();
-}
-
} // namespace WebCore
bool hasSelectorForAttribute(const AtomicString &attrname);
CSSFontSelector* fontSelector() { return m_fontSelector.get(); }
- CSSFontSelector* ensureFontSelector();
protected:
// Geeza Pro font.
result = getSimilarFontPlatformData(font);
- if (!result && startIndex == 0)
- // We still don't have a result. Hand back our last resort fallback font. We only do the last resort fallback
- // when trying to find the primary font. Otherwise our fallback will rely on the actual characters used.
+ if (!result && startIndex == 0) {
+ // If it's the primary font that we couldn't find, we try the following. In all other cases, we will
+ // just use per-character system fallback.
+
+ if (fontSelector) {
+ // Try the user's preferred standard font.
+ if (FontData* data = fontSelector->getFontData(font.fontDescription(), "-webkit-standard"))
+ return data;
+ }
+
+ // Still no result. Hand back our last resort fallback font.
result = getLastResortFallbackFont(font.fontDescription());
+ }
// Now that we have a result, we need to go from FontPlatformData -> FontData.
return getCachedFontData(result);