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

Side by Side Diff: Source/platform/fonts/WidthIterator.cpp

Issue 180893004: Adjust both x and y position when drawing glyphs (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: w/mac fix Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « Source/platform/fonts/GlyphBuffer.h ('k') | Source/platform/fonts/harfbuzz/FontHarfBuzz.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 m_isAfterExpansion = false; 239 m_isAfterExpansion = false;
240 240
241 // Account for word spacing. 241 // Account for word spacing.
242 // We apply additional space between "words" by adding width to the space character. 242 // We apply additional space between "words" by adding width to the space character.
243 if (treatAsSpace && (character != '\t' || !m_run.allowTabs()) && (textIterator.currentCharacter() || character == noBreakSpace) && m_font->fontD escription().wordSpacing()) 243 if (treatAsSpace && (character != '\t' || !m_run.allowTabs()) && (textIterator.currentCharacter() || character == noBreakSpace) && m_font->fontD escription().wordSpacing())
244 width += m_font->fontDescription().wordSpacing(); 244 width += m_font->fontDescription().wordSpacing();
245 } else 245 } else
246 m_isAfterExpansion = false; 246 m_isAfterExpansion = false;
247 } 247 }
248 248
249 if (shouldApplyFontTransforms() && glyphBuffer && Character::treatAsSpac e(character)) 249 if (shouldApplyFontTransforms() && glyphBuffer && Character::treatAsSpac e(character)) {
250 charactersTreatedAsSpace.append(make_pair(glyphBuffer->size(), 250 charactersTreatedAsSpace.append(make_pair(glyphBuffer->size(),
251 OriginalAdvancesForCharacterTreatedAsSpace(character == ' ', gly phBuffer->size() ? glyphBuffer->advanceAt(glyphBuffer->size() - 1) : 0, width))) ; 251 OriginalAdvancesForCharacterTreatedAsSpace(character == ' ',
252 glyphBuffer->size() ? glyphBuffer->advanceAt(glyphBuffer->si ze() - 1).width() : 0,
253 width)));
254 }
252 255
253 if (m_accountForGlyphBounds) { 256 if (m_accountForGlyphBounds) {
254 bounds = fontData->boundsForGlyph(glyph); 257 bounds = fontData->boundsForGlyph(glyph);
255 if (!textIterator.currentCharacter()) 258 if (!textIterator.currentCharacter())
256 m_firstGlyphOverflow = max<float>(0, -bounds.x()); 259 m_firstGlyphOverflow = max<float>(0, -bounds.x());
257 } 260 }
258 261
259 if (m_forTextEmphasis && !Character::canReceiveTextEmphasis(character)) 262 if (m_forTextEmphasis && !Character::canReceiveTextEmphasis(character))
260 glyph = 0; 263 glyph = 0;
261 264
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 SurrogatePairAwareTextIterator textIterator(m_run.data16(m_currentCharacter) , m_currentCharacter, offset, length); 333 SurrogatePairAwareTextIterator textIterator(m_run.data16(m_currentCharacter) , m_currentCharacter, offset, length);
331 return advanceInternal(textIterator, glyphBuffer); 334 return advanceInternal(textIterator, glyphBuffer);
332 } 335 }
333 336
334 bool WidthIterator::advanceOneCharacter(float& width, GlyphBuffer& glyphBuffer) 337 bool WidthIterator::advanceOneCharacter(float& width, GlyphBuffer& glyphBuffer)
335 { 338 {
336 unsigned oldSize = glyphBuffer.size(); 339 unsigned oldSize = glyphBuffer.size();
337 advance(m_currentCharacter + 1, &glyphBuffer); 340 advance(m_currentCharacter + 1, &glyphBuffer);
338 float w = 0; 341 float w = 0;
339 for (unsigned i = oldSize; i < glyphBuffer.size(); ++i) 342 for (unsigned i = oldSize; i < glyphBuffer.size(); ++i)
340 w += glyphBuffer.advanceAt(i); 343 w += glyphBuffer.advanceAt(i).width();
341 width = w; 344 width = w;
342 return glyphBuffer.size() > oldSize; 345 return glyphBuffer.size() > oldSize;
343 } 346 }
344 347
345 } 348 }
OLDNEW
« no previous file with comments | « Source/platform/fonts/GlyphBuffer.h ('k') | Source/platform/fonts/harfbuzz/FontHarfBuzz.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698