summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormathog <>2015-06-01 23:00:24 +0000
committermathog <>2015-06-01 23:00:24 +0000
commit3d556ac8b9ff5cb1574f7cc873707e2bc008cc00 (patch)
tree55451dbaa44e9007e68385f4437e68aab8cc4b0f
parentMark user-visible messages for translation (diff)
downloadinkscape-3d556ac8b9ff5cb1574f7cc873707e2bc008cc00.tar.gz
inkscape-3d556ac8b9ff5cb1574f7cc873707e2bc008cc00.zip
patch for bug 1283194
(bzr r14192)
-rw-r--r--src/display/drawing-text.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp
index 3928ad796..a3ca7173a 100644
--- a/src/display/drawing-text.cpp
+++ b/src/display/drawing-text.cpp
@@ -91,9 +91,24 @@ unsigned DrawingGlyphs::_updateItem(Geom::IntRect const &/*area*/, UpdateContext
if (_transform) {
scale_bigbox /= _transform->descrim();
}
+
- Geom::Rect bigbox(Geom::Point(-_width*scale_bigbox*0.1, _asc*scale_bigbox*1.1),Geom::Point(_width*scale_bigbox, -_dsc*scale_bigbox*1.1));
- Geom::Rect b = bigbox * ctx.ctm;
+ /* Because there can be text decorations the bounding box must correspond in Y to a little above the glyph's ascend
+ and a little below its descend. This leaves room for overline and underline. The left and right sides
+ come from the glyph's bounding box. Note that the initial direction of ascender is positive down in Y, and
+ this flips after the transform is applied. So change the sign on descender. 1.1 provides a little extra space
+ above and below the max/min y positions of the letters to place the text decorations.*/
+
+ Geom::Rect b;
+ if(_drawable){
+ Geom::OptRect tiltb = bounds_exact(*_font->PathVector(_glyph));
+ Geom::Rect bigbox(Geom::Point(tiltb->left(),-_dsc*scale_bigbox*1.1),Geom::Point(tiltb->right(),_asc*scale_bigbox*1.1));
+ b = bigbox * ctx.ctm;
+ }
+ else { // Fallback, spaces mostly
+ Geom::Rect bigbox(Geom::Point(0.0, -_dsc*scale_bigbox*1.1),Geom::Point(_width*scale_bigbox, _asc*scale_bigbox*1.1));
+ b = bigbox * ctx.ctm;
+ }
/*
The pick box matches the characters as best as it can, leaving no extra space above or below
@@ -108,11 +123,11 @@ unsigned DrawingGlyphs::_updateItem(Geom::IntRect const &/*area*/, UpdateContext
if(_drawable){
pb = bounds_exact_transformed(*_font->PathVector(_glyph), ctx.ctm);
}
- if(!pb){ // Fallback
+ if(!pb){ // Fallback, spaces mostly
Geom::Rect pbigbox(Geom::Point(0.0, _asc*scale_bigbox*0.66),Geom::Point(_width*scale_bigbox, 0.0));
pb = pbigbox * ctx.ctm;
}
-
+
#if 0
/* FIXME if this is commented out then not even an approximation of pick on decorations */
/* adjust the pick box up or down to include the decorations.
@@ -214,7 +229,7 @@ DrawingText::addComponent(font_instance *font, int glyph, Geom::Affine const &tr
ng->setGlyph(font, glyph, trans);
if(font->PathVector(glyph)){ ng->_drawable = true; }
else { ng->_drawable = false; }
- ng->_width = width; // only used when _drawable = false
+ ng->_width = width; // used especially when _drawable = false, otherwise, it is the advance of the font
ng->_asc = ascent; // of font, not of this one character
ng->_dsc = descent; // of font, not of this one character
ng->_pl = phase_length; // used for phase of dots, dashes, and wavy