/*
7 * Krzysztof KosiĆski <tweenk.pl@gmail.com>
9 * Copyright (C) 2011 Authors
10 * Released under GNU GPL v2+, read the file
'COPYING' for more information.
40 defer([=,
this, font = std::move(font)] {
60 if (font->FontHasSVG()) {
63 font_descr = pango_font_description_to_string(font->get_descr());
78 std::cerr <<
"DrawingGlyphs: Use parent style" << std::endl;
83 auto ggroup = cast<DrawingText>(&std::as_const(*
_parent));
102 float width = std::max<double>(0.125, ggroup->_nrstyle.data.stroke_width *
scale);
103 if (std::fabs(ggroup->_nrstyle.data.stroke_width *
scale) > 0.01) {
108 float miterMax =
width * ggroup->_nrstyle.data.miter_limit;
109 if (miterMax > 0.01) {
112 bbox_draw_scaled_d.
expandBy(miterMax);
133 auto ggroup = cast<DrawingText>(
_parent);
154 , style_vector_effect_stroke(false)
155 , style_stroke_extensions_hairline(false)
162 if (glyph == 0x0fffffff) {
168 std::cerr <<
"DrawingTExt::addComponent: no font!" << std::endl;
172 defer([=,
this, font = std::move(font)] ()
mutable {
176 ng->setGlyph(font, glyph, trans);
180 ng->_pl = phase_length;
191 auto vector_effect_stroke =
false;
192 auto stroke_extensions_hairline =
false;
227 0.000000, 0.382499, 0.706825, 0.923651, 1.000000, 0.923651, 0.706825, 0.382499,
228 0.000000, -0.382499, -0.706825, -0.923651, -1.000000, -0.923651, -0.706825, -0.382499,
247 double step = vextent/32.0;
248 unsigned i = 15 & (unsigned) round(xphase/step);
325 double amp = vextent/10.0;
366 double thickness = final_underline_thickness;
367 if ( thickness <= 1.0e-32 )
return;
388 thickness = final_line_through_thickness;
396 thickness = final_line_through_thickness;
417 auto rgba =
rc.outline_color;
423 auto g = cast<DrawingGlyphs>(&i);
428 if (g->_ctm.isSingular())
continue;
431 dc.
path(*g->pathvec);
471 bool fill_first =
false;
480 double phase_length = 0.0;
486 double leftmost = DBL_MAX;
488 double start_y = 0.0;
491 auto g = cast<DrawingGlyphs>(&i);
503 phase_length = g->_pl;
511 else if (std::fabs(pt[
Geom::Y] - start_y) > 1.0e-6) {
532 if (has_td_fill && fill_first) {
542 if (has_td_fill && !fill_first) {
554 auto g = cast<DrawingGlyphs>(&i);
558 if (g->_ctm.isSingular()) {
559 std::cerr <<
"DrawingText::_renderItem: glyph matrix is singular!" << std::endl;
566 auto path_copy = cairo_copy_path(dc.
raw());
591 cairo_append_path(dc.
raw(), path_copy);
592 cairo_path_destroy(path_copy);
618 double scale = g->design_units;
623 dc.
setSource(g->pixbuf->getSurfaceRaw(), 0, 0);
627 dc.
path(*g->pathvec);
652 double dx = 1.0, dy = 0.0;
654 auto pixel_size = std::hypot(dx, dy);
686 if (has_td_fill && fill_first) {
696 if (has_td_fill && !fill_first) {
721 auto g = cast<DrawingGlyphs>(&i);
729 dc.
path(*g->pathvec);
Cairo integration helpers.
3x3 matrix representing an affine transformation.
Coord descrim() const
Calculate the descriminant.
Affine inverse() const
Compute the inverse matrix.
Affine withoutTranslation() const
Axis aligned, non-empty, generic rectangle.
bool contains(GenericRect< C > const &r) const
Check whether the rectangle includes all points in the given rectangle.
void expandBy(C amount)
Expand the rectangle in both directions by the specified amount.
Two-dimensional point that doubles as a vector.
Axis aligned, non-empty rectangle.
IntRect roundOutwards() const
Return the smallest integer rectangle which contains this one.
RAII idiom for saving the state of DrawingContext.
Minimal wrapper over Cairo.
void path(Geom::PathVector const &pv)
void setSource(cairo_pattern_t *source)
void scale(Geom::Scale const &s)
void transform(Geom::Affine const &trans)
void setTolerance(double tol)
void device_to_user_distance(double &dx, double &dy)
void paint(double alpha=1.0)
void rectangle(Geom::Rect const &r)
void setFillRule(cairo_fill_rule_t rule)
void lineTo(Geom::Point const &p)
void moveTo(Geom::Point const &p)
void translate(Geom::Point const &t)
void setLineWidth(double w)
Geom::IntRect bbox_draw_scaled
DrawingGlyphs(Drawing &drawing)
void setGlyph(std::shared_ptr< FontInstance > font, unsigned int glyph, Geom::Affine const &trans)
Geom::IntRect bbox_pick_scaled
void setStyle(SPStyle const *style, SPStyle const *context_style=nullptr) override
Process information related to the new style.
unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset) override
std::shared_ptr< void const > _font_data
Inkscape::Pixbuf const * pixbuf
Geom::PathVector const * pathvec
DrawingItem * _pickItem(Geom::Point const &p, double delta, unsigned flags) override
unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset) override
DrawingItem * _pickItem(Geom::Point const &p, double delta, unsigned flags) override
SVG drawing item for display.
DrawingPattern * _fill_pattern
@ RENDER_VISIBLE_HAIRLINES
void appendChild(DrawingItem *item)
Geom::OptIntRect _bbox
Bounding box in display (pixel) coords including stroke.
virtual void setStyle(SPStyle const *style, SPStyle const *context_style=nullptr)
Process information related to the new style.
Geom::OptRect _item_bbox
Geometric bounding box in item's user space.
virtual void setChildrenStyle(SPStyle const *context_style)
Recursively update children style.
std::unique_ptr< Geom::Affine > _transform
Incremental transform from parent to this item's coords.
void _markForUpdate(unsigned state, bool propagate)
Marks the item as needing a recomputation of internal data.
DrawingPattern * _stroke_pattern
void setTransform(Geom::Affine const &trans)
SPStyle const * _context_style
Geom::Affine _ctm
Total transform from item coords to display coords.
void _markForRendering()
Marks the current visual bounding box of the item for redrawing.
void decorateItem(DrawingContext &dc, double phase_length, bool under) const
DrawingText(Drawing &drawing)
void setStyle(SPStyle const *style, SPStyle const *context_style=nullptr) override
Process information related to the new style.
void setChildrenStyle(SPStyle const *context_style) override
Recursively update children style.
unsigned _renderItem(DrawingContext &dc, RenderContext &rc, Geom::IntRect const &area, unsigned flags, DrawingItem const *stop_at) const override
unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset) override
SPWindRule style_clip_rule
void decorateStyle(DrawingContext &dc, double vextent, double xphase, Geom::Point const &p1, Geom::Point const &p2, double thickness) const
void _clipItem(DrawingContext &dc, RenderContext &rc, Geom::IntRect const &area) const override
bool style_stroke_extensions_hairline
bool style_vector_effect_stroke
friend class DrawingGlyphs
bool addComponent(std::shared_ptr< FontInstance > const &font, int unsigned glyph, Geom::Affine const &trans, float width, float ascent, float descent, float phase_length)
DrawingItem * _pickItem(Geom::Point const &p, double delta, unsigned flags) override
void applyTextDecorationFill(DrawingContext &dc, CairoPatternUniqPtr const &cp) const
void applyStroke(DrawingContext &dc, CairoPatternUniqPtr const &cp) const
CairoPatternUniqPtr prepareFill(DrawingContext &dc, RenderContext &rc, Geom::IntRect const &area, Geom::OptRect const &paintbox, DrawingPattern const *pattern) const
CairoPatternUniqPtr prepareStroke(DrawingContext &dc, RenderContext &rc, Geom::IntRect const &area, Geom::OptRect const &paintbox, DrawingPattern const *pattern) const
void applyTextDecorationStroke(DrawingContext &dc, CairoPatternUniqPtr const &cp) const
CairoPatternUniqPtr prepareTextDecorationFill(DrawingContext &dc, RenderContext &rc, Geom::IntRect const &area, Geom::OptRect const &paintbox, DrawingPattern const *pattern) const
CairoPatternUniqPtr prepareTextDecorationStroke(DrawingContext &dc, RenderContext &rc, Geom::IntRect const &area, Geom::OptRect const &paintbox, DrawingPattern const *pattern) const
void applyFill(DrawingContext &dc, CairoPatternUniqPtr const &cp) const
void set(NRStyleData &&data)
T< SPAttr::CLIP_RULE, SPIEnum< SPWindRule > > clip_rule
clip-rule: 0 nonzero, 1 evenodd
T< SPAttr::STROKE_EXTENSIONS, SPIStrokeExtensions > stroke_extensions
-inkscape-stroke
T< SPAttr::VECTOR_EFFECT, SPIVectorEffect > vector_effect
vector effect
Cairo drawing context with Inkscape extensions.
Cairo surface that remembers its origin.
Group belonging to an SVG drawing element.
static bool has_fill(SPObject *source)
static bool has_stroke(SPObject *source)
The data describing a single loaded font.
Specific geometry functions for Inkscape, not provided my lib2geom.
Helper class to stream background task notifications as a series of messages.
Geom::PathVector outline(Geom::Path const &input, double width, double miter, LineJoinType join, LineCapType butt, double tolerance)
Strokes the path given by input.
std::unique_ptr< cairo_pattern_t, CairoPatternFreer > CairoPatternUniqPtr
PathVector - a sequence of subpaths.
float line_through_thickness
@ TEXT_DECORATION_LINE_UNDERLINE
@ TEXT_DECORATION_LINE_BLINK
@ TEXT_DECORATION_LINE_CLEAR
@ TEXT_DECORATION_LINE_LINETHROUGH
@ TEXT_DECORATION_LINE_OVERLINE
std::array< PaintOrderType, 3 > paint_order_layer
@ TEXT_DECORATION_STYLE_ISDOUBLE
@ TEXT_DECORATION_STYLE_DOTTED
@ TEXT_DECORATION_STYLE_DASHED
@ TEXT_DECORATION_STYLE_WAVY
float line_through_position
int text_decoration_style
float underline_thickness
SPStyle - a style object for SPItem objects.