[poppler] poppler/Form.cc
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Aug 2 22:28:09 UTC 2023
poppler/Form.cc | 6 ++++++
1 file changed, 6 insertions(+)
New commits:
commit 1f1823045d71cc2f00ef43320cd181adf68a9d9f
Author: Sune Vuorela <sune at vuorela.dk>
Date: Tue Jul 18 10:07:50 2023 +0200
Don't look up same glyph multiple times
When iterating over the unicode codepoints, no need to check the fonts
if they still contains the same glyph as we already checked.
diff --git a/poppler/Form.cc b/poppler/Form.cc
index 54ab05b1..b30bfc7e 100644
--- a/poppler/Form.cc
+++ b/poppler/Form.cc
@@ -80,6 +80,7 @@
#include <ft2build.h>
#include FT_FREETYPE_H
+#include <unordered_set>
// helper for using std::visit to get a dependent false for static_asserts
// to help get compile errors if one ever extends variants
@@ -3022,6 +3023,7 @@ std::vector<Form::AddFontResult> Form::ensureFontsForAllCharacters(const GooStri
std::vector<AddFontResult> newFonts;
// If the text has some characters that are not available in the font, try adding a font for those
+ std::unordered_set<Unicode> seen;
for (int i = 2; i < unicodeText->getLength(); i += 2) {
Unicode uChar = (unsigned char)(unicodeText->getChar(i)) << 8;
uChar += (unsigned char)(unicodeText->getChar(i + 1));
@@ -3029,6 +3031,10 @@ std::vector<Form::AddFontResult> Form::ensureFontsForAllCharacters(const GooStri
if (uChar < 128 && !std::isprint(static_cast<unsigned char>(uChar))) {
continue;
}
+ if (seen.find(uChar) != seen.end()) {
+ continue;
+ }
+ seen.insert(uChar);
CharCode c;
bool addFont = false;
More information about the poppler
mailing list