当前位置: 首页>>代码示例>>C++>>正文


C++ TextRun::characters方法代码示例

本文整理汇总了C++中TextRun::characters方法的典型用法代码示例。如果您正苦于以下问题:C++ TextRun::characters方法的具体用法?C++ TextRun::characters怎么用?C++ TextRun::characters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TextRun的用法示例。


在下文中一共展示了TextRun::characters方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: selectionRectForComplexText

//SAMSUNG_THAI_EDITING_FIX >>
FloatRect Font::selectionRectForComplexText(const TextRun& run,
                                const IntPoint& point, int h, int from, int to) const
{
    SkPaint              paint;
    SkPaint::FontMetrics metrics;
    float beforeWidth = 0.0f ;
    float afterWidth = 0.0f ;

    primaryFont()->platformData().setupPaint(&paint);

    size_t length = from ;
    if (length > 0) {
        beforeWidth = paint.measureText(run.characters(), length << 1);
    }

    length = to ;
    if (length > 0) {
        afterWidth = paint.measureText(run.characters(), length << 1);
    }

    
    return FloatRect(point.x() + floorf(beforeWidth),
                     point.y(),
                     roundf(afterWidth) - floorf(beforeWidth),
                     roundf(SkScalarToFloat(h)));
}
开发者ID:federivas,项目名称:s6500d_official_platform,代码行数:27,代码来源:FontAndroid.cpp

示例2: selectionRectForComplexText

FloatRect Font::selectionRectForComplexText(const TextRun& run,
                                const IntPoint& point, int h, int from, int to) const
{
    SkPaint              paint;
    SkScalar             width, left;
    SkPaint::FontMetrics metrics;

    primaryFont()->platformData().setupPaint(&paint);

    SkScalar spacing = paint.getFontMetrics(&metrics);

    float beforeWidth = SkScalarToFloat(paint.measureText(run.characters(), from << 1));
    float afterWidth = SkScalarToFloat(paint.measureText(run.characters(), to << 1));

    if (run.rtl()) {
    	float totalWidth = SkScalarToFloat(paint.measureText(run.characters(), run.length() << 1));
    	return FloatRect(point.x() + floorf(totalWidth - afterWidth),
    	                 point.y(),
                         roundf(totalWidth - beforeWidth) - floorf(totalWidth - afterWidth),
    	                 //roundf(SkScalarToFloat(spacing))); // Don't compute rect height, but use h.
                         h);
    } else {
        return FloatRect(point.x() + floorf(beforeWidth),
                         point.y(),
                         roundf(afterWidth) - floorf(beforeWidth),
                         //roundf(SkScalarToFloat(spacing))); // Don't compute rect height, but use h.
                         h);
    }
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:29,代码来源:FontAndroid.cpp

示例3: floatWidthForComplexText

float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>* /* fallbackFonts */) const
{
    void* font = 0;
    float w = 0.f;
    const UChar* str = 0;
    UChar c = 0;
    const SimpleFontData* sfont = primaryFont();
    float scale = 0;
    int i, len;

    if (!sfont) return 0.f;

    len = run.length();
    if (!len) return 0.f;

    str = run.characters();

    font = sfont->platformData().Font();
    if (!font) return 0.f;
    scale = sfont->platformData().scale();

    for (i=0; i<len; i++) {
        c = fixedChar(str[i]);
        if (!c) continue;
        w += (float)wkcFontGetCharWidthPeer(font, c) * scale;
    }

    return w;
}
开发者ID:flying-dutchmen,项目名称:3DS_w3Browser,代码行数:29,代码来源:FontWKC.cpp

示例4: offsetForPositionForComplexText

int Font::offsetForPositionForComplexText(const TextRun& run, int x,
                                          bool includePartialGlyphs) const
{
    SkPaint                         paint;
    int                             count = run.length();
    SkAutoSTMalloc<64, SkScalar>    storage(count);
    SkScalar*                       widths = storage.get();
    SkAutoSTMalloc<64, int>    storageClusterIndex(count);
    int*                       clusterIndex = storageClusterIndex.get();

    primaryFont()->platformData().setupPaint(&paint);

    //count = paint.getTextWidths(run.characters(), count << 1, widths);
    count = paint.getComplexTextWidths(run.characters(), count << 1, widths, clusterIndex);

    if (count > 0)
    {
        SkScalar pos = 0;
        for (int i = 0; i < count; i++)
        {
            if (x < SkScalarRound(pos + SkScalarHalf(widths[i])))
                return clusterIndex[i];
            pos += widths[i];
        }
    }
    return run.length();
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:27,代码来源:FontAndroid.cpp

示例5: offsetForPositionForSimpleText

int Font::offsetForPositionForSimpleText(const TextRun& run, int position, bool includePartialGlyphs) const
{
#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
    String sanitized = Font::normalizeSpaces(String(run.characters(), run.length()));
    QString string = fromRawDataWithoutRef(sanitized);

    QFontMetrics fm(font());
    float delta = (float)position;
    int curPos = 0;
    do {
        float charWidth = fm.width(string[curPos]);
        delta -= charWidth;
        if (includePartialGlyphs) {
            if (delta + charWidth / 2 <= 0)
                break;
        } else {
            if (delta + charWidth <= 0)
                break;
        }
    } while (++curPos < string.size());

    return curPos;
#else
    Q_ASSERT(false);
    return 0;
#endif
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.vendor,代码行数:27,代码来源:FontQt.cpp

示例6: offsetForPositionForComplexText

int Font::offsetForPositionForComplexText(const TextRun& run, float xFloat, bool includePartialGlyphs) const
{
#if USE(FREETYPE)
    if (!primaryFont()->platformData().m_pattern)
        return offsetForPositionForSimpleText(run, xFloat, includePartialGlyphs);
#endif
    // FIXME: This truncation is not a problem for HTML, but only affects SVG, which passes floating-point numbers
    // to Font::offsetForPosition(). Bug http://webkit.org/b/40673 tracks fixing this problem.
    int x = static_cast<int>(xFloat);

    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:conioh,项目名称:os-design,代码行数:27,代码来源:FontPango.cpp

示例7: TextRunWalker

    TextRunWalker(const TextRun& run, unsigned startingX, const Font* font)
        : m_font(font)
        , m_run(run)
        , m_startingX(startingX)
        , m_offsetX(m_startingX)
        , m_iterateBackwards(run.rtl())
    {
        memset(&m_item, 0, sizeof(m_item));
        // We cannot know, ahead of time, how many glyphs a given script run
        // will produce. We take a guess that script runs will not produce more
        // than twice as many glyphs as there are code points and fallback if
        // we find that we are wrong.
        m_maxGlyphs = run.length() * 2;
        createGlyphArrays();

        m_item.log_clusters = new unsigned short[run.length()];

        m_item.face = 0;
        m_item.font = allocHarfbuzzFont();

        m_item.string = run.characters();
        m_item.stringLength = run.length();
        m_item.item.bidiLevel = run.rtl();

        reset();
    }
开发者ID:DreamOnTheGo,项目名称:src,代码行数:26,代码来源:FontLinux.cpp

示例8: drawComplexText

void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const TextStyle& style, const FloatPoint& point, int from, int to) const
{
    cairo_t* cr = context->platformContext();
    cairo_save(cr);
    
    PangoLayout* layout = pango_cairo_create_layout(cr);
    
    gchar* utf8 = convertUniCharToUTF8(run.characters(), run.length(), from, run.length());
    pango_layout_set_text(layout, utf8, -1);
    
    setPangoAttributes(this, run, layout, style.rtl());
    
    // Set the text color to use for drawing.
    float red, green, blue, alpha;
    Color penColor = context->fillColor();
    penColor.getRGBA(red, green, blue, alpha);
    cairo_set_source_rgba(cr, red, green, blue, alpha);
    
    cairo_move_to(cr, point.x(), point.y());
    PangoLayoutLine* layoutLine = pango_layout_get_line(layout, 0);
    pango_cairo_show_layout_line(cr, layoutLine);
    g_free(utf8);

    g_object_unref(layout);
    cairo_restore(cr);
}
开发者ID:UIKit0,项目名称:WebkitAIR,代码行数:26,代码来源:FontGdkApollo.cpp

示例9: drawComplexText

void Font::drawComplexText(GraphicsContext* context, const TextRun& run, const FloatPoint& point, int from, int to) const
{
#if defined(USE_FREETYPE)
    if (!primaryFont()->platformData().m_pattern) {
        drawSimpleText(context, run, point, from, to);
        return;
    }
#endif

    cairo_t* cr = context->platformContext();
    PangoLayout* layout = pango_cairo_create_layout(cr);
    setPangoAttributes(this, run, layout);

    gchar* utf8 = convertUniCharToUTF8(run.characters(), run.length(), 0, run.length());
    pango_layout_set_text(layout, utf8, -1);

    // Our layouts are single line
    PangoLayoutLine* layoutLine = pango_layout_get_line_readonly(layout, 0);

    // Get the region where this text will be laid out. We will use it to clip
    // the Cairo context, for when we are only painting part of the text run and
    // to calculate the size of the shadow buffer.
    PangoRegionType partialRegion = 0;
    char* start = g_utf8_offset_to_pointer(utf8, from);
    char* end = g_utf8_offset_to_pointer(start, to - from);
    int ranges[] = {start - utf8, end - utf8};
    partialRegion = gdk_pango_layout_line_get_clip_region(layoutLine, 0, 0, ranges, 1);

    drawGlyphsShadow(context, cr, point, layoutLine, partialRegion);

    cairo_save(cr);
    cairo_translate(cr, point.x(), point.y());

    float red, green, blue, alpha;
    context->fillColor().getRGBA(red, green, blue, alpha);
    cairo_set_source_rgba(cr, red, green, blue, alpha);
    gdk_cairo_region(cr, partialRegion);
    cairo_clip(cr);

    pango_cairo_show_layout_line(cr, layoutLine);

    if (context->textDrawingMode() & TextModeStroke) {
        Color strokeColor = context->strokeColor();
        strokeColor.getRGBA(red, green, blue, alpha);
        cairo_set_source_rgba(cr, red, green, blue, alpha);
        pango_cairo_layout_line_path(cr, layoutLine);
        cairo_set_line_width(cr, context->strokeThickness());
        cairo_stroke(cr);
    }

    // Pango sometimes leaves behind paths we don't want
    cairo_new_path(cr);

    destroyPangoRegion(partialRegion);
    g_free(utf8);
    g_object_unref(layout);

    cairo_restore(cr);
}
开发者ID:,项目名称:,代码行数:59,代码来源:

示例10: drawComplexText

void Font::drawComplexText(GraphicsContext* ctx, const TextRun& run, const TextStyle&, const FloatPoint& point) const
{
    // FIXME: style, run.from()/length() cut-off
    ctx->platformContext()->drawText(point, 
                                     QString::fromRawData(
                                         reinterpret_cast<const QChar*>(
                                             run.characters() + run.from()), run.length()));
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:8,代码来源:FontQt.cpp

示例11: offsetForPositionForComplexText

int Font::offsetForPositionForComplexText(const TextRun& run, float position, bool) const
{
    String sanitized = Font::normalizeSpaces(run.characters(), run.length());
    QString string = fromRawDataWithoutRef(sanitized);

    QTextLayout layout(string, font());
    QTextLine line = setupLayout(&layout, run);
    return line.xToCursor(position);
}
开发者ID:akosicki,项目名称:phantomjs,代码行数:9,代码来源:FontQt.cpp

示例12: selectionRectForSimpleText

FloatRect Font::selectionRectForSimpleText(const TextRun& run, const FloatPoint& pt, int h, int from, int to) const
{
    String sanitized = Font::normalizeSpaces(run.characters(), run.length());
    QString wholeText = fromRawDataWithoutRef(sanitized);
    QString selectedText = fromRawDataWithoutRef(sanitized, from, qMin(to - from, wholeText.length() - from));

    int startX = QFontMetrics(font()).width(wholeText, from, Qt::TextBypassShaping);
    int width = QFontMetrics(font()).width(selectedText, -1, Qt::TextBypassShaping);

    return FloatRect(pt.x() + startX, pt.y(), width, h);
}
开发者ID:akosicki,项目名称:phantomjs,代码行数:11,代码来源:FontQt.cpp

示例13: floatWidthForComplexText

float Font::floatWidthForComplexText(const TextRun& run, HashSet<const SimpleFontData*>*) const
{
    SkPaint paint;

    primaryFont()->platformData().setupPaint(&paint);

//printf("--------- complext measure %d chars\n", run.to() - run.from());

    SkScalar width = paint.measureText(run.characters(), run.length() << 1);
    return SkScalarToFloat(width);
}
开发者ID:Androtos,项目名称:toolchain_benchmark,代码行数:11,代码来源:FontAndroid.cpp

示例14: qstring

static QString qstring(const TextRun& run)
{
    QString string((QChar *)run.characters(), run.length());
    QChar *uc = string.data();
    for (int i = 0; i < string.length(); ++i) {
        if (Font::treatAsSpace(uc[i].unicode()))
            uc[i] = 0x20;
        else if (Font::treatAsZeroWidthSpace(uc[i].unicode()))
            uc[i] = 0x200c;
    }
    return string;
}
开发者ID:Fale,项目名称:qtmoko,代码行数:12,代码来源:FontQt.cpp

示例15: getWidth

static float getWidth(PangoLayout *layout, const TextRun& run, int from, int to)
{
    int layoutWidth;

    gchar* utf8 = convertUniCharToUTF8(run.characters(), run.length(), from, to);
    pango_layout_set_text(layout, utf8, -1);
    g_free(utf8);
    pango_layout_get_size(layout, &layoutWidth, 0);
    float width = (float)layoutWidth / (double)PANGO_SCALE;

    return width;
}
开发者ID:UIKit0,项目名称:WebkitAIR,代码行数:12,代码来源:FontGdkApollo.cpp


注:本文中的TextRun::characters方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。