| OLD | NEW |
| 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 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 return; | 653 return; |
| 654 | 654 |
| 655 drawEmphasisMarks(context, runInfo, glyphBuffer, mark, FloatPoint(point.x()
+ initialAdvance, point.y())); | 655 drawEmphasisMarks(context, runInfo, glyphBuffer, mark, FloatPoint(point.x()
+ initialAdvance, point.y())); |
| 656 } | 656 } |
| 657 | 657 |
| 658 void Font::drawGlyphBuffer(GraphicsContext* context, const TextRunPaintInfo& run
Info, const GlyphBuffer& glyphBuffer, const FloatPoint& point) const | 658 void Font::drawGlyphBuffer(GraphicsContext* context, const TextRunPaintInfo& run
Info, const GlyphBuffer& glyphBuffer, const FloatPoint& point) const |
| 659 { | 659 { |
| 660 // Draw each contiguous run of glyphs that use the same font data. | 660 // Draw each contiguous run of glyphs that use the same font data. |
| 661 const SimpleFontData* fontData = glyphBuffer.fontDataAt(0); | 661 const SimpleFontData* fontData = glyphBuffer.fontDataAt(0); |
| 662 FloatPoint startPoint(point); | 662 FloatPoint startPoint(point); |
| 663 float nextX = startPoint.x() + glyphBuffer.advanceAt(0); | 663 FloatPoint nextPoint = startPoint + glyphBuffer.advanceAt(0); |
| 664 unsigned lastFrom = 0; | 664 unsigned lastFrom = 0; |
| 665 unsigned nextGlyph = 1; | 665 unsigned nextGlyph = 1; |
| 666 #if ENABLE(SVG_FONTS) | 666 #if ENABLE(SVG_FONTS) |
| 667 TextRun::RenderingContext* renderingContext = runInfo.run.renderingContext()
; | 667 TextRun::RenderingContext* renderingContext = runInfo.run.renderingContext()
; |
| 668 #endif | 668 #endif |
| 669 while (nextGlyph < glyphBuffer.size()) { | 669 while (nextGlyph < glyphBuffer.size()) { |
| 670 const SimpleFontData* nextFontData = glyphBuffer.fontDataAt(nextGlyph); | 670 const SimpleFontData* nextFontData = glyphBuffer.fontDataAt(nextGlyph); |
| 671 | 671 |
| 672 if (nextFontData != fontData) { | 672 if (nextFontData != fontData) { |
| 673 #if ENABLE(SVG_FONTS) | 673 #if ENABLE(SVG_FONTS) |
| 674 if (renderingContext && fontData->isSVGFont()) | 674 if (renderingContext && fontData->isSVGFont()) |
| 675 renderingContext->drawSVGGlyphs(context, runInfo.run, fontData,
glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint); | 675 renderingContext->drawSVGGlyphs(context, runInfo.run, fontData,
glyphBuffer, lastFrom, nextGlyph - lastFrom, startPoint); |
| 676 else | 676 else |
| 677 #endif | 677 #endif |
| 678 drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph -
lastFrom, startPoint, runInfo.bounds); | 678 drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph -
lastFrom, startPoint, runInfo.bounds); |
| 679 | 679 |
| 680 lastFrom = nextGlyph; | 680 lastFrom = nextGlyph; |
| 681 fontData = nextFontData; | 681 fontData = nextFontData; |
| 682 startPoint.setX(nextX); | 682 startPoint = nextPoint; |
| 683 } | 683 } |
| 684 nextX += glyphBuffer.advanceAt(nextGlyph); | 684 nextPoint += glyphBuffer.advanceAt(nextGlyph); |
| 685 nextGlyph++; | 685 nextGlyph++; |
| 686 } | 686 } |
| 687 | 687 |
| 688 #if ENABLE(SVG_FONTS) | 688 #if ENABLE(SVG_FONTS) |
| 689 if (renderingContext && fontData->isSVGFont()) | 689 if (renderingContext && fontData->isSVGFont()) |
| 690 renderingContext->drawSVGGlyphs(context, runInfo.run, fontData, glyphBuf
fer, lastFrom, nextGlyph - lastFrom, startPoint); | 690 renderingContext->drawSVGGlyphs(context, runInfo.run, fontData, glyphBuf
fer, lastFrom, nextGlyph - lastFrom, startPoint); |
| 691 else | 691 else |
| 692 #endif | 692 #endif |
| 693 drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFro
m, startPoint, runInfo.bounds); | 693 drawGlyphs(context, fontData, glyphBuffer, lastFrom, nextGlyph - lastFro
m, startPoint, runInfo.bounds); |
| 694 } | 694 } |
| 695 | 695 |
| 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 offsetToMiddleOfAdvanceAtIndex(const GlyphBuffer& glyphBuffe
r, size_t i) | 706 inline static float offsetToMiddleOfAdvanceAtIndex(const GlyphBuffer& glyphBuffe
r, size_t i) |
| 707 { | 707 { |
| 708 return glyphBuffer.advanceAt(i) / 2; | 708 return glyphBuffer.advanceAt(i).width() / 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 = offsetToMiddleOfAdvanceAtIndex(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 = offsetToMiddleOfAdvanceAtIndex(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).width() - middleOfLastGlyph + m
iddleOfNextGlyph; |
| 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 |
| 743 { | 743 { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } |
| OLD | NEW |