diff options
author | Michael Stahl <mstahl@redhat.com> | 2015-01-27 00:20:58 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2015-01-27 14:42:13 +0100 |
commit | 5183910a90e97cafc3cfaaad40acdaec0b792f6d (patch) | |
tree | 659334063e885f5348e692faf7e8774ec67b080e /vcl/inc | |
parent | ad3e0989d137ef765d634cb07a7a7a46ecc774ff (diff) |
rhbz#1177022: vcl: fix PDF embedding of Type 1 fonts
Problem is that for the "CM Typewriter" font the Width for "space" (32)
is exported as 0 instead of 525, which is the correct value in the AFM.
The reason is that PDFWriterImpl::emitEmbeddedFont() has various arrays
to map from font code points to Unicode code points, and there are
duplicate mappings, so the 160->32 mapping overrides 32->32.
The PrintFontManager::PrintFont::readAfmMetrics() actually creates a
Unicode to font code mapping (which may legitimately be n:1) that is
then inverted; add an additional hack to store a set of "preferred"
Unicodes so that PDFWriterImpl can pick the right Unicode.
Presumably the code that is stored explicitly via "C" or "CH" in the
AFM should take priority over more generic mappings.
Change-Id: Id4205a1cd45ba6a0a5facee1e39f70c3535e7dd4
Diffstat (limited to 'vcl/inc')
-rw-r--r-- | vcl/inc/cairotextrender.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/fontmanager.hxx | 7 | ||||
-rw-r--r-- | vcl/inc/generic/genpspgraphics.h | 6 | ||||
-rw-r--r-- | vcl/inc/headless/svpgdi.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/quartz/salgdi.h | 2 | ||||
-rw-r--r-- | vcl/inc/salgdi.hxx | 4 | ||||
-rw-r--r-- | vcl/inc/textrender.hxx | 2 | ||||
-rw-r--r-- | vcl/inc/unx/salgdi.h | 2 | ||||
-rw-r--r-- | vcl/inc/win/salgdi.h | 2 |
9 files changed, 19 insertions, 10 deletions
diff --git a/vcl/inc/cairotextrender.hxx b/vcl/inc/cairotextrender.hxx index d94596847ee5..87eede066651 100644 --- a/vcl/inc/cairotextrender.hxx +++ b/vcl/inc/cairotextrender.hxx @@ -109,7 +109,7 @@ public: int nGlyphs, FontSubsetInfo& rInfo) SAL_OVERRIDE; - virtual const Ucs2SIntMap* GetFontEncodingVector( const PhysicalFontFace*, const Ucs2OStrMap** ppNonEncoded ) SAL_OVERRIDE; + virtual const Ucs2SIntMap* GetFontEncodingVector( const PhysicalFontFace*, const Ucs2OStrMap** ppNonEncoded, std::set<sal_Unicode> const**) SAL_OVERRIDE; virtual const void* GetEmbedFontData( const PhysicalFontFace*, const sal_Ucs* pUnicodes, diff --git a/vcl/inc/fontmanager.hxx b/vcl/inc/fontmanager.hxx index beec12ad838f..1de2e70fcfb6 100644 --- a/vcl/inc/fontmanager.hxx +++ b/vcl/inc/fontmanager.hxx @@ -202,7 +202,12 @@ class VCL_PLUGIN_PUBLIC PrintFontManager bool m_bHaveVerticalSubstitutedGlyphs; bool m_bUserOverride; + /// mapping from unicode (well, UCS-2) to font code std::map< sal_Unicode, sal_Int32 > m_aEncodingVector; + /// HACK for Type 1 fonts: if multiple UCS-2 codes map to the same + /// font code, this set contains the preferred one, i.e., the one that + /// is specified explicitly via "C" or "CH" in the AFM file + std::set<sal_Unicode> m_aEncodingVectorPriority; std::map< sal_Unicode, OString > m_aNonEncoded; explicit PrintFont( fonttype::type eType ); @@ -438,7 +443,7 @@ public: // if ppNonEncoded is set and non encoded type1 glyphs exist // then *ppNonEncoded is set to the mapping for nonencoded glyphs. // the encoding vector contains -1 for non encoded glyphs - const std::map< sal_Unicode, sal_Int32 >* getEncodingMap( fontID nFontID, const std::map< sal_Unicode, OString >** ppNonEncoded ) const; + const std::map< sal_Unicode, sal_Int32 >* getEncodingMap( fontID nFontID, const std::map< sal_Unicode, OString >** ppNonEncoded, std::set<sal_Unicode> const ** ppPriority ) const; // evaluates copyright flags for TrueType fonts for printing/viewing // type1 fonts do not have such a feature, so return for them is true diff --git a/vcl/inc/generic/genpspgraphics.h b/vcl/inc/generic/genpspgraphics.h index b4ac3137e5d9..27e4a62c05e5 100644 --- a/vcl/inc/generic/genpspgraphics.h +++ b/vcl/inc/generic/genpspgraphics.h @@ -60,7 +60,8 @@ public: // helper methods for sharing with X11SalGraphics static const Ucs2SIntMap* DoGetFontEncodingVector( psp::fontID aFont, - const Ucs2OStrMap** pNonEncoded ); + const Ucs2OStrMap** pNonEncoded, + std::set<sal_Unicode> const** ppPriority); static void DoGetGlyphWidths( psp::fontID aFont, bool bVertical, Int32Vector& rWidths, @@ -107,7 +108,8 @@ public: int nGlyphs, FontSubsetInfo& rInfo ) SAL_OVERRIDE; virtual const Ucs2SIntMap* GetFontEncodingVector( const PhysicalFontFace*, - const Ucs2OStrMap** ppNonEncoded ) SAL_OVERRIDE; + const Ucs2OStrMap** ppNonEncoded, + std::set<sal_Unicode> const** ppPriority) SAL_OVERRIDE; virtual const void* GetEmbedFontData( const PhysicalFontFace*, const sal_Ucs* pUnicodes, sal_Int32* pWidths, diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx index dc0c62ffd7c4..46081402a10e 100644 --- a/vcl/inc/headless/svpgdi.hxx +++ b/vcl/inc/headless/svpgdi.hxx @@ -127,7 +127,7 @@ public: int nGlyphs, FontSubsetInfo& rInfo ) SAL_OVERRIDE; - virtual const Ucs2SIntMap* GetFontEncodingVector( const PhysicalFontFace*, const Ucs2OStrMap** ppNonEncoded ) SAL_OVERRIDE; + virtual const Ucs2SIntMap* GetFontEncodingVector( const PhysicalFontFace*, const Ucs2OStrMap** ppNonEncoded, std::set<sal_Unicode> const** ) SAL_OVERRIDE; virtual const void* GetEmbedFontData( const PhysicalFontFace*, const sal_Ucs* pUnicodes, sal_Int32* pWidths, diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h index 9c9c741d93cc..eb55e9655ea4 100644 --- a/vcl/inc/quartz/salgdi.h +++ b/vcl/inc/quartz/salgdi.h @@ -381,7 +381,7 @@ public: // glyphs with only a name) exist it is set to the corresponding // map for non encoded glyphs; the encoding vector contains -1 // as encoding for these cases - virtual const Ucs2SIntMap* GetFontEncodingVector( const PhysicalFontFace*, const Ucs2OStrMap** ppNonEncoded ) SAL_OVERRIDE; + virtual const Ucs2SIntMap* GetFontEncodingVector( const PhysicalFontFace*, const Ucs2OStrMap** ppNonEncoded, std::set<sal_Unicode> const** ) SAL_OVERRIDE; // GetEmbedFontData: gets the font data for a font marked // embeddable by GetDevFontList or NULL in case of error diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx index b42e0b4a2ea1..6e5e80079296 100644 --- a/vcl/inc/salgdi.hxx +++ b/vcl/inc/salgdi.hxx @@ -34,6 +34,7 @@ #include "sallayout.hxx" #include <map> +#include <set> class PhysicalFontCollection; class SalBitmap; @@ -188,7 +189,8 @@ public: // as encoding for these cases virtual const Ucs2SIntMap* GetFontEncodingVector( const PhysicalFontFace*, - const Ucs2OStrMap** ppNonEncoded ) = 0; + const Ucs2OStrMap** ppNonEncoded, + std::set<sal_Unicode> const** ppPriority) = 0; // GetEmbedFontData: gets the font data for a font marked // embeddable by GetDevFontList or NULL in case of error diff --git a/vcl/inc/textrender.hxx b/vcl/inc/textrender.hxx index 4a635c5d1543..60925bbfb67e 100644 --- a/vcl/inc/textrender.hxx +++ b/vcl/inc/textrender.hxx @@ -59,7 +59,7 @@ public: int nGlyphs, FontSubsetInfo& rInfo) = 0; - virtual const Ucs2SIntMap* GetFontEncodingVector( const PhysicalFontFace*, const Ucs2OStrMap** ppNonEncoded ) = 0; + virtual const Ucs2SIntMap* GetFontEncodingVector( const PhysicalFontFace*, const Ucs2OStrMap** ppNonEncoded, std::set<sal_Unicode> const** ppPriority) = 0; virtual const void* GetEmbedFontData( const PhysicalFontFace*, const sal_Ucs* pUnicodes, diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h index 4486e8cb928c..97a5ac2371da 100644 --- a/vcl/inc/unx/salgdi.h +++ b/vcl/inc/unx/salgdi.h @@ -132,7 +132,7 @@ public: int nGlyphs, FontSubsetInfo& rInfo ) SAL_OVERRIDE; - virtual const Ucs2SIntMap* GetFontEncodingVector( const PhysicalFontFace*, const Ucs2OStrMap** ppNonEncoded ) SAL_OVERRIDE; + virtual const Ucs2SIntMap* GetFontEncodingVector( const PhysicalFontFace*, const Ucs2OStrMap** ppNonEncoded, std::set<sal_Unicode> const**) SAL_OVERRIDE; virtual const void* GetEmbedFontData( const PhysicalFontFace*, diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h index 5ff953061498..d78b1918decb 100644 --- a/vcl/inc/win/salgdi.h +++ b/vcl/inc/win/salgdi.h @@ -411,7 +411,7 @@ public: // glyphs with only a name) exist it is set to the corresponding // map for non encoded glyphs; the encoding vector contains -1 // as encoding for these cases - virtual const Ucs2SIntMap* GetFontEncodingVector( const PhysicalFontFace*, const Ucs2OStrMap** ppNonEncoded ); + virtual const Ucs2SIntMap* GetFontEncodingVector( const PhysicalFontFace*, const Ucs2OStrMap** ppNonEncoded, std::set<sal_Unicode> const** ); // GetEmbedFontData: gets the font data for a font marked // embeddable by GetDevFontList or NULL in case of error |