本文整理汇总了C++中TextRun::ltr方法的典型用法代码示例。如果您正苦于以下问题:C++ TextRun::ltr方法的具体用法?C++ TextRun::ltr怎么用?C++ TextRun::ltr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextRun
的用法示例。
在下文中一共展示了TextRun::ltr方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: drawBidiText
void GraphicsContext::drawBidiText(const Font& font, const TextRun& run, const FloatPoint& point)
{
if (paintingDisabled())
return;
BidiResolver<TextRunIterator, BidiCharacterRun> bidiResolver;
WTF::Unicode::Direction paragraphDirection = run.ltr() ? WTF::Unicode::LeftToRight : WTF::Unicode::RightToLeft;
bidiResolver.setStatus(BidiStatus(paragraphDirection, paragraphDirection, paragraphDirection, new BidiContext(run.ltr() ? 0 : 1, paragraphDirection, run.directionalOverride())));
bidiResolver.setPosition(TextRunIterator(&run, 0));
bidiResolver.createBidiRunsForLine(TextRunIterator(&run, run.length()));
if (!bidiResolver.runCount())
return;
FloatPoint currPoint = point;
BidiCharacterRun* bidiRun = bidiResolver.firstRun();
while (bidiRun) {
TextRun subrun = run;
subrun.setText(run.data(bidiRun->start()), bidiRun->stop() - bidiRun->start());
subrun.setRTL(bidiRun->level() % 2);
subrun.setDirectionalOverride(bidiRun->dirOverride(false));
font.drawText(this, subrun, currPoint);
bidiRun = bidiRun->next();
// FIXME: Have Font::drawText return the width of what it drew so that we don't have to re-measure here.
if (bidiRun)
currPoint.move(font.floatWidth(subrun), 0.f);
}
bidiResolver.deleteRuns();
}
示例2: selectionRectForComplexText
FloatRect Font::selectionRectForComplexText(const TextRun& run, const FloatPoint& point, int h, int from, int to) const
{
#if USE(FREETYPE)
if (!primaryFont()->platformData().m_pattern)
return selectionRectForSimpleText(run, point, h, from, to);
#endif
PangoLayout* layout = getDefaultPangoLayout(run);
setPangoAttributes(this, run, layout);
gchar* utf8 = convertUniCharToUTF8(run.characters(), run.length(), 0, run.length());
pango_layout_set_text(layout, utf8, -1);
char* start = g_utf8_offset_to_pointer(utf8, from);
char* end = g_utf8_offset_to_pointer(start, to - from);
if (run.ltr()) {
from = start - utf8;
to = end - utf8;
} else {
from = end - utf8;
to = start - utf8;
}
PangoLayoutLine* layoutLine = pango_layout_get_line_readonly(layout, 0);
int xPos;
xPos = 0;
if (from < layoutLine->length)
pango_layout_line_index_to_x(layoutLine, from, FALSE, &xPos);
float beforeWidth = PANGO_PIXELS_FLOOR(xPos);
xPos = 0;
if (run.ltr() || to < layoutLine->length)
pango_layout_line_index_to_x(layoutLine, to, FALSE, &xPos);
float afterWidth = PANGO_PIXELS(xPos);
g_free(utf8);
g_object_unref(layout);
return FloatRect(point.x() + beforeWidth, point.y(), afterWidth - beforeWidth, h);
}
示例3: paintSelection
void EllipsisBox::paintSelection(GraphicsContext& context, const LayoutPoint& paintOffset, const RenderStyle& style, const FontCascade& font)
{
Color textColor = style.visitedDependentColor(CSSPropertyColor);
Color c = blockFlow().selectionBackgroundColor();
if (!c.isValid() || !c.alpha())
return;
// If the text color ends up being the same as the selection background, invert the selection
// background.
if (textColor == c)
c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue());
const RootInlineBox& rootBox = root();
GraphicsContextStateSaver stateSaver(context);
// FIXME: Why is this always LTR? Fix by passing correct text run flags below.
LayoutRect selectionRect = LayoutRect(x() + paintOffset.x(), y() + paintOffset.y() + rootBox.selectionTop(), 0, rootBox.selectionHeight());
TextRun run = RenderBlock::constructTextRun(&blockFlow(), font, m_str, style, AllowTrailingExpansion);
font.adjustSelectionRectForText(run, selectionRect, 0, -1);
context.fillRect(snapRectToDevicePixelsWithWritingDirection(selectionRect, renderer().document().deviceScaleFactor(), run.ltr()), c);
}
示例4: selectionRectForTextFragment
FloatRect SVGInlineTextBox::selectionRectForTextFragment(const SVGTextFragment& fragment, int startPosition, int endPosition, RenderStyle* style) const
{
ASSERT_WITH_SECURITY_IMPLICATION(startPosition < endPosition);
ASSERT(style);
float scalingFactor = renderer().scalingFactor();
ASSERT(scalingFactor);
const FontCascade& scaledFont = renderer().scaledFont();
const FontMetrics& scaledFontMetrics = scaledFont.fontMetrics();
FloatPoint textOrigin(fragment.x, fragment.y);
if (scalingFactor != 1)
textOrigin.scale(scalingFactor, scalingFactor);
textOrigin.move(0, -scaledFontMetrics.floatAscent());
LayoutRect selectionRect = LayoutRect(textOrigin, LayoutSize(0, fragment.height * scalingFactor));
TextRun run = constructTextRun(style, fragment);
scaledFont.adjustSelectionRectForText(run, selectionRect, startPosition, endPosition);
FloatRect snappedSelectionRect = snapRectToDevicePixelsWithWritingDirection(selectionRect, renderer().document().deviceScaleFactor(), run.ltr());
if (scalingFactor == 1)
return snappedSelectionRect;
snappedSelectionRect.scale(1 / scalingFactor);
return snappedSelectionRect;
}