r21638 by jghali - avoid unnecessary function calls when layouting drop caps
scribus-commit
scribus-commit at lists.scribus.net
Sun Dec 11 18:28:10 UTC 2016
Author: jghali
Date: Sun Dec 11 18:28:10 2016
New Revision: 21638
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21638
Log:
avoid unnecessary function calls when layouting drop caps
Modified:
trunk/Scribus/scribus/pageitem_textframe.cpp
Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21638&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp (original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp Sun Dec 11 18:28:10 2016
@@ -1716,6 +1716,7 @@
if (DropCmode)
{
// drop caps are wider...
+ GlyphCluster& glyphCluster = current.glyphs[currentIndex];
if (HasObject)
{
// double itemHeight = currentObject->height() + currentObject->lineWidth();
@@ -1729,16 +1730,16 @@
asce = currentObjectBox.height();
wide = currentObjectBox.width();
realAsce = calculateLineSpacing (style, this) * DropLines;
- current.glyphs[currentIndex].setScaleH(current.glyphs[currentIndex].scaleH() / current.glyphs[currentIndex].scaleV());
- current.glyphs[currentIndex].setScaleV(realAsce / itemHeight);
- current.glyphs[currentIndex].setScaleH(current.glyphs[currentIndex].scaleH() * current.glyphs[currentIndex].scaleV());
- wide *= current.glyphs[currentIndex].scaleH();
+ glyphCluster.setScaleH(glyphCluster.scaleH() / glyphCluster.scaleV());
+ glyphCluster.setScaleV(realAsce / itemHeight);
+ glyphCluster.setScaleH(glyphCluster.scaleH() * glyphCluster.scaleV());
+ wide *= glyphCluster.scaleH();
}
else
{
double realCharHeight = 0.0;
wide = 0.0; realAsce = 0.0;
- foreach (const GlyphLayout& gl, current.glyphs[currentIndex].glyphs()) {
+ foreach (const GlyphLayout& gl, glyphCluster.glyphs()) {
GlyphMetrics gm;
gm = font.glyphBBox(gl.glyph, charStyle.fontSize() / 10.0);
realCharHeight = qMax(realCharHeight, gm.ascent + gm.descent);
@@ -1751,17 +1752,17 @@
if (realCharHeight == 0)
realCharHeight = font.height(style.charStyle().fontSize() / 10.0);
asce = font.ascent(hlcsize10);
- current.glyphs[currentIndex].setScaleH(current.glyphs[currentIndex].scaleH() / current.glyphs[currentIndex].scaleV());
- current.glyphs[currentIndex].setScaleV(realAsce / realCharHeight);
- current.glyphs[currentIndex].setScaleH(current.glyphs[currentIndex].scaleH() * current.glyphs[currentIndex].scaleV());
- current.glyphs[currentIndex].xoffset -= 0.5; //drop caps are always to far from column left edge
+ glyphCluster.setScaleH(glyphCluster.scaleH() / glyphCluster.scaleV());
+ glyphCluster.setScaleV(realAsce / realCharHeight);
+ glyphCluster.setScaleH(glyphCluster.scaleH() * glyphCluster.scaleV());
+ glyphCluster.xoffset -= 0.5; //drop caps are always to far from column left edge
}
// This is to mimic pre-boxes branches in case first character of paragraph is a space
// If we don't do this, paragraph offset will not apply correctly to first line
- if ((current.glyphs[currentIndex].scaleH() == 0.0) || (current.glyphs[currentIndex].scaleV() == 0.0))
- {
- current.glyphs[currentIndex].setScaleH(1.0);
- current.glyphs[currentIndex].setScaleV(1.0);
+ if ((glyphCluster.scaleH() == 0.0) || (glyphCluster.scaleV() == 0.0))
+ {
+ glyphCluster.setScaleH(1.0);
+ glyphCluster.setScaleV(1.0);
wide = 0.0;
}
desc = realDesc = 0;
More information about the scribus-commit
mailing list