summaryrefslogtreecommitdiff
path: root/vcl/inc
diff options
context:
space:
mode:
authorKhaled Hosny <khaled@aliftype.com>2022-06-06 00:17:02 +0200
committerCaolán McNamara <caolanm@redhat.com>2022-06-09 10:03:51 +0200
commitbe39eba9a3d81e20c42f1073a365e91ce855c1cd (patch)
treeac73dbeff2745895396db7cd8a2de4211445f47b /vcl/inc
parent136fac12eb9752f1072f852cc193d6a9accdc4a7 (diff)
Use same glyph width in PDF drawing and font subset
During PDF drawing we already know the glyph width, but when subsetting we get it again from the font subset. For fonts without CFF table this is redundant but harmless, but for fonts with CFF table, if the CFF and hmtx table (the authoritative source of glyph widths) disagree, we will be drawing the PDF string with the wrong adjustment resulting in displaced glyphs. This is a font bug, but avoiding redundancy and having one source of truth is an improvement overall. I kept the code that calculates advance widths for font subsets, just in case it is is still used elsewhere. Change-Id: I757cd0c2ebb6477b2f840d0005e84b5a131f7efb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135442 Tested-by: Jenkins Tested-by: Caolán McNamara <caolanm@redhat.com> Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/inc')
-rw-r--r--vcl/inc/pdf/pdfwriter_impl.hxx8
1 files changed, 6 insertions, 2 deletions
diff --git a/vcl/inc/pdf/pdfwriter_impl.hxx b/vcl/inc/pdf/pdfwriter_impl.hxx
index ae461895a55b..869ba7883458 100644
--- a/vcl/inc/pdf/pdfwriter_impl.hxx
+++ b/vcl/inc/pdf/pdfwriter_impl.hxx
@@ -287,15 +287,19 @@ class GlyphEmit
// performance: actually this should probably a vector;
std::vector<sal_Ucs> m_CodeUnits;
sal_uInt8 m_nSubsetGlyphID;
+ sal_Int32 m_nGlyphWidth;
public:
- GlyphEmit() : m_nSubsetGlyphID(0)
+ GlyphEmit() : m_nSubsetGlyphID(0), m_nGlyphWidth(0)
{
}
void setGlyphId( sal_uInt8 i_nId ) { m_nSubsetGlyphID = i_nId; }
sal_uInt8 getGlyphId() const { return m_nSubsetGlyphID; }
+ void setGlyphWidth( sal_Int32 nWidth ) { m_nGlyphWidth = nWidth; }
+ sal_Int32 getGlyphWidth() const { return m_nGlyphWidth; }
+
void addCode( sal_Ucs i_cCode )
{
m_CodeUnits.push_back(i_cCode);
@@ -817,7 +821,7 @@ i12626
void appendLiteralStringEncrypt( std::string_view rInString, const sal_Int32 nInObjectNumber, OStringBuffer& rOutBuffer );
/* creates fonts and subsets that will be emitted later */
- void registerGlyph(const GlyphItem* pGlyph, const vcl::font::PhysicalFontFace* pFont, const std::vector<sal_Ucs>& rCodeUnits, sal_uInt8& nMappedGlyph, sal_Int32& nMappedFontObject);
+ void registerGlyph(const GlyphItem* pGlyph, const vcl::font::PhysicalFontFace* pFont, const std::vector<sal_Ucs>& rCodeUnits, sal_Int32 nGlyphWidth, sal_uInt8& nMappedGlyph, sal_Int32& nMappedFontObject);
/* emits a text object according to the passed layout */
/* TODO: remove rText as soon as SalLayout will change so that rText is not necessary anymore */