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

Side by Side Diff: Source/platform/fonts/shaping/SimpleShaper.cpp

Issue 1119663002: Making Unicode character names consistent (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase patch Created 5 years, 7 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) 2003, 2006, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2003, 2006, 2008, 2009, 2010, 2011 Apple Inc. All rights reserv ed.
3 * Copyright (C) 2008 Holger Hans Peter Freyther 3 * Copyright (C) 2008 Holger Hans Peter Freyther
4 * Copyright (C) 2014 Google Inc. All rights reserved. 4 * Copyright (C) 2014 Google Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 { 65 {
66 ASSERT(m_font); 66 ASSERT(m_font);
67 return m_font->glyphDataForCharacter(charData.character, m_run.rtl(), normal izeSpace); 67 return m_font->glyphDataForCharacter(charData.character, m_run.rtl(), normal izeSpace);
68 } 68 }
69 69
70 float SimpleShaper::characterWidth(UChar32 character, const GlyphData& glyphData ) const 70 float SimpleShaper::characterWidth(UChar32 character, const GlyphData& glyphData ) const
71 { 71 {
72 const SimpleFontData* fontData = glyphData.fontData; 72 const SimpleFontData* fontData = glyphData.fontData;
73 ASSERT(fontData); 73 ASSERT(fontData);
74 74
75 if (UNLIKELY(character == characterTabulation && m_run.allowTabs())) 75 if (UNLIKELY(character == tabulationCharacter && m_run.allowTabs()))
76 return m_font->tabWidth(*fontData, m_run.tabSize(), m_run.xPos() + m_run WidthSoFar); 76 return m_font->tabWidth(*fontData, m_run.tabSize(), m_run.xPos() + m_run WidthSoFar);
77 77
78 float width = fontData->widthForGlyph(glyphData.glyph); 78 float width = fontData->widthForGlyph(glyphData.glyph);
79 79
80 // SVG uses horizontalGlyphStretch(), when textLength is used to stretch/squ eeze text. 80 // SVG uses horizontalGlyphStretch(), when textLength is used to stretch/squ eeze text.
81 if (UNLIKELY(m_run.horizontalGlyphStretch() != 1)) 81 if (UNLIKELY(m_run.horizontalGlyphStretch() != 1))
82 width *= m_run.horizontalGlyphStretch(); 82 width *= m_run.horizontalGlyphStretch();
83 83
84 return width; 84 return width;
85 } 85 }
(...skipping 19 matching lines...) Expand all
105 m_expansion -= m_expansionPerOpportunity; 105 m_expansion -= m_expansionPerOpportunity;
106 width += m_expansionPerOpportunity; 106 width += m_expansionPerOpportunity;
107 m_isAfterExpansion = true; 107 m_isAfterExpansion = true;
108 } 108 }
109 } else { 109 } else {
110 m_isAfterExpansion = false; 110 m_isAfterExpansion = false;
111 } 111 }
112 112
113 // Account for word spacing. 113 // Account for word spacing.
114 // We apply additional space between "words" by adding width to the spac e character. 114 // We apply additional space between "words" by adding width to the spac e character.
115 if (isExpansionOpportunity && (charData.character != characterTabulation || !m_run.allowTabs()) 115 if (isExpansionOpportunity && (charData.character != tabulationCharacter || !m_run.allowTabs())
116 && (charData.characterOffset || charData.character == noBreakSpace) 116 && (charData.characterOffset || charData.character == noBreakSpaceCh aracter)
117 && m_font->fontDescription().wordSpacing()) { 117 && m_font->fontDescription().wordSpacing()) {
118 width += m_font->fontDescription().wordSpacing(); 118 width += m_font->fontDescription().wordSpacing();
119 } 119 }
120 } else { 120 } else {
121 m_isAfterExpansion = false; 121 m_isAfterExpansion = false;
122 } 122 }
123 123
124 return width; 124 return width;
125 } 125 }
126 126
(...skipping 11 matching lines...) Expand all
138 while (textIterator.consume(charData.character)) { 138 while (textIterator.consume(charData.character)) {
139 charData.characterOffset = textIterator.offset(); 139 charData.characterOffset = textIterator.offset();
140 charData.clusterLength = textIterator.glyphLength(); 140 charData.clusterLength = textIterator.glyphLength();
141 GlyphData glyphData = glyphDataForCharacter(charData, normalizeSpace); 141 GlyphData glyphData = glyphDataForCharacter(charData, normalizeSpace);
142 142
143 // Some fonts do not have a glyph for zero-width-space, 143 // Some fonts do not have a glyph for zero-width-space,
144 // in that case use the space character and override the width. 144 // in that case use the space character and override the width.
145 float width; 145 float width;
146 bool spaceUsedAsZeroWidthSpace = false; 146 bool spaceUsedAsZeroWidthSpace = false;
147 if (!glyphData.glyph && Character::treatAsZeroWidthSpace(charData.charac ter)) { 147 if (!glyphData.glyph && Character::treatAsZeroWidthSpace(charData.charac ter)) {
148 charData.character = space; 148 charData.character = spaceCharacter;
149 glyphData = glyphDataForCharacter(charData); 149 glyphData = glyphDataForCharacter(charData);
150 width = 0; 150 width = 0;
151 spaceUsedAsZeroWidthSpace = true; 151 spaceUsedAsZeroWidthSpace = true;
152 } else { 152 } else {
153 width = characterWidth(charData.character, glyphData); 153 width = characterWidth(charData.character, glyphData);
154 } 154 }
155 155
156 Glyph glyph = glyphData.glyph; 156 Glyph glyph = glyphData.glyph;
157 const SimpleFontData* fontData = glyphData.fontData; 157 const SimpleFontData* fontData = glyphData.fontData;
158 ASSERT(fontData); 158 ASSERT(fontData);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 float initialWidth = m_runWidthSoFar; 219 float initialWidth = m_runWidthSoFar;
220 220
221 if (!advance(m_currentCharacter + 1)) 221 if (!advance(m_currentCharacter + 1))
222 return false; 222 return false;
223 223
224 width = m_runWidthSoFar - initialWidth; 224 width = m_runWidthSoFar - initialWidth;
225 return true; 225 return true;
226 } 226 }
227 227
228 } // namespace blink 228 } // namespace blink
OLDNEW
« no previous file with comments | « Source/platform/fonts/shaping/HarfBuzzShaper.cpp ('k') | Source/platform/network/HTTPParsers.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698