Пример #1
0
unsigned DrawingText::_renderItem(DrawingContext &ct, Geom::IntRect const &/*area*/, unsigned /*flags*/, DrawingItem * /*stop_at*/)
{
    if (_drawing.outline()) {
        guint32 rgba = _drawing.outlinecolor;
        Inkscape::DrawingContext::Save save(ct);
        ct.setSource(rgba);
        ct.setTolerance(0.5); // low quality, but good enough for outline mode

        for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) {
            DrawingGlyphs *g = dynamic_cast<DrawingGlyphs *>(&*i);
            if (!g) throw InvalidItemException();

            Inkscape::DrawingContext::Save save(ct);
            // skip glpyhs with singular transforms
            if (g->_ctm.isSingular()) continue;
            ct.transform(g->_ctm);
            ct.path(*g->_font->PathVector(g->_glyph));
            ct.fill();
        }
        return RENDER_OK;
    }

    // NOTE: this is very similar to drawing-shape.cpp; the only difference is in path feeding
    bool has_stroke, has_fill;

    has_fill   = _nrstyle.prepareFill(ct, _item_bbox);
    has_stroke = _nrstyle.prepareStroke(ct, _item_bbox);

    if (has_fill || has_stroke) {
        for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) {
            DrawingGlyphs *g = dynamic_cast<DrawingGlyphs *>(&*i);
            if (!g) throw InvalidItemException();

            Inkscape::DrawingContext::Save save(ct);
            if (g->_ctm.isSingular()) continue;
            ct.transform(g->_ctm);
            ct.path(*g->_font->PathVector(g->_glyph));
        }

        Inkscape::DrawingContext::Save save(ct);
        ct.transform(_ctm);
        if (has_fill) {
            _nrstyle.applyFill(ct);
            ct.fillPreserve();
        }
        if (has_stroke) {
            _nrstyle.applyStroke(ct);
            ct.strokePreserve();
        }
        ct.newPath(); // clear path
    }
    return RENDER_OK;
}
Пример #2
0
void DrawingText::_clipItem(DrawingContext &ct, Geom::IntRect const &/*area*/)
{
    Inkscape::DrawingContext::Save save(ct);

    // handle clip-rule
    if (_style) {
        if (_style->clip_rule.computed == SP_WIND_RULE_EVENODD) {
            ct.setFillRule(CAIRO_FILL_RULE_EVEN_ODD);
        } else {
            ct.setFillRule(CAIRO_FILL_RULE_WINDING);
        }
    }

    for (ChildrenList::iterator i = _children.begin(); i != _children.end(); ++i) {
        DrawingGlyphs *g = dynamic_cast<DrawingGlyphs *>(&*i);
        if (!g) {
            throw InvalidItemException();
        }

        Inkscape::DrawingContext::Save save(ct);
        ct.transform(g->_ctm);
        ct.path(*g->_font->PathVector(g->_glyph));
    }
    ct.fill();
}