diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2011-09-05 15:42:23 +0000 |
|---|---|---|
| committer | Krzysztof KosiĆski <tweenk.pl@gmail.com> | 2011-09-05 15:42:23 +0000 |
| commit | 2c77118e8580503218085a36656a121fcc4f59c0 (patch) | |
| tree | 131adf25bb9b4965ad4ea6342a4cf2ad97e0fdde /src | |
| parent | Fix incorrect marker bbox in previews (diff) | |
| download | inkscape-2c77118e8580503218085a36656a121fcc4f59c0.tar.gz inkscape-2c77118e8580503218085a36656a121fcc4f59c0.zip | |
Fix bugs in text stroke rendering and picking
(bzr r10620)
Diffstat (limited to 'src')
| -rw-r--r-- | src/display/drawing-text.cpp | 26 | ||||
| -rw-r--r-- | src/display/drawing-text.h | 3 | ||||
| -rw-r--r-- | src/libnrtype/Layout-TNG-Output.cpp | 2 |
3 files changed, 13 insertions, 18 deletions
diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp index 1134771bc..4a20875ae 100644 --- a/src/display/drawing-text.cpp +++ b/src/display/drawing-text.cpp @@ -63,14 +63,20 @@ DrawingGlyphs::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, return STATE_ALL; } + _pick_bbox = Geom::IntRect(); + _bbox = Geom::IntRect(); + Geom::OptRect b = bounds_exact_transformed(*_font->PathVector(_glyph), ctx.ctm); if (b && ggroup->_nrstyle.stroke.type != NRStyle::PAINT_NONE) { float width, scale; scale = ctx.ctm.descrim(); + if (_transform) scale /= _transform->descrim(); // FIXME temporary hack width = MAX(0.125, ggroup->_nrstyle.stroke_width * scale); if ( fabs(ggroup->_nrstyle.stroke_width * scale) > 0.01 ) { // FIXME: this is always true b->expandBy(width); } + // save no-miter bbox for picking + _pick_bbox = b->roundOutwards(); // those pesky miters, now float miterMax = width * ggroup->_nrstyle.miter_limit; if ( miterMax > 0.01 ) { @@ -78,12 +84,7 @@ DrawingGlyphs::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, // (one for each point on the curve) b->expandBy(miterMax); } - } - - if (b) { _bbox = b->roundOutwards(); - } else { - _bbox = Geom::OptIntRect(); } return STATE_ALL; @@ -95,7 +96,7 @@ DrawingGlyphs::_pickItem(Geom::Point const &p, double delta, unsigned /*flags*/) if (!_font || !_bbox) return NULL; // With text we take a simple approach: pick if the point is in a characher bbox - Geom::Rect expanded(*_bbox); + Geom::Rect expanded(_pick_bbox); expanded.expandBy(delta); if (expanded.contains(p)) return this; return NULL; @@ -135,13 +136,6 @@ DrawingText::setStyle(SPStyle *style) DrawingGroup::setStyle(style); } -void -DrawingText::setPaintBox(Geom::OptRect const &box) -{ - _paintbox = box; - _markForUpdate(STATE_ALL, false); -} - unsigned DrawingText::_updateItem(Geom::IntRect const &area, UpdateContext const &ctx, unsigned flags, unsigned reset) { @@ -175,8 +169,8 @@ DrawingText::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned // 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, _paintbox); - has_stroke = _nrstyle.prepareStroke(ct, _paintbox); + 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) { @@ -189,6 +183,8 @@ DrawingText::_renderItem(DrawingContext &ct, Geom::IntRect const &area, unsigned ct.path(*g->_font->PathVector(g->_glyph)); } + Inkscape::DrawingContext::Save save(ct); + ct.transform(_ctm); if (has_fill) { _nrstyle.applyFill(ct); ct.fillPreserve(); diff --git a/src/display/drawing-text.h b/src/display/drawing-text.h index 4f3940dde..73caa6a7c 100644 --- a/src/display/drawing-text.h +++ b/src/display/drawing-text.h @@ -36,6 +36,7 @@ protected: font_instance *_font; int _glyph; + Geom::IntRect _pick_bbox; friend class DrawingText; }; @@ -50,7 +51,6 @@ public: void clear(); void addComponent(font_instance *font, int glyph, Geom::Affine const &trans); void setStyle(SPStyle *style); - void setPaintBox(Geom::OptRect const &box); protected: virtual unsigned _updateItem(Geom::IntRect const &area, UpdateContext const &ctx, @@ -61,7 +61,6 @@ protected: virtual DrawingItem *_pickItem(Geom::Point const &p, double delta, unsigned flags); virtual bool _canClip(); - Geom::OptRect _paintbox; NRStyle _nrstyle; friend class DrawingGlyphs; diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index 7e54a00e2..ebb71d388 100644 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -99,7 +99,7 @@ void Layout::show(DrawingGroup *in_arena, Geom::OptRect const &paintbox) const } glyph_index++; } - nr_text->setPaintBox(paintbox); + nr_text->setItemBounds(paintbox); in_arena->prependChild(nr_text); } } |
