本文整理汇总了C++中GlyphBuffer::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ GlyphBuffer::isEmpty方法的具体用法?C++ GlyphBuffer::isEmpty怎么用?C++ GlyphBuffer::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GlyphBuffer
的用法示例。
在下文中一共展示了GlyphBuffer::isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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: getGlyphsAndAdvancesForSimpleText
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: drawSimpleText
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: FloatPoint
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: drawComplexText
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);
}
示例6: drawComplexText
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);
}
示例7: getGlyphsAndAdvancesForSimpleText
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;
}
示例8: drawComplexText
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
}
示例9: floatWidthUsingSVGFont
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();
}
示例10: drawEmphasisMarksForComplexText
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()));
}
示例11: drawEmphasisMarksForSimpleText
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()));
}
示例12: drawSimpleText
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);
}
示例13: drawComplexText
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);
}
示例14: drawSimpleText
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;
}
示例15: drawComplexText
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);
}