r21155 by jghali -
scribus-commit
scribus-commit at lists.scribus.net
Sun Apr 3 15:50:24 UTC 2016
Author: jghali
Date: Sun Apr 3 15:50:24 2016
New Revision: 21155
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21155
Log:
#13895: Bulleted list paragraph effects' first line text offset is not the same as the other lines
Added:
trunk/Scribus/scribus/text/textshaper.cpp
trunk/Scribus/scribus/text/textshaper.h
Modified:
trunk/Scribus/scribus/pageitem.cpp
trunk/Scribus/scribus/pageitem_textframe.cpp
trunk/Scribus/scribus/pageitem_textframe.h
trunk/Scribus/scribus/sctextstruct.h
trunk/Scribus/scribus/text/CMakeLists.txt
trunk/Scribus/win32/vc11/scribus-main/Scribus.vcxproj
trunk/Scribus/win32/vc11/scribus-main/Scribus.vcxproj.filters
Modified: trunk/Scribus/scribus/pageitem.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21155&path=/trunk/Scribus/scribus/pageitem.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem.cpp (original)
+++ trunk/Scribus/scribus/pageitem.cpp Sun Apr 3 15:50:24 2016
@@ -2644,8 +2644,8 @@
}
else */
{
- gl.xadvance = font.glyphWidth(gl.glyph, style.fontSize() / 10);
- gl.yadvance = font.glyphBBox(gl.glyph, style.fontSize() / 10).ascent;
+ gl.xadvance = font.glyphWidth(gl.glyph, style.fontSize() / 10) * gl.scaleH;
+ gl.yadvance = font.glyphBBox(gl.glyph, style.fontSize() / 10).ascent * gl.scaleV;
}
if (gl.xadvance > 0)
gl.xadvance += tracking;
Modified: trunk/Scribus/scribus/pageitem_textframe.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21155&path=/trunk/Scribus/scribus/pageitem_textframe.cpp
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.cpp (original)
+++ trunk/Scribus/scribus/pageitem_textframe.cpp Sun Apr 3 15:50:24 2016
@@ -57,6 +57,7 @@
#include "selection.h"
#include "text/boxes.h"
#include "text/screenpainter.h"
+#include "text/textshaper.h"
#include "ui/guidemanager.h"
#include "ui/marksmanager.h"
#include "undomanager.h"
@@ -1242,154 +1243,6 @@
}
}
-QList<GlyphRun> PageItem_TextFrame::shapeText()
-{
- // maps expanded characters to itemText tokens.
- QMap<int, int> textMap;
- QString text;
- for (int i = firstInFrame(); i < itemText.length(); ++i)
- {
- Mark* mark = itemText.mark(i);
- if (itemText.hasMark(i))
- {
- mark->OwnPage = OwnPage;
- //itemPtr and itemName set to this frame only if mark type is different than MARK2ItemType
- if (!mark->isType(MARK2ItemType))
- {
- mark->setItemPtr(this);
- mark->setItemName(itemName());
- }
-
- //anchors and indexes has no visible inserts in text
- if (mark->isType(MARKAnchorType) || mark->isType(MARKIndexType))
- continue;
-
- //set note marker charstyle
- if (mark->isNoteType())
- {
- TextNote* note = mark->getNotePtr();
- if (note == NULL)
- continue;
- mark->setItemPtr(this);
- NotesStyle* nStyle = note->notesStyle();
- Q_ASSERT(nStyle != NULL);
- QString chsName = nStyle->marksChStyle();
- CharStyle currStyle(itemText.charStyle(i));
- if (!chsName.isEmpty())
- {
- CharStyle marksStyle(m_Doc->charStyle(chsName));
- if (!currStyle.equiv(marksStyle))
- {
- currStyle.setParent(chsName);
- itemText.applyCharStyle(i, 1, currStyle);
- }
- }
-
- StyleFlag s(itemText.charStyle(i).effects());
- if (mark->isType(MARKNoteMasterType))
- {
- if (nStyle->isSuperscriptInMaster())
- s |= ScStyle_Superscript;
- else
- s &= ~ScStyle_Superscript;
- }
- else
- {
- if (nStyle->isSuperscriptInNote())
- s |= ScStyle_Superscript;
- else
- s &= ~ScStyle_Superscript;
- }
- if (s != itemText.charStyle(i).effects())
- {
- CharStyle haveSuperscript;
- haveSuperscript.setFeatures(s.featureList());
- itemText.applyCharStyle(i, 1, haveSuperscript);
- }
- }
- }
-
- bool bullet = false;
- if (i == 0 || itemText.text(i - 1) == SpecialChars::PARSEP)
- {
- ParagraphStyle style = itemText.paragraphStyle(i);
- if (style.hasBullet() || style.hasNum())
- {
- bullet = true;
- if (mark == NULL || !mark->isType(MARKBullNumType))
- {
- itemText.insertMark(new BulNumMark(), i);
- i--;
- continue;
- }
- if (style.hasBullet())
- mark->setString(style.bulletStr());
- else if (style.hasNum() && mark->getString().isEmpty())
- {
- mark->setString("?");
- m_Doc->flag_Renumber = true;
- }
- }
- }
-
- if (!bullet && mark && mark->isType(MARKBullNumType))
- {
- itemText.removeChars(i, 1);
- i--;
- continue;
- }
-
- QString str = ExpandToken(i);
- if (str.isEmpty())
- str = SpecialChars::ZWNBSPACE;
-
- for (int j = 0; j < str.length(); j++)
- textMap.insert(text.length() + j, i);
-
- text.append(str);
- }
-
- QList<GlyphRun> glyphRuns;
- glyphRuns.reserve(text.length());
- for (int i = 0; i < text.length(); i++)
- {
- const QChar ch(text.at(i));
- int a = textMap.value(i);
-
- GlyphRun run(&itemText.charStyle(a), itemText.flags(a), a, a, itemText.object(a));
- if (SpecialChars::isExpandingSpace(ch))
- run.setFlag(ScLayout_ExpandingSpace);
-
- GlyphLayout gl = layoutGlyphs(run.style(), QString(ch), itemText.flags(a));
-
- if (!glyphRuns.isEmpty())
- {
- GlyphLayout& last = glyphRuns.last().glyphs().last();
- last.xadvance += run.style().font().glyphKerning(last.glyph, gl.glyph, run.style().fontSize() / 10) * last.scaleH;
- }
-
- //show control characters for marks
- if (itemText.hasMark(a))
- {
- GlyphLayout control;
- control.glyph = SpecialChars::OBJECT.unicode() + ScFace::CONTROL_GLYPHS;
- run.glyphs().append(control);
- }
-
- if (SpecialChars::isExpandingSpace(ch))
- gl.xadvance *= run.style().wordTracking();
-
- if (itemText.hasObject(a))
- gl.xadvance = itemText.object(a)->width() + itemText.object(a)->lineWidth();
-
- run.glyphs().append(gl);
-
- glyphRuns.append(run);
- }
-
- return glyphRuns;
-}
-
void PageItem_TextFrame::layout()
{
// qDebug()<<"==Layout==" << itemName() ;
@@ -1526,7 +1379,8 @@
m_availableRegion = matrix.map(m_availableRegion);
}
- QList<GlyphRun> glyphRuns = shapeText();
+ QList<GlyphRun> glyphRuns;
+ TextShaper shaper(this, firstInFrame());
LineControl current(m_width, m_height, m_textDistanceMargins, lineCorr, m_Doc, glyphRuns, columnWidth(), ColGap);
current.nextColumn(textLayout);
@@ -1585,11 +1439,18 @@
setMaxY(-1);
double maxYAsc = 0.0, maxYDesc = 0.0;
int regionMinY = 0, regionMaxY= 0;
-
double autoLeftIndent = 0.0;
- for (int i = 0; i < glyphRuns.length(); ++i)
- {
- if (glyphRuns[i].glyphs().isEmpty())
+
+ for (int i = 0; shaper.hasRun(i); ++i)
+ {
+ GlyphRun newRun = shaper.runAt(i);
+ if (i >= glyphRuns.count())
+ glyphRuns.append(newRun);
+ else
+ glyphRuns[i] = newRun;
+
+ GlyphRun& currentRun = glyphRuns[i];
+ if (currentRun.glyphs().isEmpty())
continue;
int a = glyphRuns[i].firstChar();
@@ -1811,11 +1672,11 @@
GlyphLayout& firstGlyph = glyphRuns[i].glyphs().first();
GlyphLayout& lastGlyph = glyphRuns[i].glyphs().last();
- // apply cjk kerning
- //TODO: cjk spacing and kerning should be done in layoutGlyphs!
- if (i + 1 < glyphRuns.length())
- {
- GlyphRun nextRun = glyphRuns[i + 1];
+ // Apply cjk kerning
+ // TODO: cjk spacing and kerning should be done in layoutGlyphs!
+ if (shaper.hasRun(i + 1))
+ {
+ GlyphRun nextRun = shaper.runAt(i + 1);
// change xadvance, xoffset according to JIS X4051
int nextStat = SpecialChars::getCJKAttr(itemText.text(nextRun.firstChar()));
if (curStat != 0)
@@ -1909,7 +1770,7 @@
realAsce = qMax(realAsce, gm.ascent + gm.descent);
wide += gm.width;
}
- wide = (wide* scaleH) + (1 - scaleH);
+ wide = (wide * scaleH) + (1 - scaleH);
realAsce = realAsce * scaleV + offset;
if (realCharHeight == 0)
realCharHeight = font.height(style.charStyle().fontSize() / 10.0);
@@ -1920,7 +1781,7 @@
firstGlyph.scaleH *= firstGlyph.scaleV;
firstGlyph.xoffset -= 0.5; //drop caps are always to far from column left edge
}
- firstGlyph.xadvance = wide / firstGlyph.scaleH;
+ firstGlyph.xadvance = wide / firstGlyph.scaleH; // FIXME: why this division?
desc = realDesc = 0;
}
else // !DropCMode
@@ -2636,7 +2497,9 @@
if ((DropCmode || BulNumMode) && !outs)
{
current.xPos += style.parEffectOffset();
- lastGlyph.xadvance += style.parEffectOffset();
+ // FIXME: why a special case for drop caps
+ lastGlyph.xadvance += DropCmode ? (style.parEffectOffset() / lastGlyph.scaleH)
+ : style.parEffectOffset();
if (DropCmode)
{
DropCmode = false;
@@ -2949,7 +2812,7 @@
}
}
}
- if (i == glyphRuns.length() - 1)
+ if (glyphRuns[i].lastChar() == itemText.length() - 1)
{
if (!current.afterOverflow || current.addLine)
{
Modified: trunk/Scribus/scribus/pageitem_textframe.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21155&path=/trunk/Scribus/scribus/pageitem_textframe.h
==============================================================================
--- trunk/Scribus/scribus/pageitem_textframe.h (original)
+++ trunk/Scribus/scribus/pageitem_textframe.h Sun Apr 3 15:50:24 2016
@@ -159,9 +159,6 @@
public:
void setTextFrameHeight();
-
-private:
- QList<GlyphRun> shapeText();
};
#endif
Modified: trunk/Scribus/scribus/sctextstruct.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21155&path=/trunk/Scribus/scribus/sctextstruct.h
==============================================================================
--- trunk/Scribus/scribus/sctextstruct.h (original)
+++ trunk/Scribus/scribus/sctextstruct.h Sun Apr 3 15:50:24 2016
@@ -75,6 +75,7 @@
const CharStyle* m_style;
LayoutFlags m_flags;
QList<GlyphLayout> m_glyphs;
+
int m_firstChar;
int m_lastChar;
PageItem* m_object;
@@ -92,9 +93,11 @@
bool hasFlag(LayoutFlags f) const { return (m_flags & f) == f; }
void setFlag(LayoutFlags f) { m_flags = static_cast<LayoutFlags>(m_flags | f); }
void clearFlag(LayoutFlags f) { m_flags = static_cast<LayoutFlags>(m_flags & ~f); }
+ void clearGlyphs() { m_glyphs.clear(); }
QList<GlyphLayout>& glyphs() { return m_glyphs; }
const QList<GlyphLayout>& glyphs() const { return m_glyphs; }
+ int glyphCount() const { return m_glyphs.count(); }
int firstChar() const { return m_firstChar; }
int lastChar() const { return m_lastChar; }
qreal width() const;
Modified: trunk/Scribus/scribus/text/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21155&path=/trunk/Scribus/scribus/text/CMakeLists.txt
==============================================================================
--- trunk/Scribus/scribus/text/CMakeLists.txt (original)
+++ trunk/Scribus/scribus/text/CMakeLists.txt Sun Apr 3 15:50:24 2016
@@ -13,15 +13,16 @@
)
SET(SCRIBUS_TEXT_LIB_SOURCES
+ boxes.cpp
+ frect.cpp
+ fsize.cpp
+ screenpainter.cpp
+ sctext_shared.cpp
specialchars.cpp
storytext.cpp
textlayout.cpp
textlayoutpainter.cpp
- screenpainter.cpp
- sctext_shared.cpp
- fsize.cpp
- frect.cpp
- boxes.cpp
+ textshaper.cpp
)
QT5_WRAP_CPP(SCRIBUS_TEXT_MOC_SOURCES ${SCRIBUS_TEXT_MOC_CLASSES})
Modified: trunk/Scribus/win32/vc11/scribus-main/Scribus.vcxproj
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21155&path=/trunk/Scribus/win32/vc11/scribus-main/Scribus.vcxproj
==============================================================================
--- trunk/Scribus/win32/vc11/scribus-main/Scribus.vcxproj (original)
+++ trunk/Scribus/win32/vc11/scribus-main/Scribus.vcxproj Sun Apr 3 15:50:24 2016
@@ -402,6 +402,7 @@
<moc Include="..\..\..\scribus\ui\filedialogeventcatcher.h" />
<moc Include="..\..\..\scribus\ui\downloadspalette.h" />
<ClInclude Include="..\..\..\scribus\text\textlayoutpainter.h" />
+ <ClInclude Include="..\..\..\scribus\text\textshaper.h" />
<ClInclude Include="..\..\..\scribus\ui\helpnavigation.h" />
<ClInclude Include="..\..\..\scribus\third_party\hyphen\hnjalloc.h" />
<moc Include="..\..\..\scribus\ui\hruler.h" />
@@ -919,6 +920,7 @@
<ClCompile Include="..\..\..\scribus\text\screenpainter.cpp" />
<ClCompile Include="..\..\..\scribus\text\textlayout.cpp" />
<ClCompile Include="..\..\..\scribus\text\textlayoutpainter.cpp" />
+ <ClCompile Include="..\..\..\scribus\text\textshaper.cpp" />
<ClCompile Include="..\..\..\scribus\third_party\fparser\fparser.cc" />
<ClCompile Include="..\..\..\scribus\third_party\fparser\fpoptimizer.cc" />
<ClCompile Include="..\..\..\scribus\ui\about.cpp" />
Modified: trunk/Scribus/win32/vc11/scribus-main/Scribus.vcxproj.filters
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21155&path=/trunk/Scribus/win32/vc11/scribus-main/Scribus.vcxproj.filters
==============================================================================
--- trunk/Scribus/win32/vc11/scribus-main/Scribus.vcxproj.filters (original)
+++ trunk/Scribus/win32/vc11/scribus-main/Scribus.vcxproj.filters Sun Apr 3 15:50:24 2016
@@ -1031,6 +1031,9 @@
<ClInclude Include="..\..\..\scribus\text\textlayoutpainter.h">
<Filter>Header Files</Filter>
</ClInclude>
+ <ClInclude Include="..\..\..\scribus\text\textshaper.h">
+ <Filter>Header Files</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\..\scribus\desaxe\digester.cpp">
@@ -2576,6 +2579,9 @@
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\..\scribus\text\boxes.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\..\scribus\text\textshaper.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
More information about the scribus-commit
mailing list