Author: jghali
Date: Thu Oct 11 21:39:53 2018
New Revision: 22729

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22729
Log:
svg importer: fix text import issue caused by QPainterPath handling of small 
font sizes

Modified:
    trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp

Modified: trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp
URL: 
http://scribus.net/websvn/diff.php?repname=Scribus&rev=22729&path=/trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp      (original)
+++ trunk/Scribus/scribus/plugins/import/svg/svgplugin.cpp      Thu Oct 11 
21:39:53 2018
@@ -1888,8 +1888,21 @@
        QString textFillColor   = gc->FillCol;
        QString textStrokeColor = gc->StrokeCol;
 
+       // Text outline is generated using a big font size
+       // and scaled afterwards. This is done in order to
+       // overcome some QPainterPath issues when using
+       // small font sizes, especially bad glyph advances
+       QFont painterFont = textFont;
+       painterFont.setPointSizeF(100.0);
+       double fontScale = textFont.pointSizeF() / 100.0;
+
        QPainterPath painterPath;
-       painterPath.addText(startX, startY, textFont, textString);
+       painterPath.addText(0.0, 0.0, painterFont, textString);
+
+       QTransform textTrans;
+       textTrans.translate(startX, startY);
+       textTrans.scale(fontScale, fontScale);
+       painterPath = textTrans.map(painterPath);
 
        textPath.fromQPainterPath(painterPath);
        if (!textPath.empty())
@@ -2110,8 +2123,14 @@
                        {
                                SvgStyle *gc   = m_gc.top();
                                QFont textFont = getFontFromStyle(*gc);
+
+                               // This is to match the scaling done in
+                               // parseTextNode()
+                               double fontSize = textFont.pointSizeF();
+                               textFont.setPointSizeF(100.0);
+
                                QFontMetrics fm(textFont);
-                               width += fm.width(textString);
+                               width += fm.width(textString) * (fontSize / 
100.0);
                        }
                }
        }


_______________________________________________
scribus-commit mailing list
[email protected]
http://lists.scribus.net/mailman/listinfo/scribus-commit

Reply via email to