コード例 #1
0
ファイル: GlyphBufferTest.cpp プロジェクト: ollie314/chromium
TEST(GlyphBufferTest, ReverseForSimpleRTL) {
  RefPtr<SimpleFontData> font1 = TestSimpleFontData::create();
  RefPtr<SimpleFontData> font2 = TestSimpleFontData::create();

  GlyphBuffer glyphBuffer;
  glyphBuffer.add(42, font1.get(), 10);
  glyphBuffer.add(43, font1.get(), 15);
  glyphBuffer.add(44, font2.get(), 25);

  EXPECT_FALSE(glyphBuffer.isEmpty());
  EXPECT_EQ(3u, glyphBuffer.size());

  glyphBuffer.reverseForSimpleRTL(30, 100);

  EXPECT_FALSE(glyphBuffer.isEmpty());
  EXPECT_EQ(3u, glyphBuffer.size());
  EXPECT_EQ(44, glyphBuffer.glyphAt(0));
  EXPECT_EQ(43, glyphBuffer.glyphAt(1));
  EXPECT_EQ(42, glyphBuffer.glyphAt(2));
  EXPECT_EQ(font2.get(), glyphBuffer.fontDataAt(0));
  EXPECT_EQ(font1.get(), glyphBuffer.fontDataAt(1));
  EXPECT_EQ(font1.get(), glyphBuffer.fontDataAt(2));
  EXPECT_EQ(70, glyphBuffer.xOffsetAt(0));
  EXPECT_EQ(75, glyphBuffer.xOffsetAt(1));
  EXPECT_EQ(85, glyphBuffer.xOffsetAt(2));
}
コード例 #2
0
ファイル: Font.cpp プロジェクト: glenkim-dev/blink-crosswalk
float Font::getGlyphsAndAdvancesForSimpleText(const TextRun& run, int from, int to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const
{
    float initialAdvance;

    WidthIterator it(this, run, 0, false, forTextEmphasis);
    // FIXME: Using separate glyph buffers for the prefix and the suffix is incorrect when kerning or
    // ligatures are enabled.
    GlyphBuffer localGlyphBuffer;
    it.advance(from, &localGlyphBuffer);
    float beforeWidth = it.m_runWidthSoFar;
    it.advance(to, &glyphBuffer);

    if (glyphBuffer.isEmpty())
        return 0;

    float afterWidth = it.m_runWidthSoFar;

    if (run.rtl()) {
        float finalRoundingWidth = it.m_finalRoundingWidth;
        it.advance(run.length(), &localGlyphBuffer);
        initialAdvance = finalRoundingWidth + it.m_runWidthSoFar - afterWidth;
    } else {
        initialAdvance = beforeWidth;
    }

    if (run.rtl())
        glyphBuffer.reverse(0, glyphBuffer.size());

    return initialAdvance;
}
コード例 #3
0
ファイル: Font.cpp プロジェクト: Chingliu/EAWebkit
void Font::drawSimpleText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
{
    // This glyph buffer holds our glyphs+advances+font data for each glyph.
    GlyphBuffer glyphBuffer;

    float startX = point.x();
    WidthIterator it(this, run);
    it.advance(from);
    float beforeWidth = it.m_runWidthSoFar;
    it.advance(to, &glyphBuffer);
    
    // We couldn't generate any glyphs for the run.  Give up.
    if (glyphBuffer.isEmpty())
        return;
    
    float afterWidth = it.m_runWidthSoFar;

    if (run.rtl()) {
        float finalRoundingWidth = it.m_finalRoundingWidth;
        it.advance(run.length());
        startX += finalRoundingWidth + it.m_runWidthSoFar - afterWidth;
    } else
        startX += beforeWidth;

    // Swap the order of the glyphs if right-to-left.
    if (run.rtl())
        for (int i = 0, end = glyphBuffer.size() - 1; i < glyphBuffer.size() / 2; ++i, --end)
            glyphBuffer.swap(i, end);

    // Calculate the starting point of the glyphs to be displayed by adding
    // all the advances up to the first glyph.
    FloatPoint startPoint(startX, point.y());
    drawGlyphBuffer(context, glyphBuffer, run, startPoint);
}
コード例 #4
0
ファイル: GlyphBufferTest.cpp プロジェクト: ollie314/chromium
TEST(GlyphBufferTest, StoresVerticalOffsets) {
  RefPtr<SimpleFontData> font1 = TestSimpleFontData::create();
  RefPtr<SimpleFontData> font2 = TestSimpleFontData::create();

  GlyphBuffer glyphBuffer;
  EXPECT_FALSE(glyphBuffer.hasVerticalOffsets());

  glyphBuffer.add(42, font1.get(), FloatPoint(10, 0));
  glyphBuffer.add(43, font1.get(), FloatPoint(15, 0));
  glyphBuffer.add(44, font2.get(), FloatPoint(12, 2));

  EXPECT_FALSE(glyphBuffer.isEmpty());
  EXPECT_TRUE(glyphBuffer.hasVerticalOffsets());
  EXPECT_EQ(3u, glyphBuffer.size());

  const float* offsets = glyphBuffer.offsets(0);
  EXPECT_EQ(10, glyphBuffer.xOffsetAt(0));
  EXPECT_EQ(0, glyphBuffer.yOffsetAt(0));
  EXPECT_EQ(15, glyphBuffer.xOffsetAt(1));
  EXPECT_EQ(0, glyphBuffer.yOffsetAt(1));
  EXPECT_EQ(12, glyphBuffer.xOffsetAt(2));
  EXPECT_EQ(2, glyphBuffer.yOffsetAt(2));

  EXPECT_EQ(10, offsets[0]);
  EXPECT_EQ(0, offsets[1]);
  EXPECT_EQ(15, offsets[2]);
  EXPECT_EQ(0, offsets[3]);
  EXPECT_EQ(12, offsets[4]);
  EXPECT_EQ(2, offsets[5]);
}
コード例 #5
0
float Font::getGlyphsAndAdvancesForSimpleText(const TextRun& run, int from, int to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const
{
    float initialAdvance;

    WidthIterator it(this, run, 0, false, forTextEmphasis);
    it.advance(from);
    float beforeWidth = it.m_runWidthSoFar;
    it.advance(to, &glyphBuffer);

    if (glyphBuffer.isEmpty())
        return 0;

    float afterWidth = it.m_runWidthSoFar;

    if (run.rtl()) {
        it.advance(run.length());
        initialAdvance = it.m_runWidthSoFar - afterWidth;
    } else
        initialAdvance = beforeWidth;

    if (run.rtl()) {
        for (int i = 0, end = glyphBuffer.size() - 1; i < glyphBuffer.size() / 2; ++i, --end)
            glyphBuffer.swap(i, end);
    }

    return initialAdvance;
}
コード例 #6
0
void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
{
#if PLATFORM(CHROMIUM)
    if (preferHarfBuzz(this)) {
        GlyphBuffer glyphBuffer;
        HarfBuzzShaper shaper(this, run);
        shaper.setDrawRange(from, to);
        if (shaper.shape(&glyphBuffer)) {
            drawGlyphBuffer(context, run, glyphBuffer, point);
            return;
        }
    }
#endif
    // This glyph buffer holds our glyphs + advances + font data for each glyph.
    GlyphBuffer glyphBuffer;

    float startX = point.x() + getGlyphsAndAdvancesForComplexText(run, from, to, glyphBuffer);

    // We couldn't generate any glyphs for the run.  Give up.
    if (glyphBuffer.isEmpty())
        return;

    // Draw the glyph buffer now at the starting point returned in startX.
    FloatPoint startPoint(startX, point.y());
    drawGlyphBuffer(context, run, glyphBuffer, startPoint);
}
コード例 #7
0
ファイル: FontMacCoreText.cpp プロジェクト: acss/owb-mirror
void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point,
                           int from, int to) const
{
    // This glyph buffer holds our glyphs + advances + font data for each glyph.
    GlyphBuffer glyphBuffer;

    float startX = point.x();
    CoreTextController controller(this, run);
    controller.advance(from);
    float beforeWidth = controller.runWidthSoFar();
    controller.advance(to, &glyphBuffer);
    
    // We couldn't generate any glyphs for the run.  Give up.
    if (glyphBuffer.isEmpty())
        return;
    
    float afterWidth = controller.runWidthSoFar();

    if (run.rtl()) {
        startX += controller.totalWidth() + controller.finalRoundingWidth() - afterWidth;
        for (int i = 0, end = glyphBuffer.size() - 1; i < glyphBuffer.size() / 2; ++i, --end)
            glyphBuffer.swap(i, end);
    } else
        startX += beforeWidth;

    // Draw the glyph buffer now at the starting point returned in startX.
    FloatPoint startPoint(startX, point.y());
    drawGlyphBuffer(context, glyphBuffer, run, startPoint);
}
コード例 #8
0
float Font::getGlyphsAndAdvancesForSimpleText(const TextRun& run, int from, int to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const
{
    WidthIterator it(this, run, 0, false, forTextEmphasis);
    GlyphBuffer localGlyphBuffer;
    it.advance(run.length(), &localGlyphBuffer);

    if (localGlyphBuffer.isEmpty())
        return 0;

    float totalWidth = it.m_runWidthSoFar;
    float beforeWidth = 0;
    int glyphPos = 0;
    for (; glyphPos < localGlyphBuffer.size() && it.m_characterIndexOfGlyph[glyphPos] < from; ++glyphPos)
        beforeWidth += localGlyphBuffer.advanceAt(glyphPos).width();
    int glyphFrom = glyphPos;

    float afterWidth = totalWidth;
    glyphPos = localGlyphBuffer.size() - 1;
    for (; glyphPos >= glyphFrom && it.m_characterIndexOfGlyph[glyphPos] >= to; --glyphPos)
        afterWidth -= localGlyphBuffer.advanceAt(glyphPos).width();
    int glyphTo = glyphPos + 1;

    glyphBuffer.add(&localGlyphBuffer, glyphFrom, glyphTo - glyphFrom);

    if (run.rtl()) {
        glyphBuffer.reverse(0, glyphBuffer.size());
        return totalWidth - afterWidth;
    }

    return beforeWidth;
}
コード例 #9
0
ファイル: FontWx.cpp プロジェクト: 325116067/semc-qsd8x50
void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
{
#if OS(WINDOWS)
    // This glyph buffer holds our glyphs + advances + font data for each glyph.
    GlyphBuffer glyphBuffer;

    float startX = point.x();
    UniscribeController controller(this, run);
    controller.advance(from);
    float beforeWidth = controller.runWidthSoFar();
    controller.advance(to, &glyphBuffer);
    
    // We couldn't generate any glyphs for the run.  Give up.
    if (glyphBuffer.isEmpty())
        return;
    
    float afterWidth = controller.runWidthSoFar();

    if (run.rtl()) {
        controller.advance(run.length());
        startX += controller.runWidthSoFar() - afterWidth;
    } else
        startX += beforeWidth;

    // Draw the glyph buffer now at the starting point returned in startX.
    FloatPoint startPoint(startX, point.y());
    drawGlyphBuffer(context, glyphBuffer, run, startPoint);
#else
    notImplemented();
#endif
}
コード例 #10
0
float SVGTextRunRenderingContext::floatWidthUsingSVGFont(const Font& font, const TextRun& run, int& charsConsumed, Glyph& glyphId) const
{
    WidthIterator it(&font, run);
    GlyphBuffer glyphBuffer;
    charsConsumed += it.advance(run.length(), &glyphBuffer);
    glyphId = !glyphBuffer.isEmpty() ? glyphBuffer.glyphAt(0) : 0;
    return it.runWidthSoFar();
}
コード例 #11
0
ファイル: FontComplexTextMac.cpp プロジェクト: Igalia/blink
void Font::drawEmphasisMarksForComplexText(GraphicsContext* context, const TextRunPaintInfo& runInfo, const AtomicString& mark, const FloatPoint& point) const
{
    GlyphBuffer glyphBuffer;
    float initialAdvance = getGlyphsAndAdvancesForComplexText(runInfo.run, runInfo.from, runInfo.to, glyphBuffer, ForTextEmphasis);

    if (glyphBuffer.isEmpty())
        return;

    drawEmphasisMarks(context, runInfo, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y()));
}
コード例 #12
0
void Font::drawEmphasisMarksForSimpleText(GraphicsContext* context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, int from, int to) const
{
    GlyphBuffer glyphBuffer;
    float initialAdvance = getGlyphsAndAdvancesForSimpleText(run, from, to, glyphBuffer, ForTextEmphasis);

    if (glyphBuffer.isEmpty())
        return;

    drawEmphasisMarks(context, run, glyphBuffer, mark, FloatPoint(point.x() + initialAdvance, point.y()));
}
コード例 #13
0
ファイル: Font.cpp プロジェクト: glenkim-dev/blink-crosswalk
void Font::drawSimpleText(GraphicsContext* context, const TextRunPaintInfo& runInfo, const FloatPoint& point) const
{
    // This glyph buffer holds our glyphs+advances+font data for each glyph.
    GlyphBuffer glyphBuffer;

    float startX = point.x() + getGlyphsAndAdvancesForSimpleText(runInfo.run, runInfo.from, runInfo.to, glyphBuffer);

    if (glyphBuffer.isEmpty())
        return;

    FloatPoint startPoint(startX, point.y());
    drawGlyphBuffer(context, runInfo, glyphBuffer, startPoint);
}
コード例 #14
0
ファイル: FontComplexTextMac.cpp プロジェクト: 13W/phantomjs
void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
{
    // This glyph buffer holds our glyphs + advances + font data for each glyph.
    GlyphBuffer glyphBuffer;

    float startX = point.x() + getGlyphsAndAdvancesForComplexText(run, from, to, glyphBuffer);

    // We couldn't generate any glyphs for the run.  Give up.
    if (glyphBuffer.isEmpty())
        return;

    // Draw the glyph buffer now at the starting point returned in startX.
    FloatPoint startPoint(startX, point.y());
    drawGlyphBuffer(context, glyphBuffer, startPoint);
}
コード例 #15
0
float Font::drawSimpleText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
{
    // This glyph buffer holds our glyphs+advances+font data for each glyph.
    GlyphBuffer glyphBuffer;

    float startX = point.x() + getGlyphsAndAdvancesForSimpleText(run, from, to, glyphBuffer);

    if (glyphBuffer.isEmpty())
        return 0;

    FloatPoint startPoint(startX, point.y());
    drawGlyphBuffer(context, run, glyphBuffer, startPoint);

    return startPoint.x() - startX;
}
コード例 #16
0
ファイル: GlyphBufferTest.cpp プロジェクト: ollie314/chromium
TEST(GlyphBufferTest, OffsetArrayWithNonZeroIndex) {
  RefPtr<SimpleFontData> font1 = TestSimpleFontData::create();
  RefPtr<SimpleFontData> font2 = TestSimpleFontData::create();

  {
    GlyphBuffer glyphBuffer;
    glyphBuffer.add(42, font1.get(), 10);
    glyphBuffer.add(43, font1.get(), 15);
    glyphBuffer.add(43, font2.get(), 12);

    EXPECT_FALSE(glyphBuffer.isEmpty());
    EXPECT_FALSE(glyphBuffer.hasVerticalOffsets());
    EXPECT_EQ(3u, glyphBuffer.size());

    const float* offsets = glyphBuffer.offsets(1);
    EXPECT_EQ(15, offsets[0]);
    EXPECT_EQ(12, offsets[1]);
  }

  {
    GlyphBuffer glyphBuffer;
    glyphBuffer.add(42, font1.get(), FloatPoint(10, 0));
    glyphBuffer.add(43, font1.get(), FloatPoint(15, 0));
    glyphBuffer.add(43, font2.get(), FloatPoint(12, 2));

    EXPECT_FALSE(glyphBuffer.isEmpty());
    EXPECT_TRUE(glyphBuffer.hasVerticalOffsets());
    EXPECT_EQ(3u, glyphBuffer.size());

    const float* offsets = glyphBuffer.offsets(1);
    EXPECT_EQ(15, offsets[0]);
    EXPECT_EQ(0, offsets[1]);
    EXPECT_EQ(12, offsets[2]);
    EXPECT_EQ(2, offsets[3]);
  }
}
コード例 #17
0
ファイル: GlyphBufferTest.cpp プロジェクト: ollie314/chromium
TEST(GlyphBufferTest, StoresSimpleFontData) {
  RefPtr<SimpleFontData> font1 = TestSimpleFontData::create();
  RefPtr<SimpleFontData> font2 = TestSimpleFontData::create();

  GlyphBuffer glyphBuffer;
  glyphBuffer.add(42, font1.get(), 10);
  glyphBuffer.add(43, font1.get(), 15);
  glyphBuffer.add(44, font2.get(), 12);

  EXPECT_FALSE(glyphBuffer.isEmpty());
  EXPECT_EQ(3u, glyphBuffer.size());

  EXPECT_EQ(font1.get(), glyphBuffer.fontDataAt(0));
  EXPECT_EQ(font1.get(), glyphBuffer.fontDataAt(1));
  EXPECT_EQ(font2.get(), glyphBuffer.fontDataAt(2));
}
コード例 #18
0
ファイル: GlyphBufferTest.cpp プロジェクト: ollie314/chromium
TEST(GlyphBufferTest, GlyphArrayWithOffset) {
  RefPtr<SimpleFontData> font1 = TestSimpleFontData::create();
  RefPtr<SimpleFontData> font2 = TestSimpleFontData::create();

  GlyphBuffer glyphBuffer;
  glyphBuffer.add(42, font1.get(), 10);
  glyphBuffer.add(43, font1.get(), 15);
  glyphBuffer.add(44, font2.get(), 12);

  EXPECT_FALSE(glyphBuffer.isEmpty());
  EXPECT_EQ(3u, glyphBuffer.size());

  const Glyph* glyphs = glyphBuffer.glyphs(1);
  EXPECT_EQ(43, glyphs[0]);
  EXPECT_EQ(44, glyphs[1]);
}
コード例 #19
0
ファイル: FontHarfBuzz.cpp プロジェクト: ewilligers/blink
void Font::drawComplexText(GraphicsContext* gc, const TextRunPaintInfo& runInfo, const FloatPoint& point) const
{
    if (!runInfo.run.length())
        return;

    TextDrawingModeFlags textMode = gc->textDrawingMode();
    bool fill = textMode & TextModeFill;
    bool stroke = (textMode & TextModeStroke) && gc->hasStroke();

    if (!fill && !stroke)
        return;

    GlyphBuffer glyphBuffer;
    HarfBuzzShaper shaper(this, runInfo.run);
    shaper.setDrawRange(runInfo.from, runInfo.to);
    if (!shaper.shape(&glyphBuffer) || glyphBuffer.isEmpty())
        return;
    FloatPoint adjustedPoint = shaper.adjustStartPoint(point);
    drawGlyphBuffer(gc, runInfo, glyphBuffer, adjustedPoint);
}
コード例 #20
0
void Font::drawSimpleText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
{
    // This glyph buffer holds our glyphs+advances+font data for each glyph.
    GlyphBuffer glyphBuffer;
//SAMSUNG CHANGES>>
    //if Point has high negative value, SKIA is not handling, so handle here
    WidthIterator it(this, run, 0, false, 0);
    it.advance(from);
    float Width = it.m_runWidthSoFar;
    if(point.x() + Width < -9999)
    	return;
//SAMSUNG CHANGES<<     

    float startX = point.x() + getGlyphsAndAdvancesForSimpleText(run, from, to, glyphBuffer);

    if (glyphBuffer.isEmpty())
        return;

    FloatPoint startPoint(startX, point.y());
    drawGlyphBuffer(context, glyphBuffer, startPoint);
}
コード例 #21
0
float Font::getGlyphsAndAdvancesForComplexText(const TextRun& run, int from, int to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const
{
    float initialAdvance;

    ComplexTextController controller(this, run, false, 0, forTextEmphasis);
    controller.advance(from);
    float beforeWidth = controller.runWidthSoFar();
    controller.advance(to, &glyphBuffer);

    if (glyphBuffer.isEmpty())
        return 0;

    float afterWidth = controller.runWidthSoFar();

    if (run.rtl()) {
        initialAdvance = controller.totalWidth() + controller.finalRoundingWidth() - afterWidth;
        glyphBuffer.reverse(0, glyphBuffer.size());
    } else
        initialAdvance = beforeWidth;

    return initialAdvance;
}
コード例 #22
0
ファイル: GlyphBufferTest.cpp プロジェクト: ollie314/chromium
TEST(GlyphBufferTest, StoresGlyphs) {
  RefPtr<SimpleFontData> font1 = TestSimpleFontData::create();
  RefPtr<SimpleFontData> font2 = TestSimpleFontData::create();

  GlyphBuffer glyphBuffer;
  glyphBuffer.add(42, font1.get(), 10);
  glyphBuffer.add(43, font1.get(), 15);
  glyphBuffer.add(44, font2.get(), 22);

  EXPECT_FALSE(glyphBuffer.isEmpty());
  EXPECT_FALSE(glyphBuffer.hasVerticalOffsets());
  EXPECT_EQ(3u, glyphBuffer.size());

  EXPECT_EQ(42, glyphBuffer.glyphAt(0));
  EXPECT_EQ(43, glyphBuffer.glyphAt(1));
  EXPECT_EQ(44, glyphBuffer.glyphAt(2));

  const Glyph* glyphs = glyphBuffer.glyphs(0);
  EXPECT_EQ(42, glyphs[0]);
  EXPECT_EQ(43, glyphs[1]);
  EXPECT_EQ(44, glyphs[2]);
}
コード例 #23
0
ファイル: FontComplexTextMac.cpp プロジェクト: 13W/phantomjs
float Font::getGlyphsAndAdvancesForComplexText(const TextRun& run, int from, int to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const
{
    float initialAdvance;

    ComplexTextController controller(this, run, false, 0, forTextEmphasis);
    controller.advance(from);
    float beforeWidth = controller.runWidthSoFar();
    controller.advance(to, &glyphBuffer);

    if (glyphBuffer.isEmpty())
        return 0;

    float afterWidth = controller.runWidthSoFar();

    if (run.rtl()) {
        initialAdvance = controller.totalWidth() - afterWidth;
        for (int i = 0, end = glyphBuffer.size() - 1; i < glyphBuffer.size() / 2; ++i, --end)
            glyphBuffer.swap(i, end);
    } else
        initialAdvance = beforeWidth;

    return initialAdvance;
}
コード例 #24
0
ファイル: FontWin.cpp プロジェクト: Anthony-Biget/openjfx
float Font::getGlyphsAndAdvancesForComplexText(const TextRun& run, int from, int to, GlyphBuffer& glyphBuffer, ForTextEmphasisOrNot forTextEmphasis) const
{
    if (forTextEmphasis) {
        // FIXME: Add forTextEmphasis paremeter to UniscribeController and use it.
        LOG_ERROR("Not implemented for text emphasis.");
        return 0;
    }

    UniscribeController controller(this, run);
    controller.advance(from);
    float beforeWidth = controller.runWidthSoFar();
    controller.advance(to, &glyphBuffer);

    if (glyphBuffer.isEmpty())
        return 0;

    float afterWidth = controller.runWidthSoFar();

    if (run.rtl()) {
        controller.advance(run.length());
        return controller.runWidthSoFar() - afterWidth;
    }
    return beforeWidth;
}
コード例 #25
0
ファイル: GlyphBufferTest.cpp プロジェクト: ollie314/chromium
TEST(GlyphBufferTest, StartsEmpty) {
  GlyphBuffer glyphBuffer;
  EXPECT_TRUE(glyphBuffer.isEmpty());
  EXPECT_EQ(0u, glyphBuffer.size());
}