vcl/inc/pdf/pdfwriter_impl.hxx    |    8 +++++---
 vcl/quartz/salgdi.cxx             |    5 -----
 vcl/source/gdi/pdfwriter_impl.cxx |   25 ++++++++++++++++---------
 3 files changed, 21 insertions(+), 17 deletions(-)

New commits:
commit ae2d1315766581259756c819f0227270d344f4d4
Author:     Khaled Hosny <[email protected]>
AuthorDate: Sun Nov 27 05:10:29 2022 +0200
Commit:     خالد حسني <[email protected]>
CommitDate: Sun Nov 27 06:00:56 2022 +0100

    tdf#102914: keep font attributes for the substituted fallback font
    
    Setting italic to that of the found font seems to prevent artificial
    italic in PDF export. We want to keep the original select pattern
    attributes so that we know we asked for italic font but got a non-italic
    one.
    
    Change-Id: I0cf400e86d802028dffdabbb98e35e3ee584626e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/143339
    Tested-by: Jenkins
    Reviewed-by: خالد حسني <[email protected]>

diff --git a/vcl/quartz/salgdi.cxx b/vcl/quartz/salgdi.cxx
index 661a7e76735e..1058b7bc31e9 100644
--- a/vcl/quartz/salgdi.cxx
+++ b/vcl/quartz/salgdi.cxx
@@ -111,11 +111,6 @@ bool 
CoreTextGlyphFallbackSubstititution::FindFontSubstitute(vcl::font::FontSele
 
             rPattern.maSearchName = rAttr.GetFamilyName();
 
-            rPattern.SetWeight(rAttr.GetWeight());
-            rPattern.SetItalic(rAttr.GetItalic());
-            rPattern.SetPitch(rAttr.GetPitch());
-            rPattern.SetWidthType(rAttr.GetWidthType());
-
             CFRelease(pFallback);
             CFRelease(pDesc);
         }
commit 521ba0f495919022a77a189c52f632baef02a05c
Author:     Khaled Hosny <[email protected]>
AuthorDate: Sun Nov 27 03:58:47 2022 +0200
Commit:     خالد حسني <[email protected]>
CommitDate: Sun Nov 27 06:00:38 2022 +0100

    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: خالد حسني <[email protected]>

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" );

Reply via email to