diff options
author | Khaled Hosny <khaled@aliftype.com> | 2022-11-27 03:58:47 +0200 |
---|---|---|
committer | خالد حسني <khaled@aliftype.com> | 2022-11-27 06:00:38 +0100 |
commit | 521ba0f495919022a77a189c52f632baef02a05c (patch) | |
tree | d5eb3f2dafcbce2468fca31eaf6649c7488d5940 /vcl | |
parent | 5b18eebc2c95321ce7e6edf10f4df81557382a48 (diff) |
tdf#102914: fix artificial italic of fallback fonts in PDF export
Check the LogicalFontInstance that the glyphs actually use when
deciding whether to do artificial italic or not.
Change-Id: Iefb60cf512285b94ff56d48923c3c33c6a6fbc40
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143338
Tested-by: Jenkins
Reviewed-by: خالد حسني <khaled@aliftype.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/pdf/pdfwriter_impl.hxx | 8 | ||||
-rw-r--r-- | vcl/source/gdi/pdfwriter_impl.cxx | 25 |
2 files changed, 21 insertions, 12 deletions
diff --git a/vcl/inc/pdf/pdfwriter_impl.hxx b/vcl/inc/pdf/pdfwriter_impl.hxx index b3222f4072fd..6f68478f2f61 100644 --- a/vcl/inc/pdf/pdfwriter_impl.hxx +++ b/vcl/inc/pdf/pdfwriter_impl.hxx @@ -615,6 +615,7 @@ struct PDFGlyph { DevicePoint const m_aPos; const GlyphItem* m_pGlyph; + const LogicalFontInstance* m_pFont; sal_Int32 const m_nNativeWidth; sal_Int32 const m_nMappedFontId; sal_uInt8 const m_nMappedGlyphId; @@ -622,11 +623,12 @@ struct PDFGlyph PDFGlyph( const DevicePoint& rPos, const GlyphItem* pGlyph, + const LogicalFontInstance* pFont, sal_Int32 nNativeWidth, sal_Int32 nFontId, sal_uInt8 nMappedGlyphId, int nCharPos ) - : m_aPos( rPos ), m_pGlyph(pGlyph), m_nNativeWidth( nNativeWidth ), + : m_aPos( rPos ), m_pGlyph(pGlyph), m_pFont(pFont), m_nNativeWidth( nNativeWidth ), m_nMappedFontId( nFontId ), m_nMappedGlyphId( nMappedGlyphId ), m_nCharPos(nCharPos) {} @@ -861,8 +863,8 @@ i12626 /* 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 */ - void drawVerticalGlyphs( const std::vector<PDFGlyph>& rGlyphs, OStringBuffer& rLine, const Point& rAlignOffset, const Matrix3& rRotScale, double fAngle, double fXScale, double fSkew, sal_Int32 nFontHeight ); - void drawHorizontalGlyphs( const std::vector<PDFGlyph>& rGlyphs, OStringBuffer& rLine, const Point& rAlignOffset, bool bFirst, double fAngle, double fXScale, double fSkew, sal_Int32 nFontHeight, sal_Int32 nPixelFontHeight ); + void drawVerticalGlyphs( const std::vector<PDFGlyph>& rGlyphs, OStringBuffer& rLine, const Point& rAlignOffset, const Matrix3& rRotScale, double fAngle, double fXScale, sal_Int32 nFontHeight ); + void drawHorizontalGlyphs( const std::vector<PDFGlyph>& rGlyphs, OStringBuffer& rLine, const Point& rAlignOffset, bool bFirst, double fAngle, double fXScale, sal_Int32 nFontHeight, sal_Int32 nPixelFontHeight ); void drawLayout( SalLayout& rLayout, const OUString& rText, bool bTextLines ); void drawRelief( SalLayout& rLayout, const OUString& rText, bool bTextLines ); void drawShadow( SalLayout& rLayout, const OUString& rText, bool bTextLines ); diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index d107e8996629..34785e2da3f7 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -6315,7 +6315,6 @@ void PDFWriterImpl::drawVerticalGlyphs( const Matrix3& rRotScale, double fAngle, double fXScale, - double fSkew, sal_Int32 nFontHeight) { double nXOffset = 0; @@ -6327,6 +6326,12 @@ void PDFWriterImpl::drawVerticalGlyphs( double fDeltaAngle = 0.0; double fYScale = 1.0; double fTempXScale = fXScale; + + // perform artificial italics if necessary + double fSkew = 0.0; + if (rGlyphs[i].m_pFont->NeedsArtificialItalic()) + fSkew = ARTIFICIAL_ITALIC_SKEW; + double fSkewB = fSkew; double fSkewA = 0.0; @@ -6381,7 +6386,6 @@ void PDFWriterImpl::drawHorizontalGlyphs( bool bFirst, double fAngle, double fXScale, - double fSkew, sal_Int32 nFontHeight, sal_Int32 nPixelFontHeight) { @@ -6395,6 +6399,7 @@ void PDFWriterImpl::drawHorizontalGlyphs( for( size_t i = 1; i < rGlyphs.size(); i++ ) { if( rGlyphs[i].m_nMappedFontId != rGlyphs[i-1].m_nMappedFontId || + rGlyphs[i].m_pFont != rGlyphs[i-1].m_pFont || rGlyphs[i].m_aPos.getY() != rGlyphs[i-1].m_aPos.getY() ) { aRunEnds.push_back(i); @@ -6410,6 +6415,12 @@ void PDFWriterImpl::drawHorizontalGlyphs( // setup text matrix back transformed to current coordinate system Point aCurPos(SubPixelToLogic(rGlyphs[nBeginRun].m_aPos)); aCurPos += rAlignOffset; + + // perform artificial italics if necessary + double fSkew = 0.0; + if (rGlyphs[nBeginRun].m_pFont->NeedsArtificialItalic()) + fSkew = ARTIFICIAL_ITALIC_SKEW; + // the first run can be set with "Td" operator // subsequent use of that operator would move // the textline matrix relative to what was set before @@ -6498,7 +6509,6 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool bool bVertical = m_aCurrentPDFState.m_aFont.IsVertical(); int nIndex = 0; double fXScale = 1.0; - double fSkew = 0.0; sal_Int32 nPixelFontHeight = GetFontInstance()->GetFontSelectPattern().mnHeight; TextAlign eAlign = m_aCurrentPDFState.m_aFont.GetAlignment(); @@ -6518,10 +6528,6 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool } } - // perform artificial italics if necessary - if (GetFontInstance()->NeedsArtificialItalic()) - fSkew = ARTIFICIAL_ITALIC_SKEW; - // if the mapmode is distorted we need to adjust for that also if( m_aCurrentPDFState.m_aMapMode.GetScaleX() != m_aCurrentPDFState.m_aMapMode.GetScaleY() ) { @@ -6674,6 +6680,7 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool aGlyphs.emplace_back(aPos, pGlyph, + pGlyphFont, XUnits(pFace->UnitsPerEm(), nGlyphWidth), nMappedFontObject, nMappedGlyph, @@ -6763,9 +6770,9 @@ void PDFWriterImpl::drawLayout( SalLayout& rLayout, const OUString& rText, bool } if (bVertical) - drawVerticalGlyphs(aRun, aLine, aAlignOffset, aRotScale, fAngle, fXScale, fSkew, nFontHeight); + drawVerticalGlyphs(aRun, aLine, aAlignOffset, aRotScale, fAngle, fXScale, nFontHeight); else - drawHorizontalGlyphs(aRun, aLine, aAlignOffset, nStart == 0, fAngle, fXScale, fSkew, nFontHeight, nPixelFontHeight); + drawHorizontalGlyphs(aRun, aLine, aAlignOffset, nStart == 0, fAngle, fXScale, nFontHeight, nPixelFontHeight); if (nCharPos >= 0 && nCharCount) aLine.append( "EMC\n" ); |