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 15 matching lines...) Expand all Loading... |
26 #define Font_h | 26 #define Font_h |
27 | 27 |
28 #include "platform/LayoutUnit.h" | 28 #include "platform/LayoutUnit.h" |
29 #include "platform/PlatformExport.h" | 29 #include "platform/PlatformExport.h" |
30 #include "platform/fonts/FontDescription.h" | 30 #include "platform/fonts/FontDescription.h" |
31 #include "platform/fonts/FontFallbackList.h" | 31 #include "platform/fonts/FontFallbackList.h" |
32 #include "platform/fonts/FontFallbackPriority.h" | 32 #include "platform/fonts/FontFallbackPriority.h" |
33 #include "platform/fonts/SimpleFontData.h" | 33 #include "platform/fonts/SimpleFontData.h" |
34 #include "platform/text/TabSize.h" | 34 #include "platform/text/TabSize.h" |
35 #include "platform/text/TextDirection.h" | 35 #include "platform/text/TextDirection.h" |
36 #include "platform/text/TextPath.h" | |
37 #include "wtf/Allocator.h" | 36 #include "wtf/Allocator.h" |
38 #include "wtf/HashMap.h" | 37 #include "wtf/HashMap.h" |
39 #include "wtf/HashSet.h" | 38 #include "wtf/HashSet.h" |
40 #include "wtf/MathExtras.h" | 39 #include "wtf/MathExtras.h" |
41 #include "wtf/text/CharacterNames.h" | 40 #include "wtf/text/CharacterNames.h" |
42 | 41 |
43 class SkCanvas; | 42 class SkCanvas; |
44 class SkPaint; | 43 class SkPaint; |
45 struct SkPoint; | 44 struct SkPoint; |
46 | 45 |
47 namespace blink { | 46 namespace blink { |
48 | 47 |
49 struct CharacterRange; | 48 struct CharacterRange; |
50 class FloatPoint; | 49 class FloatPoint; |
51 class FloatRect; | 50 class FloatRect; |
52 class FontFallbackIterator; | 51 class FontFallbackIterator; |
53 class FontData; | 52 class FontData; |
54 class FontMetrics; | 53 class FontMetrics; |
55 class FontSelector; | 54 class FontSelector; |
56 class GlyphBuffer; | 55 class GlyphBuffer; |
57 class TextRun; | 56 class TextRun; |
58 struct TextRunPaintInfo; | 57 struct TextRunPaintInfo; |
59 | 58 |
60 struct GlyphData; | |
61 | |
62 class PLATFORM_EXPORT Font { | 59 class PLATFORM_EXPORT Font { |
63 DISALLOW_NEW(); | 60 DISALLOW_NEW(); |
64 | 61 |
65 public: | 62 public: |
66 Font(); | 63 Font(); |
67 Font(const FontDescription&); | 64 Font(const FontDescription&); |
68 ~Font(); | 65 ~Font(); |
69 | 66 |
70 Font(const Font&); | 67 Font(const Font&); |
71 Font& operator=(const Font&); | 68 Font& operator=(const Font&); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 int emphasisMarkAscent(const AtomicString&) const; | 150 int emphasisMarkAscent(const AtomicString&) const; |
154 int emphasisMarkDescent(const AtomicString&) const; | 151 int emphasisMarkDescent(const AtomicString&) const; |
155 int emphasisMarkHeight(const AtomicString&) const; | 152 int emphasisMarkHeight(const AtomicString&) const; |
156 | 153 |
157 // This may fail and return a nullptr in case the last resort font cannot be | 154 // This may fail and return a nullptr in case the last resort font cannot be |
158 // loaded. This *should* not happen but in reality it does ever now and then | 155 // loaded. This *should* not happen but in reality it does ever now and then |
159 // when, for whatever reason, the last resort font cannot be loaded. | 156 // when, for whatever reason, the last resort font cannot be loaded. |
160 const SimpleFontData* primaryFont() const; | 157 const SimpleFontData* primaryFont() const; |
161 const FontData* fontDataAt(unsigned) const; | 158 const FontData* fontDataAt(unsigned) const; |
162 | 159 |
163 GlyphData glyphDataForCharacter(UChar32&, | |
164 bool mirror, | |
165 bool normalizeSpace = false, | |
166 FontDataVariant = AutoVariant) const; | |
167 CodePath codePath(const TextRunPaintInfo&) const; | |
168 | |
169 // Whether the font supports shaping word by word instead of shaping the | 160 // Whether the font supports shaping word by word instead of shaping the |
170 // full run in one go. Allows better caching for fonts where space cannot | 161 // full run in one go. Allows better caching for fonts where space cannot |
171 // participate in kerning and/or ligatures. | 162 // participate in kerning and/or ligatures. |
172 bool canShapeWordByWord() const; | 163 bool canShapeWordByWord() const; |
173 | 164 |
174 void setCanShapeWordByWordForTesting(bool b) { | 165 void setCanShapeWordByWordForTesting(bool b) { |
175 m_canShapeWordByWord = b; | 166 m_canShapeWordByWord = b; |
176 m_shapeWordByWordComputed = true; | 167 m_shapeWordByWordComputed = true; |
177 } | 168 } |
178 | 169 |
179 private: | 170 private: |
180 enum ForTextEmphasisOrNot { NotForTextEmphasis, ForTextEmphasis }; | 171 enum ForTextEmphasisOrNot { NotForTextEmphasis, ForTextEmphasis }; |
181 | 172 |
182 // Returns the total advance. | 173 // Returns the total advance. |
183 float buildGlyphBuffer(const TextRunPaintInfo&, | 174 float buildGlyphBuffer(const TextRunPaintInfo&, |
184 GlyphBuffer&, | 175 GlyphBuffer&, |
185 const GlyphData* emphasisData = nullptr) const; | 176 const GlyphData* emphasisData = nullptr) const; |
186 void drawGlyphBuffer(SkCanvas*, | 177 void drawGlyphBuffer(SkCanvas*, |
187 const SkPaint&, | 178 const SkPaint&, |
188 const TextRunPaintInfo&, | 179 const TextRunPaintInfo&, |
189 const GlyphBuffer&, | 180 const GlyphBuffer&, |
190 const FloatPoint&, | 181 const FloatPoint&, |
191 float deviceScaleFactor) const; | 182 float deviceScaleFactor) const; |
192 float floatWidthForSimpleText( | |
193 const TextRun&, | |
194 HashSet<const SimpleFontData*>* fallbackFonts = 0, | |
195 FloatRect* glyphBounds = 0) const; | |
196 int offsetForPositionForSimpleText(const TextRun&, | |
197 float position, | |
198 bool includePartialGlyphs) const; | |
199 FloatRect selectionRectForSimpleText(const TextRun&, | |
200 const FloatPoint&, | |
201 int h, | |
202 int from, | |
203 int to, | |
204 bool accountForGlyphBounds) const; | |
205 | 183 |
206 bool getEmphasisMarkGlyphData(const AtomicString&, GlyphData&) const; | 184 bool getEmphasisMarkGlyphData(const AtomicString&, GlyphData&) const; |
207 | 185 |
208 float floatWidthForComplexText(const TextRun&, | 186 float floatWidthForComplexText(const TextRun&, |
209 HashSet<const SimpleFontData*>* fallbackFonts, | 187 HashSet<const SimpleFontData*>* fallbackFonts, |
210 FloatRect* glyphBounds) const; | 188 FloatRect* glyphBounds) const; |
211 int offsetForPositionForComplexText(const TextRun&, | 189 int offsetForPositionForComplexText(const TextRun&, |
212 float position, | 190 float position, |
213 bool includePartialGlyphs) const; | 191 bool includePartialGlyphs) const; |
214 FloatRect selectionRectForComplexText(const TextRun&, | 192 FloatRect selectionRectForComplexText(const TextRun&, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 // advance an additional tab stop. | 255 // advance an additional tab stop. |
278 if (distanceToTabStop < fontData->spaceWidth() / 2) | 256 if (distanceToTabStop < fontData->spaceWidth() / 2) |
279 distanceToTabStop += baseTabWidth; | 257 distanceToTabStop += baseTabWidth; |
280 | 258 |
281 return distanceToTabStop; | 259 return distanceToTabStop; |
282 } | 260 } |
283 | 261 |
284 } // namespace blink | 262 } // namespace blink |
285 | 263 |
286 #endif | 264 #endif |
OLD | NEW |