本文整理汇总了C++中TextRun类的典型用法代码示例。如果您正苦于以下问题:C++ TextRun类的具体用法?C++ TextRun怎么用?C++ TextRun使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextRun类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
void GraphicsContext::drawBidiText(const Font& font, const TextRun& run, const FloatPoint& point, Font::CustomFontNotReadyAction customFontNotReadyAction)
{
if (paintingDisabled())
return;
BidiResolver<TextRunIterator, BidiCharacterRun> bidiResolver;
bidiResolver.setStatus(BidiStatus(run.direction(), run.directionalOverride()));
bidiResolver.setPositionIgnoringNestedIsolates(TextRunIterator(&run, 0));
// FIXME: This ownership should be reversed. We should pass BidiRunList
// to BidiResolver in createBidiRunsForLine.
BidiRunList<BidiCharacterRun>& bidiRuns = bidiResolver.runs();
bidiResolver.createBidiRunsForLine(TextRunIterator(&run, run.length()));
if (!bidiRuns.runCount())
return;
FloatPoint currPoint = point;
BidiCharacterRun* bidiRun = bidiRuns.firstRun();
while (bidiRun) {
TextRun subrun = run.subRun(bidiRun->start(), bidiRun->stop() - bidiRun->start());
bool isRTL = bidiRun->level() % 2;
subrun.setDirection(isRTL ? RTL : LTR);
subrun.setDirectionalOverride(bidiRun->dirOverride(false));
font.drawText(this, subrun, currPoint, 0, -1, customFontNotReadyAction);
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.width(subrun), 0);
}
bidiRuns.deleteRuns();
}
示例2: setupForTextPainting
void Font::drawComplexText(GraphicsContext* gc, const TextRun& run,
const FloatPoint& point, int from, int to) const
{
if (!run.length())
return;
SkCanvas* canvas = gc->platformContext()->canvas();
int textMode = gc->platformContext()->getTextDrawingMode();
bool fill = textMode & cTextFill;
bool stroke = (textMode & cTextStroke)
&& gc->platformContext()->getStrokeStyle() != NoStroke
&& gc->platformContext()->getStrokeThickness() > 0;
if (!fill && !stroke)
return;
SkPaint strokePaint, fillPaint;
if (fill) {
gc->platformContext()->setupPaintForFilling(&fillPaint);
setupForTextPainting(&fillPaint, gc->fillColor().rgb());
}
if (stroke) {
gc->platformContext()->setupPaintForStroking(&strokePaint, 0, 0);
setupForTextPainting(&strokePaint, gc->strokeColor().rgb());
}
TextRunWalker walker(run, point.x(), this);
walker.setWordSpacingAdjustment(wordSpacing());
walker.setLetterSpacingAdjustment(letterSpacing());
walker.setPadding(run.padding());
while (walker.nextScriptRun()) {
if (fill) {
walker.fontPlatformDataForScriptRun()->setupPaint(&fillPaint);
adjustTextRenderMode(&fillPaint, gc->platformContext());
canvas->drawPosTextH(walker.glyphs(), walker.length() << 1, walker.xPositions(), point.y(), fillPaint);
}
if (stroke) {
walker.fontPlatformDataForScriptRun()->setupPaint(&strokePaint);
adjustTextRenderMode(&strokePaint, gc->platformContext());
canvas->drawPosTextH(walker.glyphs(), walker.length() << 1, walker.xPositions(), point.y(), strokePaint);
}
}
}
示例3: selectionRectForComplexText
FloatRect Font::selectionRectForComplexText(const TextRun& run, const FloatPoint& point, int h,
int from, int to) const
{
UniscribeController it(this, run);
it.advance(from);
float beforeWidth = it.runWidthSoFar();
it.advance(to);
float afterWidth = it.runWidthSoFar();
// Using roundf() rather than ceilf() for the right edge as a compromise to ensure correct caret positioning
if (run.rtl()) {
it.advance(run.length());
float totalWidth = it.runWidthSoFar();
return FloatRect(point.x() + floorf(totalWidth - afterWidth), point.y(), roundf(totalWidth - beforeWidth) - floorf(totalWidth - afterWidth), h);
}
return FloatRect(point.x() + floorf(beforeWidth), point.y(), roundf(afterWidth) - floorf(beforeWidth), h);
}
示例4: isOneLeftToRightRun
static bool isOneLeftToRightRun(const TextRun& run)
{
for (int i = 0; i < run.length(); i++) {
WTF::Unicode::Direction direction = WTF::Unicode::direction(run[i]);
if (direction == WTF::Unicode::RightToLeft || direction > WTF::Unicode::OtherNeutral)
return false;
}
return true;
}
示例5: selectionRectForComplexText
// Return the rectangle for selecting the given range of code-points in the TextRun.
FloatRect Font::selectionRectForComplexText(const TextRun& run,
const FloatPoint& point, int height,
int from, int to) const
{
ComplexTextController controller(this, run, 0, 0);
if (run.rtl())
controller.setupForRTL();
return controller.selectionRect(point, height, from, to);
}
示例6: selectionRectForSimpleText
FloatRect Font::selectionRectForSimpleText(const TextRun& run, const FloatPoint& point, int h, int from, int to) const
{
GlyphBuffer glyphBuffer;
WidthIterator it(this, run);
it.advance(from, &glyphBuffer);
float beforeWidth = it.m_runWidthSoFar;
it.advance(to, &glyphBuffer);
float afterWidth = it.m_runWidthSoFar;
// Using roundf() rather than ceilf() for the right edge as a compromise to ensure correct caret positioning.
if (run.rtl()) {
it.advance(run.length(), &glyphBuffer);
float totalWidth = it.m_runWidthSoFar;
return FloatRect(floorf(point.x() + totalWidth - afterWidth), point.y(), roundf(point.x() + totalWidth - beforeWidth) - floorf(point.x() + totalWidth - afterWidth), h);
}
return FloatRect(floorf(point.x() + beforeWidth), point.y(), roundf(point.x() + afterWidth) - floorf(point.x() + beforeWidth), h);
}
示例7: drawComplexText
void Font::drawComplexText(GraphicsContext* gc, TextRun const& run,
FloatPoint const& point, int, int) const
{
SkCanvas* canvas = gc->platformContext()->mCanvas;
SkPaint paint;
if (!setupForText(&paint, gc, primaryFont())) {
return;
}
// go to chars, instead of glyphs, which was set by setupForText()
paint.setTextEncoding(SkPaint::kUTF16_TextEncoding);
canvas->drawText(run.characters(), run.length() << 1,
SkFloatToScalar(point.x()), SkFloatToScalar(point.y()),
paint);
}
示例8: selectionRectForText
FloatRect Font::selectionRectForText(const TextRun& run, const FloatPoint& point, int h, int from, int to) const
{
to = (to == -1 ? run.length() : to);
if (codePath(run) != Complex)
return selectionRectForSimpleText(run, point, h, from, to);
return selectionRectForComplexText(run, point, h, from, to);
}
示例9: drawEmphasisMarks
void Font::drawEmphasisMarks(GraphicsContext* context, const TextRun& run, const AtomicString& mark, const FloatPoint& point, int from, int to) const
{
if (loadingCustomFonts())
return;
if (to < 0)
to = run.length();
CodePath codePathToUse = codePath(run);
// FIXME: Use the fast code path once it handles partial runs with kerning and ligatures. See http://webkit.org/b/100050
if (codePathToUse != Complex && typesettingFeatures() && (from || to != run.length()))
codePathToUse = Complex;
if (codePathToUse != Complex)
drawEmphasisMarksForSimpleText(context, run, mark, point, from, to);
else
drawEmphasisMarksForComplexText(context, run, mark, point, from, to);
}
示例10: getCharacterRange
CharacterRange CachingWordShaper::getCharacterRange(const Font* font,
const TextRun& run, unsigned from, unsigned to)
{
ShapeResultBuffer buffer;
float totalWidth = shapeResultsForRun(m_shapeCache, font, run, nullptr,
&buffer);
return buffer.getCharacterRange(run.direction(), totalWidth, from, to);
}
示例11: drawText
void Font::drawText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
{
// Don't draw anything while we are using custom fonts that are in the process of loading.
if (loadingCustomFonts())
return;
to = (to == -1 ? run.length() : to);
CodePath codePathToUse = codePath(run);
// FIXME: Use the fast code path once it handles partial runs with kerning and ligatures. See http://webkit.org/b/100050
if (codePathToUse != Complex && typesettingFeatures() && (from || to != run.length()))
codePathToUse = Complex;
if (codePathToUse != Complex)
return drawSimpleText(context, run, point, from, to);
return drawComplexText(context, run, point, from, to);
}
示例12: copyTextRunTo
void copyTextRunTo(const TextRun& run, UChar *word)
{
int word_size = run.length() - run.from(), j = 0;
for (int i = run.from(); i < run.length(); i++)
{
if (Font::treatAsSpace(run[i]))
{
word[j] = ' ';
j++;
}
else
{
word[j] = run[i];
j++;
}
}
word[j]='\0';
}
示例13: isOneLeftToRightRun
static bool isOneLeftToRightRun(const TextRun& run)
{
for (int i = 0; i < run.length(); i++) {
UCharDirection direction = u_charDirection(run[i]);
if (direction == U_RIGHT_TO_LEFT || direction > U_OTHER_NEUTRAL)
return false;
}
return true;
}
示例14: constructTextRun
TextRun constructTextRun(const Font& font,
const LineLayoutText text,
unsigned offset,
unsigned length,
const ComputedStyle& style) {
ASSERT(offset + length <= text.textLength());
if (text.hasEmptyText())
return constructTextRunInternal(font, static_cast<const LChar*>(nullptr), 0,
style, LTR);
if (text.is8Bit())
return constructTextRunInternal(font, text.characters8() + offset, length,
style, LTR);
TextRun run = constructTextRunInternal(font, text.characters16() + offset,
length, style, LTR);
run.setDirection(directionForRun(run));
return run;
}
示例15: applySpacing
void ShapeResult::applySpacing(ShapeResultSpacing& spacing,
const TextRun& textRun) {
float offsetX, offsetY;
float& offset = spacing.isVerticalOffset() ? offsetY : offsetX;
float totalSpace = 0;
for (auto& run : m_runs) {
if (!run)
continue;
float totalSpaceForRun = 0;
for (size_t i = 0; i < run->m_glyphData.size(); i++) {
HarfBuzzRunGlyphData& glyphData = run->m_glyphData[i];
// Skip if it's not a grapheme cluster boundary.
if (i + 1 < run->m_glyphData.size() &&
glyphData.characterIndex == run->m_glyphData[i + 1].characterIndex) {
// In RTL, marks need the same letter-spacing offset as the base.
if (textRun.rtl() && spacing.letterSpacing()) {
offsetX = offsetY = 0;
offset = spacing.letterSpacing();
glyphData.offset.expand(offsetX, offsetY);
}
} else {
offsetX = offsetY = 0;
float space = spacing.computeSpacing(
textRun, run->m_startIndex + glyphData.characterIndex, offset);
glyphData.advance += space;
totalSpaceForRun += space;
if (textRun.rtl()) {
// In RTL, spacing should be added to left side of glyphs.
offset += space;
}
glyphData.offset.expand(offsetX, offsetY);
}
m_hasVerticalOffsets |= (glyphData.offset.height() != 0);
}
run->m_width += totalSpaceForRun;
totalSpace += totalSpaceForRun;
}
m_width += totalSpace;
if (spacing.isVerticalOffset())
m_glyphBoundingBox.setHeight(m_glyphBoundingBox.height() + totalSpace);
else
m_glyphBoundingBox.setWidth(m_glyphBoundingBox.width() + totalSpace);
}