r21355 by jghali -
scribus-commit
scribus-commit at lists.scribus.net
Fri May 27 22:28:31 UTC 2016
Author: jghali
Date: Fri May 27 22:28:31 2016
New Revision: 21355
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21355
Log:
#14110: PP may display incorrect text properties if text is selected left to right
Modified:
trunk/Scribus/scribus/pageitem.cpp
trunk/Scribus/scribus/pageitem_textframe.cpp
Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21355&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Fri May 27 22:28:31 2016
@@ -1519,17 +1519,30 @@
/// returns the style at the current charpos
const ParagraphStyle& PageItem::currentStyle() const
{
- if (frameDisplays(itemText.cursorPosition()))
- return itemText.paragraphStyle(itemText.cursorPosition());
- else
- return itemText.defaultStyle();
+ int cursorPosition = itemText.cursorPosition();
+ if (itemText.lengthOfSelection() > 0)
+ {
+ int firstSelected = itemText.startOfSelection();
+ int lastSelected = qMax(itemText.endOfSelection() - 1, 0);
+ cursorPosition = qMax(firstSelected, qMin(cursorPosition, lastSelected));
+ }
+ if (frameDisplays(cursorPosition))
+ return itemText.paragraphStyle(cursorPosition);
+ return itemText.defaultStyle();
}
/// returns the style at the current charpos for changing
ParagraphStyle& PageItem::changeCurrentStyle()
{
- if (frameDisplays(itemText.cursorPosition()))
- return const_cast<ParagraphStyle&>(itemText.paragraphStyle(itemText.cursorPosition()));
+ int cursorPosition = itemText.cursorPosition();
+ if (itemText.lengthOfSelection() > 0)
+ {
+ int firstSelected = itemText.startOfSelection();
+ int lastSelected = qMax(itemText.endOfSelection() - 1, 0);
+ cursorPosition = qMax(firstSelected, qMin(cursorPosition, lastSelected));
+ }
+ if (frameDisplays(cursorPosition))
+ return const_cast<ParagraphStyle&>(itemText.paragraphStyle(cursorPosition));
else
return const_cast<ParagraphStyle&>(itemText.defaultStyle());
}
@@ -1537,8 +1550,15 @@
/// returns the style at the current charpos
const CharStyle& PageItem::currentCharStyle() const
{
- if (frameDisplays(itemText.cursorPosition()))
- return itemText.charStyle(itemText.cursorPosition());
+ int cursorPosition = itemText.cursorPosition();
+ if (itemText.lengthOfSelection() > 0)
+ {
+ int firstSelected = itemText.startOfSelection();
+ int lastSelected = qMax(itemText.endOfSelection() - 1, 0);
+ cursorPosition = qMax(firstSelected, qMin(cursorPosition, lastSelected));
+ }
+ if (frameDisplays(cursorPosition))
+ return itemText.charStyle(cursorPosition);
else
return itemText.defaultStyle().charStyle();
}
Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21355&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp (original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp Fri May 27 22:28:31 2016
@@ -1815,9 +1815,8 @@
realCharHeight = qMax(realCharHeight, gm.ascent + gm.descent);
gm = font.glyphBBox(gl.glyph, chsd / 10.0);
realAsce = qMax(realAsce, gm.ascent + gm.descent);
- wide += gm.width;
- }
- wide = (wide * scaleH) + (1 - scaleH);
+ wide += font.glyphWidth(gl.glyph, charStyle.fontSize() / 10.0);
+ }
realAsce = realAsce * scaleV + offset;
if (realCharHeight == 0)
realCharHeight = font.height(style.charStyle().fontSize() / 10.0);
@@ -1827,6 +1826,7 @@
firstGlyph.scaleV = (realAsce / realCharHeight);
firstGlyph.scaleH *= firstGlyph.scaleV;
firstGlyph.xoffset -= 0.5; //drop caps are always to far from column left edge
+ wide *= firstGlyph.scaleH;
}
// 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
More information about the scribus-commit
mailing list