summaryrefslogtreecommitdiffstats
path: root/webkit/pending/SimpleFontData.h
diff options
context:
space:
mode:
authordglazkov@google.com <dglazkov@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-29 22:11:23 +0000
committerdglazkov@google.com <dglazkov@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-29 22:11:23 +0000
commit0e9120dd886ca8ed40261250ed5c1cb9dcf502e3 (patch)
treef92d91de9d753c4424ce64f2b59898d3de68321d /webkit/pending/SimpleFontData.h
parent949ad3315c2e93cc3d8d21e9726187ec7c0f253e (diff)
downloadchromium_src-0e9120dd886ca8ed40261250ed5c1cb9dcf502e3.zip
chromium_src-0e9120dd886ca8ed40261250ed5c1cb9dcf502e3.tar.gz
chromium_src-0e9120dd886ca8ed40261250ed5c1cb9dcf502e3.tar.bz2
Makes sure that debug-only layout test failures are not to the ZERO WIDTH SPACE mapping to SPACE glyph complaints (http://b/1317563), fixes a layout test (fast/text/zero-width-characters.html), and provides an updated patch for WebKit.org bug 20237 (https://bugs.webkit.org/show_bug.cgi?id=20237).
This change brings handling of the ZWS and CJK character widths down to the level of SimpleFontData by creating special (sub-classed) SimpleFontData objects that are used in GlyphData. These instances are created when the glyph cache is being filled (GlyphPage::fill). More better things are possible, but at the moment I thought it might be good to just get the basics right. Also, a couple of the layout tests are brought back to pre-font-metric-hacks removal versions. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1557 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/pending/SimpleFontData.h')
-rw-r--r--webkit/pending/SimpleFontData.h43
1 files changed, 38 insertions, 5 deletions
diff --git a/webkit/pending/SimpleFontData.h b/webkit/pending/SimpleFontData.h
index c1a84aa..1ebdeaa 100644
--- a/webkit/pending/SimpleFontData.h
+++ b/webkit/pending/SimpleFontData.h
@@ -44,6 +44,8 @@ class FontPlatformData;
class SharedBuffer;
class SVGFontData;
class WidthMap;
+class ZeroWidthFontData;
+class CJKWidthFontData;
enum Pitch { UnknownPitch, FixedPitch, VariablePitch };
@@ -52,6 +54,10 @@ public:
SimpleFontData(const FontPlatformData&, bool customFont = false, bool loading = false, SVGFontData* data = 0);
virtual ~SimpleFontData();
+protected:
+ // sub-class constructor
+ SimpleFontData();
+
public:
const FontPlatformData& platformData() const { return m_font; }
SimpleFontData* smallCapsFontData(const FontDescription& fontDescription) const;
@@ -67,7 +73,7 @@ public:
float xHeight() const { return m_xHeight; }
unsigned unitsPerEm() const { return m_unitsPerEm; }
- float widthForGlyph(UChar32, Glyph) const;
+ virtual float widthForGlyph(Glyph) const;
float platformWidthForGlyph(Glyph) const;
virtual const SimpleFontData* fontDataForCharacter(UChar32) const;
@@ -117,12 +123,14 @@ public:
wxFont getWxFont() const { return m_font.font(); }
#endif
+ const SimpleFontData* zeroWidthFontData() const;
+ const SimpleFontData* cjkWidthFontData() const;
+
private:
void platformInit();
void platformDestroy();
void commonInit();
- bool IsCJKCodePoint(UChar32) const;
public:
int m_ascent;
@@ -155,9 +163,6 @@ public:
mutable SimpleFontData* m_smallCapsFontData;
- // Optimization for CJK glyphs
- mutable float m_cjkGlyphWidth;
-
#if PLATFORM(CG)
float m_syntheticBoldOffset;
#endif
@@ -176,6 +181,34 @@ public:
mutable SCRIPT_CACHE m_scriptCache;
mutable SCRIPT_FONTPROPERTIES* m_scriptFontProperties;
#endif
+
+private:
+ OwnPtr<ZeroWidthFontData> m_zeroWidthFontData;
+ OwnPtr<CJKWidthFontData> m_cjkWidthFontData;
+};
+
+// SimpleFontData sub-classes:
+
+// Has a single zero-width glyph, used for ZWS and
+// UCHAR_DEFAULT_IGNORABLE_CODE_POINT characters
+class ZeroWidthFontData : public SimpleFontData {
+public:
+ void init(SimpleFontData*);
+ virtual float widthForGlyph(Glyph) const { return 0.0f; }
+};
+
+// Monospaced, single glyph and width, used for CJK characters
+// The assumption made here can break for some high-quality CJK fonts with
+// proportional CJK glyphs.
+class CJKWidthFontData : public ZeroWidthFontData {
+public:
+ CJKWidthFontData();
+
+ virtual float widthForGlyph(Glyph) const;
+
+private:
+ // Optimization for CJK glyphs
+ mutable float m_cjkGlyphWidth;
};
} // namespace WebCore