Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(274)

Side by Side Diff: Source/platform/fonts/harfbuzz/HarfBuzzShaper.h

Issue 130433006: Implement CSS Emphasis Marks for complex text (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: countGraphemesInCluster based on m_normalizedBuffer (win build fix) Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 27 matching lines...) Expand all
38 #include "wtf/HashSet.h" 38 #include "wtf/HashSet.h"
39 #include "wtf/OwnPtr.h" 39 #include "wtf/OwnPtr.h"
40 #include "wtf/PassOwnPtr.h" 40 #include "wtf/PassOwnPtr.h"
41 #include "wtf/unicode/CharacterNames.h" 41 #include "wtf/unicode/CharacterNames.h"
42 #include "wtf/Vector.h" 42 #include "wtf/Vector.h"
43 43
44 namespace WebCore { 44 namespace WebCore {
45 45
46 class Font; 46 class Font;
47 class SimpleFontData; 47 class SimpleFontData;
48
49 class HarfBuzzShaper FINAL { 48 class HarfBuzzShaper FINAL {
50 public: 49 public:
51 enum NormalizeMode { 50 enum NormalizeMode {
52 DoNotNormalizeMirrorChars, 51 DoNotNormalizeMirrorChars,
53 NormalizeMirrorChars 52 NormalizeMirrorChars
54 }; 53 };
55 54
56 HarfBuzzShaper(const Font*, const TextRun&); 55 enum ForTextEmphasisOrNot {
56 NotForTextEmphasis,
57 ForTextEmphasis
58 };
59
60 HarfBuzzShaper(const Font*, const TextRun&, ForTextEmphasisOrNot = NotForTex tEmphasis);
57 61
58 void setDrawRange(int from, int to); 62 void setDrawRange(int from, int to);
59 bool shape(GlyphBuffer* = 0); 63 bool shape(GlyphBuffer* = 0);
60 FloatPoint adjustStartPoint(const FloatPoint&); 64 FloatPoint adjustStartPoint(const FloatPoint&);
61 float totalWidth() { return m_totalWidth; } 65 float totalWidth() { return m_totalWidth; }
62 int offsetForPosition(float targetX); 66 int offsetForPosition(float targetX);
63 FloatRect selectionRect(const FloatPoint&, int height, int from, int to); 67 FloatRect selectionRect(const FloatPoint&, int height, int from, int to);
64 68
65 private: 69 private:
66 class HarfBuzzRun { 70 class HarfBuzzRun {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 130
127 // In complex text word-spacing affects each line-break, space (U+0020) and non-breaking space (U+00A0). 131 // In complex text word-spacing affects each line-break, space (U+0020) and non-breaking space (U+00A0).
128 static bool isCodepointSpace(UChar c) { return c == ' ' || c == noBreakSpace || c == '\n'; } 132 static bool isCodepointSpace(UChar c) { return c == ' ' || c == noBreakSpace || c == '\n'; }
129 133
130 void setFontFeatures(); 134 void setFontFeatures();
131 135
132 bool createHarfBuzzRuns(); 136 bool createHarfBuzzRuns();
133 bool shapeHarfBuzzRuns(); 137 bool shapeHarfBuzzRuns();
134 bool fillGlyphBuffer(GlyphBuffer*); 138 bool fillGlyphBuffer(GlyphBuffer*);
135 void fillGlyphBufferFromHarfBuzzRun(GlyphBuffer*, HarfBuzzRun*, FloatPoint& firstOffsetOfNextRun); 139 void fillGlyphBufferFromHarfBuzzRun(GlyphBuffer*, HarfBuzzRun*, FloatPoint& firstOffsetOfNextRun);
140 void fillGlyphBufferForTextEmphasis(GlyphBuffer*, HarfBuzzRun* currentRun);
136 void setGlyphPositionsForHarfBuzzRun(HarfBuzzRun*, hb_buffer_t*); 141 void setGlyphPositionsForHarfBuzzRun(HarfBuzzRun*, hb_buffer_t*);
137 void addHarfBuzzRun(unsigned startCharacter, unsigned endCharacter, const Si mpleFontData*, UScriptCode); 142 void addHarfBuzzRun(unsigned startCharacter, unsigned endCharacter, const Si mpleFontData*, UScriptCode);
138 143
139 GlyphBufferAdvance createGlyphBufferAdvance(float, float); 144 GlyphBufferAdvance createGlyphBufferAdvance(float, float);
140 145
141 const Font* m_font; 146 const Font* m_font;
142 OwnPtr<UChar[]> m_normalizedBuffer; 147 OwnPtr<UChar[]> m_normalizedBuffer;
143 unsigned m_normalizedBufferLength; 148 unsigned m_normalizedBufferLength;
144 const TextRun& m_run; 149 const TextRun& m_run;
145 150
146 float m_wordSpacingAdjustment; // Delta adjustment (pixels) for each word br eak. 151 float m_wordSpacingAdjustment; // Delta adjustment (pixels) for each word br eak.
147 float m_padding; // Pixels to be distributed over the line at word breaks. 152 float m_padding; // Pixels to be distributed over the line at word breaks.
148 float m_padPerWordBreak; // Pixels to be added to each word break. 153 float m_padPerWordBreak; // Pixels to be added to each word break.
149 float m_padError; // m_padPerWordBreak might have a fractional component. Si nce we only add a whole number of padding pixels at each word break we accumulat e error. This is the number of pixels that we are behind so far. 154 float m_padError; // m_padPerWordBreak might have a fractional component. Si nce we only add a whole number of padding pixels at each word break we accumulat e error. This is the number of pixels that we are behind so far.
150 float m_letterSpacing; // Pixels to be added after each glyph. 155 float m_letterSpacing; // Pixels to be added after each glyph.
151 156
152 Vector<hb_feature_t, 4> m_features; 157 Vector<hb_feature_t, 4> m_features;
153 Vector<OwnPtr<HarfBuzzRun>, 16> m_harfBuzzRuns; 158 Vector<OwnPtr<HarfBuzzRun>, 16> m_harfBuzzRuns;
154 159
155 FloatPoint m_startOffset; 160 FloatPoint m_startOffset;
156 161
157 int m_fromIndex; 162 int m_fromIndex;
158 int m_toIndex; 163 int m_toIndex;
159 164
165 ForTextEmphasisOrNot m_forTextEmphasis;
166
160 float m_totalWidth; 167 float m_totalWidth;
161 168
162 friend struct CachedShapingResults; 169 friend struct CachedShapingResults;
163 }; 170 };
164 171
165 } // namespace WebCore 172 } // namespace WebCore
166 173
167 #endif // HarfBuzzShaper_h 174 #endif // HarfBuzzShaper_h
OLDNEW
« no previous file with comments | « Source/platform/fonts/harfbuzz/FontHarfBuzz.cpp ('k') | Source/platform/fonts/harfbuzz/HarfBuzzShaper.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698