| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 2000 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) | 3 * (C) 2000 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2000 Dirk Mueller (mueller@kde.org) | 4 * (C) 2000 Dirk Mueller (mueller@kde.org) |
| 5 * Copyright (C) 2003, 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. | 5 * Copyright (C) 2003, 2006, 2007, 2010, 2011 Apple Inc. All rights reserved. |
| 6 * Copyright (C) 2008 Holger Hans Peter Freyther | 6 * Copyright (C) 2008 Holger Hans Peter Freyther |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 */ | 23 */ |
| 24 | 24 |
| 25 #ifndef Font_h | 25 #ifndef Font_h |
| 26 #define Font_h | 26 #define Font_h |
| 27 | 27 |
| 28 #include "platform/PlatformExport.h" | 28 #include "platform/PlatformExport.h" |
| 29 #include "platform/fonts/FontDescription.h" | 29 #include "platform/fonts/FontDescription.h" |
| 30 #include "platform/fonts/FontFallbackList.h" | 30 #include "platform/fonts/FontFallbackList.h" |
| 31 #include "platform/fonts/SimpleFontData.h" | 31 #include "platform/fonts/SimpleFontData.h" |
| 32 #include "platform/fonts/TextBlob.h" | 32 #include "platform/fonts/TextBlob.h" |
| 33 #include "platform/text/TabSize.h" |
| 33 #include "platform/text/TextDirection.h" | 34 #include "platform/text/TextDirection.h" |
| 34 #include "platform/text/TextPath.h" | 35 #include "platform/text/TextPath.h" |
| 35 #include "wtf/HashMap.h" | 36 #include "wtf/HashMap.h" |
| 36 #include "wtf/HashSet.h" | 37 #include "wtf/HashSet.h" |
| 37 #include "wtf/MathExtras.h" | 38 #include "wtf/MathExtras.h" |
| 38 #include "wtf/text/CharacterNames.h" | 39 #include "wtf/text/CharacterNames.h" |
| 39 | 40 |
| 40 // "X11/X.h" defines Complex to 0 and conflicts | 41 // "X11/X.h" defines Complex to 0 and conflicts |
| 41 // with Complex value in CodePath enum. | 42 // with Complex value in CodePath enum. |
| 42 #ifdef Complex | 43 #ifdef Complex |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 int emphasisMarkAscent(const AtomicString&) const; | 99 int emphasisMarkAscent(const AtomicString&) const; |
| 99 int emphasisMarkDescent(const AtomicString&) const; | 100 int emphasisMarkDescent(const AtomicString&) const; |
| 100 int emphasisMarkHeight(const AtomicString&) const; | 101 int emphasisMarkHeight(const AtomicString&) const; |
| 101 | 102 |
| 102 const SimpleFontData* primaryFont() const; | 103 const SimpleFontData* primaryFont() const; |
| 103 const FontData* fontDataAt(unsigned) const; | 104 const FontData* fontDataAt(unsigned) const; |
| 104 | 105 |
| 105 GlyphData glyphDataForCharacter(UChar32&, bool mirror, bool normalizeSpace =
false, FontDataVariant = AutoVariant) const; | 106 GlyphData glyphDataForCharacter(UChar32&, bool mirror, bool normalizeSpace =
false, FontDataVariant = AutoVariant) const; |
| 106 CodePath codePath(const TextRunPaintInfo&) const; | 107 CodePath codePath(const TextRunPaintInfo&) const; |
| 107 | 108 |
| 109 // Whether the font supports shaping word by word instead of shaping the |
| 110 // full run in one go. Allows better caching for fonts where space cannot |
| 111 // participate in kerning and/or ligatures. |
| 112 bool canShapeWordByWord() const; |
| 113 |
| 114 void setCanShapeWordByWordForTesting(bool b) |
| 115 { |
| 116 m_canShapeWordByWord = b; |
| 117 m_shapeWordByWordComputed = true; |
| 118 } |
| 119 |
| 108 private: | 120 private: |
| 109 enum ForTextEmphasisOrNot { NotForTextEmphasis, ForTextEmphasis }; | 121 enum ForTextEmphasisOrNot { NotForTextEmphasis, ForTextEmphasis }; |
| 110 | 122 |
| 111 // Returns the total advance. | 123 // Returns the total advance. |
| 112 float buildGlyphBuffer(const TextRunPaintInfo&, GlyphBuffer&, const GlyphDat
a* emphasisData = nullptr) const; | 124 float buildGlyphBuffer(const TextRunPaintInfo&, GlyphBuffer&, const GlyphDat
a* emphasisData = nullptr) const; |
| 113 PassTextBlobPtr buildTextBlob(const GlyphBuffer&) const; | 125 PassTextBlobPtr buildTextBlob(const GlyphBuffer&) const; |
| 114 void paintGlyphs(SkCanvas*, const SkPaint&, const SimpleFontData*, const Gly
ph glyphs[], unsigned numGlyphs, | 126 void paintGlyphs(SkCanvas*, const SkPaint&, const SimpleFontData*, const Gly
ph glyphs[], unsigned numGlyphs, |
| 115 const SkPoint pos[], const FloatRect& textRect, float deviceScaleFactor)
const; | 127 const SkPoint pos[], const FloatRect& textRect, float deviceScaleFactor)
const; |
| 116 void paintGlyphsHorizontal(SkCanvas*, const SkPaint&, const SimpleFontData*,
const Glyph glyphs[], unsigned numGlyphs, | 128 void paintGlyphsHorizontal(SkCanvas*, const SkPaint&, const SimpleFontData*,
const Glyph glyphs[], unsigned numGlyphs, |
| 117 const SkScalar xpos[], SkScalar constY, const FloatRect& textRect, float
deviceScaleFactor) const; | 129 const SkScalar xpos[], SkScalar constY, const FloatRect& textRect, float
deviceScaleFactor) const; |
| 118 void drawGlyphs(SkCanvas*, const SkPaint&, const SimpleFontData*, const Glyp
hBuffer&, unsigned from, unsigned numGlyphs, | 130 void drawGlyphs(SkCanvas*, const SkPaint&, const SimpleFontData*, const Glyp
hBuffer&, unsigned from, unsigned numGlyphs, |
| 119 const FloatPoint&, const FloatRect& textRect, float deviceScaleFactor) c
onst; | 131 const FloatPoint&, const FloatRect& textRect, float deviceScaleFactor) c
onst; |
| 120 void drawTextBlob(SkCanvas*, const SkPaint&, const SkTextBlob*, const SkPoin
t& origin) const; | 132 void drawTextBlob(SkCanvas*, const SkPaint&, const SkTextBlob*, const SkPoin
t& origin) const; |
| 121 void drawGlyphBuffer(SkCanvas*, const SkPaint&, const TextRunPaintInfo&, con
st GlyphBuffer&, const FloatPoint&, float deviceScaleFactor) const; | 133 void drawGlyphBuffer(SkCanvas*, const SkPaint&, const TextRunPaintInfo&, con
st GlyphBuffer&, const FloatPoint&, float deviceScaleFactor) const; |
| 122 float floatWidthForSimpleText(const TextRun&, HashSet<const SimpleFontData*>
* fallbackFonts = 0, FloatRect* glyphBounds = 0) const; | 134 float floatWidthForSimpleText(const TextRun&, HashSet<const SimpleFontData*>
* fallbackFonts = 0, FloatRect* glyphBounds = 0) const; |
| 123 int offsetForPositionForSimpleText(const TextRun&, float position, bool incl
udePartialGlyphs) const; | 135 int offsetForPositionForSimpleText(const TextRun&, float position, bool incl
udePartialGlyphs) const; |
| 124 FloatRect selectionRectForSimpleText(const TextRun&, const FloatPoint&, int
h, int from, int to, bool accountForGlyphBounds) const; | 136 FloatRect selectionRectForSimpleText(const TextRun&, const FloatPoint&, int
h, int from, int to, bool accountForGlyphBounds) const; |
| 125 | 137 |
| 126 bool getEmphasisMarkGlyphData(const AtomicString&, GlyphData&) const; | 138 bool getEmphasisMarkGlyphData(const AtomicString&, GlyphData&) const; |
| 127 | 139 |
| 128 float floatWidthForComplexText(const TextRun&, HashSet<const SimpleFontData*
>* fallbackFonts, FloatRect* glyphBounds) const; | 140 float floatWidthForComplexText(const TextRun&, HashSet<const SimpleFontData*
>* fallbackFonts, FloatRect* glyphBounds) const; |
| 129 int offsetForPositionForComplexText(const TextRun&, float position, bool inc
ludePartialGlyphs) const; | 141 int offsetForPositionForComplexText(const TextRun&, float position, bool inc
ludePartialGlyphs) const; |
| 130 FloatRect selectionRectForComplexText(const TextRun&, const FloatPoint&, int
h, int from, int to) const; | 142 FloatRect selectionRectForComplexText(const TextRun&, const FloatPoint&, int
h, int from, int to) const; |
| 131 | 143 |
| 144 bool computeCanShapeWordByWord() const; |
| 145 |
| 132 friend struct SimpleShaper; | 146 friend struct SimpleShaper; |
| 133 | 147 |
| 134 public: | 148 public: |
| 135 FontSelector* fontSelector() const; | 149 FontSelector* fontSelector() const; |
| 136 | 150 |
| 137 void willUseFontData(UChar32) const; | 151 void willUseFontData(UChar32) const; |
| 138 | 152 |
| 139 bool loadingCustomFonts() const; | 153 bool loadingCustomFonts() const; |
| 140 bool isFallbackValid() const; | 154 bool isFallbackValid() const; |
| 141 | 155 |
| 142 private: | 156 private: |
| 143 bool shouldSkipDrawing() const | 157 bool shouldSkipDrawing() const |
| 144 { | 158 { |
| 145 return m_fontFallbackList && m_fontFallbackList->shouldSkipDrawing(); | 159 return m_fontFallbackList && m_fontFallbackList->shouldSkipDrawing(); |
| 146 } | 160 } |
| 147 | 161 |
| 148 FontDescription m_fontDescription; | 162 FontDescription m_fontDescription; |
| 149 mutable RefPtr<FontFallbackList> m_fontFallbackList; | 163 mutable RefPtr<FontFallbackList> m_fontFallbackList; |
| 164 mutable unsigned m_canShapeWordByWord : 1; |
| 165 mutable unsigned m_shapeWordByWordComputed : 1; |
| 150 }; | 166 }; |
| 151 | 167 |
| 152 inline Font::~Font() | 168 inline Font::~Font() |
| 153 { | 169 { |
| 154 } | 170 } |
| 155 | 171 |
| 156 inline const SimpleFontData* Font::primaryFont() const | 172 inline const SimpleFontData* Font::primaryFont() const |
| 157 { | 173 { |
| 158 ASSERT(m_fontFallbackList); | 174 ASSERT(m_fontFallbackList); |
| 159 return m_fontFallbackList->primarySimpleFontData(m_fontDescription); | 175 return m_fontFallbackList->primarySimpleFontData(m_fontDescription); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 181 // to the next tab stop is less than that, advance an additional tab stop. | 197 // to the next tab stop is less than that, advance an additional tab stop. |
| 182 if (distanceToTabStop < fontDescription().letterSpacing()) | 198 if (distanceToTabStop < fontDescription().letterSpacing()) |
| 183 distanceToTabStop += baseTabWidth; | 199 distanceToTabStop += baseTabWidth; |
| 184 | 200 |
| 185 return distanceToTabStop; | 201 return distanceToTabStop; |
| 186 } | 202 } |
| 187 | 203 |
| 188 } // namespace blink | 204 } // namespace blink |
| 189 | 205 |
| 190 #endif | 206 #endif |
| OLD | NEW |