r22539 by jghali - #15318: Page number glyphs partially render as boxes/blank during PDF export in certain circumstances
scribus-commit
scribus-commit at lists.scribus.net
Sun May 13 12:34:10 UTC 2018
Author: jghali
Date: Sun May 13 12:34:10 2018
New Revision: 22539
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22539
Log:
#15318: Page number glyphs partially render as boxes/blank during PDF export in certain circumstances
Modified:
trunk/Scribus/scribus/scribusdoc.cpp
Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22539&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Sun May 13 12:34:10 2018
@@ -4505,106 +4505,36 @@
UsedGlyphsPainter p(Really);
it->textLayout.render(&p);
- // Process page numbers and page count special characters
- int start = it->isTextFrame() ? it->firstInFrame() : 0;
- int stop = it->isTextFrame() ? it->lastInFrame() + 1 : it->itemText.length();
- for (int e = start; e < stop; ++e)
- {
- const ScFace& font = it->itemText.charStyle(e).font();
- double fontSize = it->itemText.charStyle(e).fontSize();
- QString fontName = font.replacementName();
- if (!Really.contains(fontName) )
- {
- if (!fontName.isEmpty())
- Really.insert(fontName, QMap<uint, FPointArray>());
- }
- uint chr = it->itemText.text(e).unicode();
- if ((chr != SpecialChars::PAGENUMBER ) && (chr != SpecialChars::PAGECOUNT))
- continue;
-
- QStringList txtList;
- QString pageNumberText; //Our page number collection string
- if (chr == SpecialChars::PAGENUMBER)
- {
- if (e > 0 && it->itemText.text(e-1) == SpecialChars::PAGENUMBER)
- pageNumberText = SpecialChars::ZWNBSPACE;
- else if (lc!=0) //If not on a master page just get the page number for the page and the text
- {
- pageNumberText = QString("%1").arg(getSectionPageNumberForPageIndex(it->OwnPage),
- getSectionPageNumberWidthForPageIndex(it->OwnPage),
- getSectionPageNumberFillCharForPageIndex(it->OwnPage));
- txtList.append(pageNumberText);
- }
- else
- {
- //Else, for a page number in a text frame on a master page we must scan
- //all pages to see which ones use this page and get their page numbers.
- //We only add each character of the pages' page number text if its nothing
- //already in the pageNumberText variable. No need to add glyphs twice.
- QString newText;
- uint docPageCount = DocPages.count();
- for (uint a = 0; a < docPageCount; ++a)
- {
- if (DocPages.at(a)->MPageNam == it->OnMasterPage)
- {
- newText = QString("%1").arg(getSectionPageNumberForPageIndex(a),
- getSectionPageNumberWidthForPageIndex(a),
- getSectionPageNumberFillCharForPageIndex(a));
- txtList.append(newText);
- }
- }
- }
- }
- else //ch == SpecialChars::PAGECOUNT
- {
- if (lc != 0)
- {
- int key = getSectionKeyForPageIndex(it->OwnPage);
- if (key == -1)
- pageNumberText = "";
- else
- pageNumberText = QString("%1").arg(getStringFromSequence(m_docPrefsData.docSectionMap[key].type, m_docPrefsData.docSectionMap[key].toindex - m_docPrefsData.docSectionMap[key].fromindex + 1));
- txtList.append(pageNumberText);
- }
- else
- {
- QString newText;
- int docPageCount = DocPages.count();
- for (int a = 0; a < docPageCount; ++a)
- {
- if (DocPages.at(a)->MPageNam == it->OnMasterPage)
- {
- int key = getSectionKeyForPageIndex(a);
- if (key == -1)
- newText = "";
- else
- newText = QString("%1").arg(getStringFromSequence(m_docPrefsData.docSectionMap[key].type, m_docPrefsData.docSectionMap[key].toindex - m_docPrefsData.docSectionMap[key].fromindex + 1));
- txtList.append(newText);
- }
- }
- }
- }
-
- //Now scan and add any glyphs used in page numbers
- for (int a = 0; a < txtList.count(); ++a)
- {
- CharStyle style(font, fontSize);
- StoryText story;
- story.insertChars(txtList[a]);
- story.setCharStyle(0, txtList[a].count(), style);
-
- TextShaper textShaper(story, 0);
- const QList<GlyphCluster> glyphRuns = textShaper.shape(0, story.length()).glyphs();
-
- for (const GlyphCluster &run : glyphRuns)
- {
- for (const GlyphLayout &gl : run.glyphs())
- {
- FPointArray outline(font.glyphOutline(gl.glyph));
- if (!fontName.isEmpty())
- Really[fontName].insert(gl.glyph, outline);
- }
- }
+ // Process page numbers and page count special characters on master pages
+ if (!it->OnMasterPage.isEmpty())
+ {
+ bool hasPageNumbers = false;
+
+ int start = it->isTextFrame() ? it->firstInFrame() : 0;
+ int stop = it->isTextFrame() ? it->lastInFrame() + 1 : it->itemText.length();
+ for (int e = start; e < stop; ++e)
+ {
+ uint chr = it->itemText.text(e).unicode();
+ if ((chr == SpecialChars::PAGENUMBER) || (chr == SpecialChars::PAGECOUNT))
+ {
+ hasPageNumbers = true;
+ break;
+ }
+ }
+
+ if (hasPageNumbers)
+ {
+ it->savedOwnPage = it->OwnPage;
+ int docPageCount = DocPages.count();
+ for (int i = 0; i < docPageCount; ++i)
+ {
+ it->OwnPage = i;
+ it->invalid = true;
+ it->layout();
+ it->textLayout.render(&p);
+ }
+ it->OwnPage = it->savedOwnPage;
+ it->invalid = true;
}
}
More information about the scribus-commit
mailing list