r24726 by jghali - #16645: Text using alternate-form glyphs cannot be copied from PDF

scribus-commit scribus-commit at lists.scribus.net
Sun Oct 3 14:12:14 UTC 2021


Author: jghali
Date: Sun Oct  3 14:12:14 2021
New Revision: 24726

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24726
Log:
#16645: Text using alternate-form glyphs cannot be copied from PDF

Modified:
    trunk/Scribus/scribus/pdflib_core.cpp

Modified: trunk/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24726&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp	(original)
+++ trunk/Scribus/scribus/pdflib_core.cpp	Sun Oct  3 14:12:14 2021
@@ -28,6 +28,8 @@
 #if defined(_MSC_VER) && !defined(_USE_MATH_DEFINES)
 #define _USE_MATH_DEFINES
 #endif
+
+#include <algorithm>
 #include <cmath>
 #include <cstdlib>
 #include <string>
@@ -1741,7 +1743,13 @@
 
 	ScFace::FaceEncoding encoding;
 	face.glyphNames(encoding);
-	QList<uint> keys = encoding.uniqueKeys();
+
+	// In some case (arial!), all used glyphs may not be listed in the  encoding map,
+	// and glyphs such as old numerals may be found only in the usedGlyphs map
+	QList<uint> keys = encoding.uniqueKeys() + usedGlyphs.uniqueKeys();
+	std::sort(keys.begin(), keys.end());
+	auto lastIt = std::unique(keys.begin(), keys.end());
+	keys.erase(lastIt, keys.end());
 	bool seenNotDef = false;
 	
 	PutDoc("[ ");
@@ -1755,6 +1763,7 @@
 		PutDoc(Pdf::toPdf(gid) + " [" + Pdf::toPdf(static_cast<int>(face.glyphWidth(*git) * 1000)) + "] ");
 		QString tmp = QString::asprintf("%04X", gid);
 		QString tmp2;
+
 		auto  glyphIt = encoding.constFind(*git);
 		if ((glyphIt != encoding.constEnd()) && (glyphIt->charcode > 0))
 			tmp2 = glyphIt->toUnicode;




More information about the scribus-commit mailing list