本文整理汇总了C++中TextRun类的典型用法代码示例。如果您正苦于以下问题:C++ TextRun类的具体用法?C++ TextRun怎么用?C++ TextRun使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextRun类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:,项目名称:,代码行数:34,代码来源:
示例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);
}
}
}
开发者ID:azrul2202,项目名称:WebKit-Smartphone,代码行数:45,代码来源:FontLinux.cpp
示例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);
}
开发者ID:Anthony-Biget,项目名称:openjfx,代码行数:18,代码来源:FontWin.cpp
示例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;
}
开发者ID:1833183060,项目名称:wke,代码行数:9,代码来源:WebCoreTextRenderer.cpp
示例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);
}
开发者ID:xiaolu31,项目名称:webkit-node,代码行数:10,代码来源:FontHarfBuzz.cpp
示例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);
}
开发者ID:,项目名称:,代码行数:18,代码来源:
示例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);
}
开发者ID:federivas,项目名称:s6500d_official_platform,代码行数:18,代码来源:FontAndroid.cpp
示例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);
}
开发者ID:bearmingo,项目名称:UI,代码行数:9,代码来源:Font.cpp
示例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);
}
开发者ID:,项目名称:,代码行数:18,代码来源:
示例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);
}
开发者ID:endlessm,项目名称:chromium-browser,代码行数:9,代码来源:CachingWordShaper.cpp
示例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);
}
开发者ID:,项目名称:,代码行数:18,代码来源:
示例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';
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:18,代码来源:BTFont.cpp
示例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;
}
开发者ID:AndriyKalashnykov,项目名称:webkit,代码行数:9,代码来源:WebCoreTextRenderer.cpp
示例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;
}
开发者ID:,项目名称:,代码行数:18,代码来源:
示例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);
}
开发者ID:,项目名称:,代码行数:44,代码来源:
示例16: offsetForPositionForComplexText
int Font::offsetForPositionForComplexText(const TextRun& run, int x, bool includePartialGlyphs) const
{
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);
int index, trailing;
pango_layout_xy_to_index(layout, x * PANGO_SCALE, 1, &index, &trailing);
glong offset = g_utf8_pointer_to_offset(utf8, utf8 + index);
if (includePartialGlyphs)
offset += trailing;
g_free(utf8);
g_object_unref(layout);
return offset;
}
开发者ID:Czerrr,项目名称:ISeeBrowser,代码行数:19,代码来源:FontGtk.cpp
示例17: floatWidthForComplexText
float Font::floatWidthForComplexText(const TextRun& run) const
{
if (run.length() == 0)
return 0.0f;
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);
int width;
pango_layout_get_pixel_size(layout, &width, 0);
g_free(utf8);
g_object_unref(layout);
return width;
}
开发者ID:Czerrr,项目名称:ISeeBrowser,代码行数:19,代码来源:FontGtk.cpp
示例18: floatWidthForComplexText
float Font::floatWidthForComplexText(const TextRun& run, const TextStyle& style) const
{
if (run.length() == 0)
return 0.0f;
PangoLayout* layout = getDefaultPangoLayout(run);
setPangoAttributes(this, run, layout, style.rtl());
gchar* utf8 = convertUniCharToUTF8(run.characters(), run.length(), 0, run.length());
pango_layout_set_text(layout, utf8, -1);
g_free(utf8);
int layoutWidth;
pango_layout_get_size(layout, &layoutWidth, 0);
float width = (float)layoutWidth / (double)PANGO_SCALE;
g_object_unref(layout);
return width;
}
开发者ID:UIKit0,项目名称:WebkitAIR,代码行数:19,代码来源:FontGdkApollo.cpp
示例19: selectionRect
FloatRect CachingWordShaper::selectionRect(const Font* font, const TextRun& run,
const FloatPoint& point, int height, unsigned from, unsigned to)
{
Vector<RefPtr<ShapeResult>> results;
float totalWidth = shapeResultsForRun(m_shapeCache, font, run, nullptr,
&results);
return ShapeResult::selectionRect(results, run.direction(), totalWidth,
point, height, from, to);
}
开发者ID:shaoboyan,项目名称:chromium-crosswalk,代码行数:10,代码来源:CachingWordShaper.cpp
示例20: releasePaintingResource
void SVGInlineTextBox::restoreGraphicsContextAfterTextPainting(GraphicsContext*& context, TextRun& textRun)
{
releasePaintingResource(context, /* path */0);
#if ENABLE(SVG_FONTS)
TextRun::RenderingContext* renderingContext = textRun.renderingContext();
if (renderingContext)
static_cast<SVGTextRunRenderingContext*>(renderingContext)->setActivePaintingResource(0);
#endif
}
开发者ID:glenkim-dev,项目名称:blink-crosswalk,代码行数:10,代码来源:SVGInlineTextBox.cpp
注:本文中的TextRun类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论