poppler/CairoFontEngine.h | 3 +++ poppler/CairoOutputDev.cc | 7 ++++++- poppler/CairoOutputDev.h | 2 ++ poppler/Form.cc | 6 +++--- 4 files changed, 14 insertions(+), 4 deletions(-)
New commits: commit bc4a0d9a2abfcd75d9b0ee4be3f7600905fe6001 Author: Marek Kasik <[email protected]> Date: Fri Jun 24 22:01:27 2022 +0200 Form: Provide Unicode marker when ensuring fonts Form::ensureFontsForAllCharacters() needs input text with Unicode marker. Provide such in FormFieldText::setContentCopy(). diff --git a/poppler/Form.cc b/poppler/Form.cc index d33160b3..9407b6c5 100644 --- a/poppler/Form.cc +++ b/poppler/Form.cc @@ -27,7 +27,7 @@ // Copyright 2019, 2020 Oliver Sander <[email protected]> // Copyright 2019 Tomoyuki Kubota <[email protected]> // Copyright 2019 João Netto <[email protected]> -// Copyright 2020, 2021 Marek Kasik <[email protected]> +// Copyright 2020-2022 Marek Kasik <[email protected]> // Copyright 2020 Thorsten Behrens <[email protected]> // Copyright 2020 Klarälvdalens Datakonsult AB, a KDAB Group company, <[email protected]>. Work sponsored by Technische Universität Dresden // Copyright 2021 Georgiy Sgibnev <[email protected]>. Work sponsored by lab50.net. @@ -1674,14 +1674,14 @@ void FormFieldText::setContentCopy(const GooString *new_content) Object fieldResourcesDictObj = obj.dictLookup("DR"); if (fieldResourcesDictObj.isDict()) { GfxResources fieldResources(doc->getXRef(), fieldResourcesDictObj.getDict(), form->getDefaultResources()); - const std::vector<Form::AddFontResult> newFonts = form->ensureFontsForAllCharacters(new_content, fontName, &fieldResources); + const std::vector<Form::AddFontResult> newFonts = form->ensureFontsForAllCharacters(content, fontName, &fieldResources); // If we added new fonts to the Form object default resuources we also need to add them (we only add the ref so this is cheap) // to the field DR dictionary for (const Form::AddFontResult &afr : newFonts) { fieldResourcesDictObj.dictLookup("Font").dictAdd(afr.fontName.c_str(), Object(afr.ref)); } } else { - form->ensureFontsForAllCharacters(new_content, fontName); + form->ensureFontsForAllCharacters(content, fontName); } } } else { commit 111f38a722eedddd94faa52dda8c5e0da561fb41 Author: Marek Kasik <[email protected]> Date: Fri Jun 24 22:00:09 2022 +0200 Cairo: Update font after restore Update font after restore (Q operator) if font has changed. This is important when entering text into forms if there are characters shown by default font after characters which needed new font. New method getRef() where added to CairoFont class to be able to easily compare fonts. diff --git a/poppler/CairoFontEngine.h b/poppler/CairoFontEngine.h index 56cc8825..c97e0ea4 100644 --- a/poppler/CairoFontEngine.h +++ b/poppler/CairoFontEngine.h @@ -22,6 +22,7 @@ // Copyright (C) 2013 Thomas Freitag <[email protected]> // Copyright (C) 2018 Adam Reichold <[email protected]> // Copyright (C) 2022 Oliver Sander <[email protected]> +// Copyright (C) 2022 Marek Kasik <[email protected]> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -59,6 +60,8 @@ public: bool isSubstitute() { return substitute; } + Ref getRef() { return ref; } + protected: Ref ref; cairo_font_face_t *cairo_font_face; diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc index b402cc8b..a72c218a 100644 --- a/poppler/CairoOutputDev.cc +++ b/poppler/CairoOutputDev.cc @@ -31,7 +31,7 @@ // Copyright (C) 2015 Suzuki Toshiya <[email protected]> // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <[email protected]>. Work sponsored by the LiMux project of the city of Munich // Copyright (C) 2018, 2020 Adam Reichold <[email protected]> -// Copyright (C) 2019, 2020 Marek Kasik <[email protected]> +// Copyright (C) 2019, 2020, 2022 Marek Kasik <[email protected]> // Copyright (C) 2020 Michal <[email protected]> // Copyright (C) 2020, 2022 Oliver Sander <[email protected]> // Copyright (C) 2021 Uli Schlachter <[email protected]> @@ -357,6 +357,7 @@ void CairoOutputDev::saveState(GfxState *state) elem.stroke_opacity = stroke_opacity; elem.mask = mask ? cairo_pattern_reference(mask) : nullptr; elem.mask_matrix = mask_matrix; + elem.fontRef = currentFont ? currentFont->getRef() : Ref::INVALID(); saveStateStack.push_back(elem); if (strokePathClip) { @@ -384,6 +385,10 @@ void CairoOutputDev::restoreState(GfxState *state) stroke_color = {}; stroke_opacity = saveStateStack.back().stroke_opacity; + if (saveStateStack.back().fontRef != (currentFont ? currentFont->getRef() : Ref::INVALID())) { + needFontUpdate = true; + } + /* This isn't restored by cairo_restore() since we keep it in the * output device. */ updateBlendMode(state); diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h index c287bf5c..5ce877d2 100644 --- a/poppler/CairoOutputDev.h +++ b/poppler/CairoOutputDev.h @@ -27,6 +27,7 @@ // Copyright (C) 2018 Klarälvdalens Datakonsult AB, a KDAB Group company, <[email protected]>. Work sponsored by the LiMux project of the city of Munich // Copyright (C) 2020 Michal <[email protected]> // Copyright (C) 2021 Christian Persch <[email protected]> +// Copyright (C) 2022 Marek Kasik <[email protected]> // // To see a description of the changes please see the Changelog file that // came with your tarball or type make ChangeLog if you are building from git @@ -381,6 +382,7 @@ protected: double stroke_opacity; cairo_pattern_t *mask; // can be null cairo_matrix_t mask_matrix; + Ref fontRef; }; std::vector<SaveStateElement> saveStateStack; };
