diff options
Diffstat (limited to 'WebCore/platform/graphics/Font.h')
-rw-r--r-- | WebCore/platform/graphics/Font.h | 120 |
1 files changed, 19 insertions, 101 deletions
diff --git a/WebCore/platform/graphics/Font.h b/WebCore/platform/graphics/Font.h index 84048ed..a99ce12 100644 --- a/WebCore/platform/graphics/Font.h +++ b/WebCore/platform/graphics/Font.h @@ -1,6 +1,4 @@ /* - * This file is part of the html renderer for KDE. - * * Copyright (C) 2000 Lars Knoll (knoll@kde.org) * (C) 2000 Antti Koivisto (koivisto@kde.org) * (C) 2000 Dirk Mueller (mueller@kde.org) @@ -26,6 +24,7 @@ #ifndef Font_h #define Font_h +#include "TextRun.h" #include "FontDescription.h" #include <wtf/HashMap.h> @@ -46,102 +45,11 @@ class GlyphBuffer; class GlyphPageTreeNode; class GraphicsContext; class IntPoint; -class RenderObject; class SimpleFontData; -class SVGPaintServer; +class SVGFontElement; struct GlyphData; -class TextRun { -public: - TextRun(const UChar* c, int len, bool allowTabs = false, int xpos = 0, int padding = 0, bool rtl = false, bool directionalOverride = false, - bool applyRunRounding = true, bool applyWordRounding = true) - : m_characters(c) - , m_len(len) - , m_allowTabs(allowTabs) - , m_xpos(xpos) - , m_padding(padding) - , m_rtl(rtl) - , m_directionalOverride(directionalOverride) - , m_applyRunRounding(applyRunRounding) - , m_applyWordRounding(applyWordRounding) - , m_disableSpacing(false) -#if ENABLE(SVG_FONTS) - , m_referencingRenderObject(0) - , m_activePaintServer(0) -#endif - { - } - - TextRun(const String& s, bool allowTabs = false, int xpos = 0, int padding = 0, bool rtl = false, bool directionalOverride = false, - bool applyRunRounding = true, bool applyWordRounding = true) - : m_characters(s.characters()) - , m_len(s.length()) - , m_allowTabs(allowTabs) - , m_xpos(xpos) - , m_padding(padding) - , m_rtl(rtl) - , m_directionalOverride(directionalOverride) - , m_applyRunRounding(applyRunRounding) - , m_applyWordRounding(applyWordRounding) - , m_disableSpacing(false) -#if ENABLE(SVG_FONTS) - , m_referencingRenderObject(0) - , m_activePaintServer(0) -#endif - { - } - - const UChar operator[](int i) const { return m_characters[i]; } - const UChar* data(int i) const { return &m_characters[i]; } - - const UChar* characters() const { return m_characters; } - int length() const { return m_len; } - - void setText(const UChar* c, int len) { m_characters = c; m_len = len; } - - bool allowTabs() const { return m_allowTabs; } - int xPos() const { return m_xpos; } - int padding() const { return m_padding; } - bool rtl() const { return m_rtl; } - bool ltr() const { return !m_rtl; } - bool directionalOverride() const { return m_directionalOverride; } - bool applyRunRounding() const { return m_applyRunRounding; } - bool applyWordRounding() const { return m_applyWordRounding; } - bool spacingDisabled() const { return m_disableSpacing; } - - void disableSpacing() { m_disableSpacing = true; } - void disableRoundingHacks() { m_applyRunRounding = m_applyWordRounding = false; } - void setRTL(bool b) { m_rtl = b; } - void setDirectionalOverride(bool override) { m_directionalOverride = override; } - -#if ENABLE(SVG_FONTS) - RenderObject* referencingRenderObject() const { return m_referencingRenderObject; } - void setReferencingRenderObject(RenderObject* object) { m_referencingRenderObject = object; } - - SVGPaintServer* activePaintServer() const { return m_activePaintServer; } - void setActivePaintServer(SVGPaintServer* object) { m_activePaintServer = object; } -#endif - -private: - const UChar* m_characters; - int m_len; - - bool m_allowTabs; - int m_xpos; - int m_padding; - bool m_rtl; - bool m_directionalOverride; - bool m_applyRunRounding; - bool m_applyWordRounding; - bool m_disableSpacing; - -#if ENABLE(SVG_FONTS) - RenderObject* m_referencingRenderObject; - SVGPaintServer* m_activePaintServer; -#endif -}; - class Font { public: Font(); @@ -170,6 +78,7 @@ public: int width(const TextRun&) const; float floatWidth(const TextRun&) const; + float floatWidth(const TextRun& run, int extraCharsAvailable, int& charsConsumed, String& glyphName) const; int offsetForPosition(const TextRun&, int position, bool includePartialGlyphs) const; FloatRect selectionRectForText(const TextRun&, const IntPoint&, int h, int from = 0, int to = -1) const; @@ -194,8 +103,7 @@ public: const FontFamily& family() const { return m_fontDescription.family(); } bool italic() const { return m_fontDescription.italic(); } - unsigned weight() const { return m_fontDescription.weight(); } - bool bold() const { return m_fontDescription.bold(); } + FontWeight weight() const { return m_fontDescription.weight(); } #if !PLATFORM(QT) bool isPlatformFont() const { return m_isPlatformFont; } @@ -211,6 +119,7 @@ public: int descent() const; int height() const { return ascent() + descent(); } int lineSpacing() const; + int lineGap() const; float xHeight() const; unsigned unitsPerEm() const; int spaceWidth() const; @@ -234,6 +143,7 @@ private: #if ENABLE(SVG_FONTS) void drawTextUsingSVGFont(GraphicsContext*, const TextRun&, const FloatPoint&, int from, int to) const; float floatWidthUsingSVGFont(const TextRun&) const; + float floatWidthUsingSVGFont(const TextRun&, int extraCharsAvailable, int& charsConsumed, String& glyphName) const; FloatRect selectionRectForTextUsingSVGFont(const TextRun&, const IntPoint&, int h, int from, int to) const; int offsetForPositionForTextUsingSVGFont(const TextRun&, int position, bool includePartialGlyphs) const; #endif @@ -250,12 +160,15 @@ private: #endif friend struct WidthIterator; - // Useful for debugging the different font rendering code paths. public: -#if !PLATFORM(QT) +#if PLATFORM(QT) + FontSelector* fontSelector() const { return 0; } +#else + // Useful for debugging the different font rendering code paths. enum CodePath { Auto, Simple, Complex }; static void setCodePath(CodePath); - static CodePath codePath; + static CodePath codePath(); + static CodePath s_codePath; static const uint8_t gRoundingHackCharacterTable[256]; static bool isRoundingHackCharacter(UChar32 c) @@ -266,8 +179,13 @@ public: FontSelector* fontSelector() const; #endif static bool treatAsSpace(UChar c) { return c == ' ' || c == '\t' || c == '\n' || c == 0x00A0; } -// ANDROID: extra parentheses around expressions to suppress warnings - static bool treatAsZeroWidthSpace(UChar c) { return c < 0x20 || (c >= 0x7F && c < 0xA0) || c == 0x200e || c == 0x200f || (c >= 0x202a && c <= 0x202e); } + static bool treatAsZeroWidthSpace(UChar c) { return c < 0x20 || (c >= 0x7F && c < 0xA0) || c == 0x200e || c == 0x200f || (c >= 0x202a && c <= 0x202e) || c == 0xFFFC; } + +#if ENABLE(SVG_FONTS) + bool isSVGFont() const; + SVGFontElement* svgFont() const; +#endif + private: FontDescription m_fontDescription; #if !PLATFORM(QT) |