のねのBlog

パソコンの問題や、ソフトウェアの開発で起きた問題など書いていきます。よろしくお願いします^^。

SimpleText

=============================================================================================

    353 void Font::drawSimpleText(GraphicsContext* context, const TextRun& run,
                                 const FloatPoint& point, int from, int to) const
    354 {
    355     // This glyph buffer holds our glyphs+advances+font data for each glyph.
    356     GlyphBuffer glyphBuffer;
    357 
    358     float startX = point.x() + getGlyphsAndAdvancesForSimpleText(run, from, to, glyphBuffer);
    359 
    360     if (glyphBuffer.isEmpty())
    361         return;
    362 
    363     FloatPoint startPoint(startX, point.y());
    364     drawGlyphBuffer(context, glyphBuffer, startPoint);
    365 }
    378 void Font::drawGlyphBuffer(GraphicsContext* context,
                             const GlyphBuffer& glyphBuffer,
                             const FloatPoint& point) const
    379 {
    380     // Draw each contiguous run of glyphs that use the same font data.
    381     const SimpleFontData* fontData = glyphBuffer.fontDataAt(0);
    382     FloatSize offset = glyphBuffer.offsetAt(0);
    383     FloatPoint startPoint(point);
    384     float nextX = startPoint.x();
    385     int lastFrom = 0;
    386     int nextGlyph = 0;
    387     while (nextGlyph < glyphBuffer.size()) {
    388         const SimpleFontData* nextFontData = glyphBuffer.fontDataAt(nextGlyph);
    389         FloatSize nextOffset = glyphBuffer.offsetAt(nextGlyph);
    390         if (nextFontData != fontData || nextOffset != offset) {
    391             drawGlyphs(context, fontData, glyphBuffer,
                              lastFrom, nextGlyph - lastFrom, startPoint); <==========
    392 
    393             lastFrom = nextGlyph;
    394             fontData = nextFontData;
    395             offset = nextOffset;
    396             startPoint.setX(nextX);
    397         }
    398         nextX += glyphBuffer.advanceAt(nextGlyph);
    399         nextGlyph++;
    400     }
    401 
    402     drawGlyphs(context, fontData, glyphBuffer,
                      lastFrom, nextGlyph - lastFrom, startPoint); <==================
    403 }
   190 void Font::drawGlyphs(GraphicsContext* gc, const SimpleFontData* font,
    191                       const GlyphBuffer& glyphBuffer,  int from, int numGlyphs,
    192                       const FloatPoint& point) const
    193 {
    194     // compile-time assert
    195     SkASSERT(sizeof(GlyphBufferGlyph) == sizeof(uint16_t));
    196 
    197     if (numGlyphs == 1 && glyphBuffer.glyphAt(from) == 0x3) {
    198         // Webkit likes to draw end text control command for some reason
    199         // Just ignore it
    200         return;
    201     }
    202 
    203     SkPaint paint;
    204     if (!setupForText(&paint, gc, font)) { <===============
    205         return;
    206     }