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

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

Issue 130433006: Implement CSS Emphasis Marks for complex text (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: New Approach, splitting hb-clusters into grapheme clusters, comment cleanup, rebaseline 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) 2003, 2006, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2003, 2006, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Holger Hans Peter Freyther 3 * Copyright (C) 2008 Holger Hans Peter Freyther
4 * Copyright (C) 2009 Torch Mobile, Inc. 4 * Copyright (C) 2009 Torch Mobile, Inc.
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 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 inline static float offsetToMiddleOfGlyph(const SimpleFontData* fontData, Glyph glyph) 491 inline static float offsetToMiddleOfGlyph(const SimpleFontData* fontData, Glyph glyph)
492 { 492 {
493 if (fontData->platformData().orientation() == Horizontal) { 493 if (fontData->platformData().orientation() == Horizontal) {
494 FloatRect bounds = fontData->boundsForGlyph(glyph); 494 FloatRect bounds = fontData->boundsForGlyph(glyph);
495 return bounds.x() + bounds.width() / 2; 495 return bounds.x() + bounds.width() / 2;
496 } 496 }
497 // FIXME: Use glyph bounds once they make sense for vertical fonts. 497 // FIXME: Use glyph bounds once they make sense for vertical fonts.
498 return fontData->widthForGlyph(glyph) / 2; 498 return fontData->widthForGlyph(glyph) / 2;
499 } 499 }
500 500
501 inline static float offsetToMiddleOfGlyphAtIndex(const GlyphBuffer& glyphBuffer, size_t i) 501 inline static float offsetToMiddleOfAdvanceAtIndex(const GlyphBuffer& glyphBuffe r, size_t i)
502 { 502 {
503 return offsetToMiddleOfGlyph(glyphBuffer.fontDataAt(i), glyphBuffer.glyphAt( i)); 503 return glyphBuffer.advanceAt(i) / 2;
504 } 504 }
505 505
506 void Font::drawEmphasisMarks(GraphicsContext* context, const TextRunPaintInfo& r unInfo, const GlyphBuffer& glyphBuffer, const AtomicString& mark, const FloatPoi nt& point) const 506 void Font::drawEmphasisMarks(GraphicsContext* context, const TextRunPaintInfo& r unInfo, const GlyphBuffer& glyphBuffer, const AtomicString& mark, const FloatPoi nt& point) const
507 { 507 {
508 FontCachePurgePreventer purgePreventer; 508 FontCachePurgePreventer purgePreventer;
509 509
510 GlyphData markGlyphData; 510 GlyphData markGlyphData;
511 if (!getEmphasisMarkGlyphData(mark, markGlyphData)) 511 if (!getEmphasisMarkGlyphData(mark, markGlyphData))
512 return; 512 return;
513 513
514 const SimpleFontData* markFontData = markGlyphData.fontData; 514 const SimpleFontData* markFontData = markGlyphData.fontData;
515 ASSERT(markFontData); 515 ASSERT(markFontData);
516 if (!markFontData) 516 if (!markFontData)
517 return; 517 return;
518 518
519 Glyph markGlyph = markGlyphData.glyph; 519 Glyph markGlyph = markGlyphData.glyph;
520 Glyph spaceGlyph = markFontData->spaceGlyph(); 520 Glyph spaceGlyph = markFontData->spaceGlyph();
521 521
522 float middleOfLastGlyph = offsetToMiddleOfGlyphAtIndex(glyphBuffer, 0); 522 float middleOfLastGlyph = offsetToMiddleOfAdvanceAtIndex(glyphBuffer, 0);
523 FloatPoint startPoint(point.x() + middleOfLastGlyph - offsetToMiddleOfGlyph( markFontData, markGlyph), point.y()); 523 FloatPoint startPoint(point.x() + middleOfLastGlyph - offsetToMiddleOfGlyph( markFontData, markGlyph), point.y());
524 524
525 GlyphBuffer markBuffer; 525 GlyphBuffer markBuffer;
526 for (unsigned i = 0; i + 1 < glyphBuffer.size(); ++i) { 526 for (unsigned i = 0; i + 1 < glyphBuffer.size(); ++i) {
527 float middleOfNextGlyph = offsetToMiddleOfGlyphAtIndex(glyphBuffer, i + 1); 527 float middleOfNextGlyph = offsetToMiddleOfAdvanceAtIndex(glyphBuffer, i + 1);
528 float advance = glyphBuffer.advanceAt(i) - middleOfLastGlyph + middleOfN extGlyph; 528 float advance = glyphBuffer.advanceAt(i) - middleOfLastGlyph + middleOfN extGlyph;
529 markBuffer.add(glyphBuffer.glyphAt(i) ? markGlyph : spaceGlyph, markFont Data, advance); 529 markBuffer.add(glyphBuffer.glyphAt(i) ? markGlyph : spaceGlyph, markFont Data, advance);
530 middleOfLastGlyph = middleOfNextGlyph; 530 middleOfLastGlyph = middleOfNextGlyph;
531 } 531 }
532 markBuffer.add(glyphBuffer.glyphAt(glyphBuffer.size() - 1) ? markGlyph : spa ceGlyph, markFontData, 0); 532 markBuffer.add(glyphBuffer.glyphAt(glyphBuffer.size() - 1) ? markGlyph : spa ceGlyph, markFontData, 0);
533 533
534 drawGlyphBuffer(context, runInfo, markBuffer, startPoint); 534 drawGlyphBuffer(context, runInfo, markBuffer, startPoint);
535 } 535 }
536 536
537 float Font::floatWidthForSimpleText(const TextRun& run, HashSet<const SimpleFont Data*>* fallbackFonts, GlyphOverflow* glyphOverflow) const 537 float Font::floatWidthForSimpleText(const TextRun& run, HashSet<const SimpleFont Data*>* fallbackFonts, GlyphOverflow* glyphOverflow) const
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 if (delta <= 0) 613 if (delta <= 0)
614 break; 614 break;
615 } 615 }
616 } 616 }
617 } 617 }
618 618
619 return offset; 619 return offset;
620 } 620 }
621 621
622 } 622 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698