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

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

Issue 152093006: Using x-advance for emphasis mark drawing. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebased on changed TestExpectations 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
« no previous file with comments | « LayoutTests/TestExpectations ('k') | no next file » | 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 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, 2010, 2011 Apple Inc. All rights reserved. 5 * Copyright (C) 2003, 2006, 2010, 2011 Apple Inc. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after
696 inline static float offsetToMiddleOfGlyph(const SimpleFontData* fontData, Glyph glyph) 696 inline static float offsetToMiddleOfGlyph(const SimpleFontData* fontData, Glyph glyph)
697 { 697 {
698 if (fontData->platformData().orientation() == Horizontal) { 698 if (fontData->platformData().orientation() == Horizontal) {
699 FloatRect bounds = fontData->boundsForGlyph(glyph); 699 FloatRect bounds = fontData->boundsForGlyph(glyph);
700 return bounds.x() + bounds.width() / 2; 700 return bounds.x() + bounds.width() / 2;
701 } 701 }
702 // FIXME: Use glyph bounds once they make sense for vertical fonts. 702 // FIXME: Use glyph bounds once they make sense for vertical fonts.
703 return fontData->widthForGlyph(glyph) / 2; 703 return fontData->widthForGlyph(glyph) / 2;
704 } 704 }
705 705
706 inline static float offsetToMiddleOfGlyphAtIndex(const GlyphBuffer& glyphBuffer, size_t i) 706 inline static float offsetToMiddleOfAdvanceAtIndex(const GlyphBuffer& glyphBuffe r, size_t i)
707 { 707 {
708 return offsetToMiddleOfGlyph(glyphBuffer.fontDataAt(i), glyphBuffer.glyphAt( i)); 708 return glyphBuffer.advanceAt(i) / 2;
709 } 709 }
710 710
711 void Font::drawEmphasisMarks(GraphicsContext* context, const TextRunPaintInfo& r unInfo, const GlyphBuffer& glyphBuffer, const AtomicString& mark, const FloatPoi nt& point) const 711 void Font::drawEmphasisMarks(GraphicsContext* context, const TextRunPaintInfo& r unInfo, const GlyphBuffer& glyphBuffer, const AtomicString& mark, const FloatPoi nt& point) const
712 { 712 {
713 FontCachePurgePreventer purgePreventer; 713 FontCachePurgePreventer purgePreventer;
714 714
715 GlyphData markGlyphData; 715 GlyphData markGlyphData;
716 if (!getEmphasisMarkGlyphData(mark, markGlyphData)) 716 if (!getEmphasisMarkGlyphData(mark, markGlyphData))
717 return; 717 return;
718 718
719 const SimpleFontData* markFontData = markGlyphData.fontData; 719 const SimpleFontData* markFontData = markGlyphData.fontData;
720 ASSERT(markFontData); 720 ASSERT(markFontData);
721 if (!markFontData) 721 if (!markFontData)
722 return; 722 return;
723 723
724 Glyph markGlyph = markGlyphData.glyph; 724 Glyph markGlyph = markGlyphData.glyph;
725 Glyph spaceGlyph = markFontData->spaceGlyph(); 725 Glyph spaceGlyph = markFontData->spaceGlyph();
726 726
727 float middleOfLastGlyph = offsetToMiddleOfGlyphAtIndex(glyphBuffer, 0); 727 float middleOfLastGlyph = offsetToMiddleOfAdvanceAtIndex(glyphBuffer, 0);
728 FloatPoint startPoint(point.x() + middleOfLastGlyph - offsetToMiddleOfGlyph( markFontData, markGlyph), point.y()); 728 FloatPoint startPoint(point.x() + middleOfLastGlyph - offsetToMiddleOfGlyph( markFontData, markGlyph), point.y());
729 729
730 GlyphBuffer markBuffer; 730 GlyphBuffer markBuffer;
731 for (unsigned i = 0; i + 1 < glyphBuffer.size(); ++i) { 731 for (unsigned i = 0; i + 1 < glyphBuffer.size(); ++i) {
732 float middleOfNextGlyph = offsetToMiddleOfGlyphAtIndex(glyphBuffer, i + 1); 732 float middleOfNextGlyph = offsetToMiddleOfAdvanceAtIndex(glyphBuffer, i + 1);
733 float advance = glyphBuffer.advanceAt(i) - middleOfLastGlyph + middleOfN extGlyph; 733 float advance = glyphBuffer.advanceAt(i) - middleOfLastGlyph + middleOfN extGlyph;
734 markBuffer.add(glyphBuffer.glyphAt(i) ? markGlyph : spaceGlyph, markFont Data, advance); 734 markBuffer.add(glyphBuffer.glyphAt(i) ? markGlyph : spaceGlyph, markFont Data, advance);
735 middleOfLastGlyph = middleOfNextGlyph; 735 middleOfLastGlyph = middleOfNextGlyph;
736 } 736 }
737 markBuffer.add(glyphBuffer.glyphAt(glyphBuffer.size() - 1) ? markGlyph : spa ceGlyph, markFontData, 0); 737 markBuffer.add(glyphBuffer.glyphAt(glyphBuffer.size() - 1) ? markGlyph : spa ceGlyph, markFontData, 0);
738 738
739 drawGlyphBuffer(context, runInfo, markBuffer, startPoint); 739 drawGlyphBuffer(context, runInfo, markBuffer, startPoint);
740 } 740 }
741 741
742 float Font::floatWidthForSimpleText(const TextRun& run, HashSet<const SimpleFont Data*>* fallbackFonts, GlyphOverflow* glyphOverflow) const 742 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
818 if (delta <= 0) 818 if (delta <= 0)
819 break; 819 break;
820 } 820 }
821 } 821 }
822 } 822 }
823 823
824 return offset; 824 return offset;
825 } 825 }
826 826
827 } 827 }
OLDNEW
« no previous file with comments | « LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698