summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
Diffstat (limited to 'vcl')
-rw-r--r--vcl/headless/svptext.cxx11
-rw-r--r--vcl/inc/font/PhysicalFontFace.hxx14
-rw-r--r--vcl/inc/headless/svpgdi.hxx7
-rw-r--r--vcl/inc/qt5/QtGraphics.hxx5
-rw-r--r--vcl/inc/quartz/salgdi.h19
-rw-r--r--vcl/inc/salgdi.hxx21
-rw-r--r--vcl/inc/textrender.hxx7
-rw-r--r--vcl/inc/unx/fontmanager.hxx18
-rw-r--r--vcl/inc/unx/freetypetextrender.hxx7
-rw-r--r--vcl/inc/unx/genpspgraphics.h6
-rw-r--r--vcl/inc/unx/salgdi.h8
-rw-r--r--vcl/inc/win/salgdi.h19
-rw-r--r--vcl/qt5/QtGraphics_Text.cxx32
-rw-r--r--vcl/quartz/salgdicommon.cxx44
-rw-r--r--vcl/source/font/PhysicalFontFace.cxx35
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx13
-rw-r--r--vcl/unx/generic/fontmanager/fontmanager.cxx113
-rw-r--r--vcl/unx/generic/gdi/font.cxx13
-rw-r--r--vcl/unx/generic/gdi/freetypetextrender.cxx19
-rw-r--r--vcl/unx/generic/print/genpspgraphics.cxx19
-rw-r--r--vcl/win/gdi/salfont.cxx33
21 files changed, 53 insertions, 410 deletions
diff --git a/vcl/headless/svptext.cxx b/vcl/headless/svptext.cxx
index 26d0d3966f4e..782caba56971 100644
--- a/vcl/headless/svptext.cxx
+++ b/vcl/headless/svptext.cxx
@@ -62,17 +62,6 @@ bool SvpSalGraphics::AddTempDevFont( vcl::font::PhysicalFontCollection* pFontCol
return m_aTextRenderImpl.AddTempDevFont(pFontCollection, rFileURL, rFontName);
}
-bool SvpSalGraphics::CreateFontSubset(
- const OUString& rToFile,
- const vcl::font::PhysicalFontFace* pFont,
- const sal_GlyphId* pGlyphIds,
- const sal_uInt8* pEncoding,
- int nGlyphCount,
- FontSubsetInfo& rInfo)
-{
- return m_aTextRenderImpl.CreateFontSubset(rToFile, pFont, pGlyphIds, pEncoding, nGlyphCount, rInfo);
-}
-
const void* SvpSalGraphics::GetEmbedFontData(const vcl::font::PhysicalFontFace* pFont, tools::Long* pDataLen)
{
return m_aTextRenderImpl.GetEmbedFontData(pFont, pDataLen);
diff --git a/vcl/inc/font/PhysicalFontFace.hxx b/vcl/inc/font/PhysicalFontFace.hxx
index 3f59dd3b25e4..8521ce752f32 100644
--- a/vcl/inc/font/PhysicalFontFace.hxx
+++ b/vcl/inc/font/PhysicalFontFace.hxx
@@ -29,6 +29,7 @@
#include <vcl/fontcharmap.hxx>
#include <fontattributes.hxx>
+#include <fontsubset.hxx>
#include <hb.h>
@@ -111,6 +112,19 @@ public:
bool IsBetterMatch(const vcl::font::FontSelectPattern&, FontMatchStatus&) const;
sal_Int32 CompareIgnoreSize(const PhysicalFontFace&) const;
+ // CreateFontSubset: a method to get a subset of glyhps of a font inside a
+ // new valid font file
+ // returns true if creation of subset was successful
+ // parameters: rToFile: contains an osl file URL to write the subset to
+ // pGlyphIDs: the glyph ids to be extracted
+ // pEncoding: the character code corresponding to each glyph
+ // nGlyphs: the number of glyphs
+ // rInfo: additional outgoing information
+ // implementation note: encoding 0 with glyph id 0 should be added implicitly
+ // as "undefined character"
+ bool CreateFontSubset(const OUString&, const sal_GlyphId*, const sal_uInt8*, const int,
+ FontSubsetInfo&) const;
+
virtual hb_face_t* GetHbFace() const;
virtual hb_blob_t* GetHbTable(hb_tag_t) const
{
diff --git a/vcl/inc/headless/svpgdi.hxx b/vcl/inc/headless/svpgdi.hxx
index 441ccf201861..04e6bfa3eddf 100644
--- a/vcl/inc/headless/svpgdi.hxx
+++ b/vcl/inc/headless/svpgdi.hxx
@@ -77,13 +77,6 @@ public:
virtual void GetDevFontList( vcl::font::PhysicalFontCollection* ) override;
virtual void ClearDevFontCache() override;
virtual bool AddTempDevFont( vcl::font::PhysicalFontCollection*, const OUString& rFileURL, const OUString& rFontName ) override;
- virtual bool CreateFontSubset( const OUString& rToFile,
- const vcl::font::PhysicalFontFace*,
- const sal_GlyphId* pGlyphIds,
- const sal_uInt8* pEncoding,
- int nGlyphs,
- FontSubsetInfo& rInfo
- ) override;
virtual const void* GetEmbedFontData(const vcl::font::PhysicalFontFace*, tools::Long* pDataLen) override;
virtual void FreeEmbedFontData( const void* pData, tools::Long nDataLen ) override;
virtual std::unique_ptr<GenericSalLayout>
diff --git a/vcl/inc/qt5/QtGraphics.hxx b/vcl/inc/qt5/QtGraphics.hxx
index e8f5fdd9a58e..987ab1601f38 100644
--- a/vcl/inc/qt5/QtGraphics.hxx
+++ b/vcl/inc/qt5/QtGraphics.hxx
@@ -231,11 +231,6 @@ public:
virtual void ClearDevFontCache() override;
virtual bool AddTempDevFont(vcl::font::PhysicalFontCollection*, const OUString& rFileURL,
const OUString& rFontName) override;
- virtual bool CreateFontSubset(const OUString& rToFile, const vcl::font::PhysicalFontFace* pFont,
- const sal_GlyphId* pGlyphIds, const sal_uInt8* pEncoding,
- int nGlyphs,
- FontSubsetInfo& rInfo // out parameter
- ) override;
virtual const void* GetEmbedFontData(const vcl::font::PhysicalFontFace*,
tools::Long* pDataLen) override;
diff --git a/vcl/inc/quartz/salgdi.h b/vcl/inc/quartz/salgdi.h
index c809e9d39670..4435e9fd86c9 100644
--- a/vcl/inc/quartz/salgdi.h
+++ b/vcl/inc/quartz/salgdi.h
@@ -536,25 +536,6 @@ public:
// graphics must drop any cached font info
virtual void ClearDevFontCache() override;
virtual bool AddTempDevFont( vcl::font::PhysicalFontCollection*, const OUString& rFileURL, const OUString& rFontName ) override;
- // CreateFontSubset: a method to get a subset of glyhps of a font
- // inside a new valid font file
- // returns TRUE if creation of subset was successful
- // parameters: rToFile: contains an osl file URL to write the subset to
- // pFont: describes from which font to create a subset
- // pGlyphIDs: the glyph ids to be extracted
- // pEncoding: the character code corresponding to each glyph
- // pWidths: the advance widths of the corresponding glyphs (in PS font units)
- // nGlyphs: the number of glyphs
- // rInfo: additional outgoing information
- // implementation note: encoding 0 with glyph id 0 should be added implicitly
- // as "undefined character"
- virtual bool CreateFontSubset( const OUString& rToFile,
- const vcl::font::PhysicalFontFace* pFont,
- const sal_GlyphId* pGlyphIds,
- const sal_uInt8* pEncoding,
- int nGlyphs,
- FontSubsetInfo& rInfo // out parameter
- ) 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 cad89819efa8..4521785e3971 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -161,26 +161,6 @@ public:
const OUString& rFileURL,
const OUString& rFontName ) = 0;
- // CreateFontSubset: a method to get a subset of glyhps of a font
- // inside a new valid font file
- // returns true if creation of subset was successful
- // parameters: rToFile: contains an osl file URL to write the subset to
- // pFont: describes from which font to create a subset
- // pGlyphIDs: the glyph ids to be extracted
- // pEncoding: the character code corresponding to each glyph
- // pWidths: the advance widths of the corresponding glyphs (in PS font units)
- // nGlyphs: the number of glyphs
- // rInfo: additional outgoing information
- // implementation note: encoding 0 with glyph id 0 should be added implicitly
- // as "undefined character"
- virtual bool CreateFontSubset(
- const OUString& rToFile,
- const vcl::font::PhysicalFontFace* pFont,
- const sal_GlyphId* pGlyphIDs,
- const sal_uInt8* pEncoding,
- int nGlyphs,
- FontSubsetInfo& rInfo ) = 0;
-
// GetEmbedFontData: gets the font data for a font marked
// embeddable by GetDevFontList or NULL in case of error
// parameters: pFont: describes the font in question
@@ -651,6 +631,7 @@ protected:
std::unique_ptr<vcl::WidgetDrawInterface> m_pWidgetDraw;
vcl::WidgetDrawInterface* forWidget() { return m_pWidgetDraw ? m_pWidgetDraw.get() : this; }
+public:
static bool CreateTTFfontSubset(vcl::AbstractTrueTypeFont& aTTF, const OString& rSysPath,
const sal_GlyphId* pGlyphIds,
const sal_uInt8* pEncoding,
diff --git a/vcl/inc/textrender.hxx b/vcl/inc/textrender.hxx
index cb6594c8a6f7..6675e6aebb5c 100644
--- a/vcl/inc/textrender.hxx
+++ b/vcl/inc/textrender.hxx
@@ -42,13 +42,6 @@ public:
virtual void GetDevFontList( vcl::font::PhysicalFontCollection* ) = 0;
virtual void ClearDevFontCache() = 0;
virtual bool AddTempDevFont( vcl::font::PhysicalFontCollection*, const OUString& rFileURL, const OUString& rFontName ) = 0;
- virtual bool CreateFontSubset(
- const OUString& rToFile,
- const vcl::font::PhysicalFontFace*,
- const sal_GlyphId* pGlyphIDs,
- const sal_uInt8* pEncoding,
- int nGlyphs,
- FontSubsetInfo& rInfo) = 0;
virtual const void* GetEmbedFontData(const vcl::font::PhysicalFontFace*, tools::Long* pDataLen) = 0;
virtual void FreeEmbedFontData( const void* pData, tools::Long nDataLen ) = 0;
diff --git a/vcl/inc/unx/fontmanager.hxx b/vcl/inc/unx/fontmanager.hxx
index f85a80901f74..059ffe1a7e58 100644
--- a/vcl/inc/unx/fontmanager.hxx
+++ b/vcl/inc/unx/fontmanager.hxx
@@ -45,7 +45,6 @@
*/
class FontAttributes;
-class FontSubsetInfo;
class FontConfigFontOptions;
namespace vcl::font
{
@@ -265,23 +264,6 @@ public:
// get a fonts glyph bounding box
void getFontBoundingBox( fontID nFont, int& xMin, int& yMin, int& xMax, int& yMax );
- // creates a new font subset of an existing SFNT font
- // returns true in case of success, else false
- // pFace: the font face to be subsetted
- // rOutFile: the file to put the new subset into;
- // must be a valid osl file URL
- // pGlyphIDs: input array of glyph ids for new font
- // pNewEncoding: the corresponding encoding in the new font
- // nGlyphs: number of glyphs in arrays
- // TODO: callers of this method should use its FontSubsetInfo counterpart directly
- bool createFontSubset( FontSubsetInfo&,
- const vcl::font::PhysicalFontFace* pFace,
- const OUString& rOutFile,
- const sal_GlyphId* pGlyphIDs,
- const sal_uInt8* pNewEncoding,
- int nGlyphs
- );
-
// font administration functions
/* system dependent font matching
diff --git a/vcl/inc/unx/freetypetextrender.hxx b/vcl/inc/unx/freetypetextrender.hxx
index 0c7323885a60..e61faa0c9e49 100644
--- a/vcl/inc/unx/freetypetextrender.hxx
+++ b/vcl/inc/unx/freetypetextrender.hxx
@@ -47,13 +47,6 @@ public:
virtual void GetDevFontList( vcl::font::PhysicalFontCollection* ) override;
virtual void ClearDevFontCache() override;
virtual bool AddTempDevFont( vcl::font::PhysicalFontCollection*, const OUString& rFileURL, const OUString& rFontName ) override;
- virtual bool CreateFontSubset(
- const OUString& rToFile,
- const vcl::font::PhysicalFontFace*,
- const sal_GlyphId* pGlyphIDs,
- const sal_uInt8* pEncoding,
- int nGlyphs,
- FontSubsetInfo& rInfo) override;
virtual const void* GetEmbedFontData(const vcl::font::PhysicalFontFace*, tools::Long* pDataLen) override;
virtual void FreeEmbedFontData( const void* pData, tools::Long nDataLen ) override;
diff --git a/vcl/inc/unx/genpspgraphics.h b/vcl/inc/unx/genpspgraphics.h
index da1df08b8895..438e03fa39be 100644
--- a/vcl/inc/unx/genpspgraphics.h
+++ b/vcl/inc/unx/genpspgraphics.h
@@ -90,12 +90,6 @@ public:
const OUString& rFileURL,
const OUString& rFontName ) override;
- virtual bool CreateFontSubset( const OUString& rToFile,
- const vcl::font::PhysicalFontFace*,
- const sal_GlyphId* pGlyphIDs,
- const sal_uInt8* pEncoding,
- int nGlyphs,
- FontSubsetInfo& rInfo ) override;
virtual const void* GetEmbedFontData(const vcl::font::PhysicalFontFace*, tools::Long* pDataLen) override;
virtual void FreeEmbedFontData( const void* pData, tools::Long nDataLen ) override;
virtual std::unique_ptr<GenericSalLayout>
diff --git a/vcl/inc/unx/salgdi.h b/vcl/inc/unx/salgdi.h
index 0b217a784131..dbb7b98fbfec 100644
--- a/vcl/inc/unx/salgdi.h
+++ b/vcl/inc/unx/salgdi.h
@@ -122,14 +122,6 @@ public:
virtual void ClearDevFontCache() override;
virtual bool AddTempDevFont( vcl::font::PhysicalFontCollection*, const OUString& rFileURL, const OUString& rFontName ) override;
- virtual bool CreateFontSubset(
- const OUString& rToFile,
- const vcl::font::PhysicalFontFace*,
- const sal_GlyphId* pGlyphIDs,
- const sal_uInt8* pEncoding,
- int nGlyphs,
- FontSubsetInfo& rInfo ) override;
-
virtual const void* GetEmbedFontData(const vcl::font::PhysicalFontFace*, tools::Long* pDataLen) override;
virtual void FreeEmbedFontData( const void* pData, tools::Long nDataLen ) override;
diff --git a/vcl/inc/win/salgdi.h b/vcl/inc/win/salgdi.h
index 5b60e6e9ebff..247408406e8b 100644
--- a/vcl/inc/win/salgdi.h
+++ b/vcl/inc/win/salgdi.h
@@ -348,25 +348,6 @@ public:
// graphics must drop any cached font info
virtual void ClearDevFontCache() override;
virtual bool AddTempDevFont( vcl::font::PhysicalFontCollection*, const OUString& rFileURL, const OUString& rFontName ) override;
- // CreateFontSubset: a method to get a subset of glyhps of a font
- // inside a new valid font file
- // returns TRUE if creation of subset was successful
- // parameters: rToFile: contains an osl file URL to write the subset to
- // pFont: describes from which font to create a subset
- // pGlyphIDs: the glyph ids to be extracted
- // pEncoding: the character code corresponding to each glyph
- // pWidths: the advance widths of the corresponding glyphs (in PS font units)
- // nGlyphs: the number of glyphs
- // rInfo: additional outgoing information
- // implementation note: encoding 0 with glyph id 0 should be added implicitly
- // as "undefined character"
- virtual bool CreateFontSubset( const OUString& rToFile,
- const vcl::font::PhysicalFontFace*,
- const sal_GlyphId* pGlyphIDs,
- const sal_uInt8* pEncoding,
- int nGlyphs,
- FontSubsetInfo& rInfo // out parameter
- ) override;
// GetEmbedFontData: gets the font data for a font marked
// embeddable by GetDevFontList or NULL in case of error
diff --git a/vcl/qt5/QtGraphics_Text.cxx b/vcl/qt5/QtGraphics_Text.cxx
index 69828ea82cc0..42a1037943dc 100644
--- a/vcl/qt5/QtGraphics_Text.cxx
+++ b/vcl/qt5/QtGraphics_Text.cxx
@@ -24,7 +24,6 @@
#include <QtFont.hxx>
#include <QtPainter.hxx>
-#include <fontsubset.hxx>
#include <vcl/fontcharmap.hxx>
#include <unx/geninst.h>
#include <unx/fontmanager.hxx>
@@ -137,37 +136,6 @@ bool QtGraphics::AddTempDevFont(vcl::font::PhysicalFontCollection*, const OUStri
return false;
}
-bool QtGraphics::CreateFontSubset(const OUString& rToFile, const vcl::font::PhysicalFontFace* pFace,
- const sal_GlyphId* pGlyphIds, const sal_uInt8* pEncoding,
- int nGlyphCount, FontSubsetInfo& rInfo)
-{
- OUString aSysPath;
- if (osl_File_E_None != osl_getSystemPathFromFileURL(rToFile.pData, &aSysPath.pData))
- return false;
-
- const OString aToFile(OUStringToOString(aSysPath, osl_getThreadTextEncoding()));
-
- // handle CFF-subsetting
- auto aData = pFace->GetRawFontData(vcl::T_CFF);
- if (!aData.empty())
- return SalGraphics::CreateCFFfontSubset(aData.data(), aData.size(), aToFile, pGlyphIds,
- pEncoding, nGlyphCount, rInfo);
-
- // prepare data for psprint's font subsetter
- vcl::TrueTypeFace aTTF(*pFace);
- if (aTTF.initialize() != vcl::SFErrCodes::Ok)
- return false;
-
- // get details about the subsetted font
- vcl::TTGlobalFontInfo aTTInfo;
- vcl::GetTTGlobalFontInfo(&aTTF, &aTTInfo);
- OUString aPSName(aTTInfo.psname, std::strlen(aTTInfo.psname), RTL_TEXTENCODING_UTF8);
- FillFontSubsetInfo(aTTInfo, aPSName, rInfo);
-
- // write subset into destination file
- return SalGraphics::CreateTTFfontSubset(aTTF, aToFile, pGlyphIds, pEncoding, nGlyphCount);
-}
-
const void* QtGraphics::GetEmbedFontData(const vcl::font::PhysicalFontFace*,
tools::Long* /*pDataLen*/)
{
diff --git a/vcl/quartz/salgdicommon.cxx b/vcl/quartz/salgdicommon.cxx
index 26ba9e86a4c7..98ff40a7dc54 100644
--- a/vcl/quartz/salgdicommon.cxx
+++ b/vcl/quartz/salgdicommon.cxx
@@ -33,7 +33,6 @@
#include <tools/long.hxx>
#include <vcl/sysdata.hxx>
-#include <fontsubset.hxx>
#include <quartz/salbmp.h>
#ifdef MACOSX
#include <quartz/salgdi.h>
@@ -42,52 +41,9 @@
#ifdef IOS
#include <svdata.hxx>
#endif
-#include <sft.hxx>
using namespace vcl;
-bool AquaSalGraphics::CreateFontSubset( const OUString& rToFile,
- const vcl::font::PhysicalFontFace* pFace,
- const sal_GlyphId* pGlyphIds, const sal_uInt8* pEncoding,
- const int nGlyphCount,
- FontSubsetInfo& rInfo )
-{
- // TODO: move more of the functionality here into the generic subsetter code
-
- // prepare the requested file name for writing the font-subset file
- OUString aSysPath;
- if( osl_File_E_None != osl_getSystemPathFromFileURL( rToFile.pData, &aSysPath.pData ) )
- return false;
-
- const OString aToFile( OUStringToOString( aSysPath,
- osl_getThreadTextEncoding()));
-
- // handle CFF-subsetting
- // NOTE: assuming that all glyphids requested on Aqua are fully translated
- auto aData = pFace->GetRawFontData(T_CFF);
- if (!aData.empty())
- return SalGraphics::CreateCFFfontSubset(aData.data(), aData.size(), aToFile, pGlyphIds,
- pEncoding, nGlyphCount, rInfo);
-
- // TODO: modernize psprint's horrible fontsubset C-API
- // this probably only makes sense after the switch to another SCM
- // that can preserve change history after file renames
-
- // prepare data for psprint's font subsetter
- TrueTypeFace aSftFont(*pFace);
- if (aSftFont.initialize() != SFErrCodes::Ok)
- return false;
-
- // get details about the subsetted font
- TTGlobalFontInfo aTTInfo;
- ::GetTTGlobalFontInfo(&aSftFont, &aTTInfo);
- OUString aPSName(aTTInfo.psname, std::strlen(aTTInfo.psname), RTL_TEXTENCODING_UTF8);
- FillFontSubsetInfo(aTTInfo, aPSName, rInfo);
-
- // write subset into destination file
- return SalGraphics::CreateTTFfontSubset(aSftFont, aToFile, pGlyphIds, pEncoding, nGlyphCount);
-}
-
#ifndef IOS
void AquaSalGraphics::copyResolution( AquaSalGraphics& rGraphics )
diff --git a/vcl/source/font/PhysicalFontFace.cxx b/vcl/source/font/PhysicalFontFace.cxx
index 88ec43fa2bd5..10a1048dcf79 100644
--- a/vcl/source/font/PhysicalFontFace.cxx
+++ b/vcl/source/font/PhysicalFontFace.cxx
@@ -22,10 +22,13 @@
#include <sal/types.h>
#include <tools/fontenum.hxx>
#include <unotools/fontdefs.hxx>
+#include <osl/file.hxx>
+#include <osl/thread.h>
#include <fontattributes.hxx>
#include <impfontcharmap.hxx>
#include <sft.hxx>
+#include <salgdi.hxx>
#include <font/FontSelectPattern.hxx>
#include <font/PhysicalFontFace.hxx>
@@ -280,6 +283,38 @@ bool PhysicalFontFace::GetFontCapabilities(vcl::FontCapabilities& rFontCapabilit
rFontCapabilities = maFontCapabilities;
return rFontCapabilities.oUnicodeRange || rFontCapabilities.oCodePageRange;
}
+
+bool PhysicalFontFace::CreateFontSubset(const OUString& rToFile, const sal_GlyphId* pGlyphIds,
+ const sal_uInt8* pEncoding, const int nGlyphCount,
+ FontSubsetInfo& rInfo) const
+{
+ // Prepare the requested file name for writing the font-subset file
+ OUString aSysPath;
+ if (osl_File_E_None != osl_getSystemPathFromFileURL(rToFile.pData, &aSysPath.pData))
+ return false;
+
+ const OString aToFile(OUStringToOString(aSysPath, osl_getThreadTextEncoding()));
+
+ // Shortcut for CFF-subsetting.
+ auto aData = GetRawFontData(T_CFF);
+ if (!aData.empty())
+ return SalGraphics::CreateCFFfontSubset(aData.data(), aData.size(), aToFile, pGlyphIds,
+ pEncoding, nGlyphCount, rInfo);
+
+ // Prepare data for font subsetter.
+ TrueTypeFace aSftFont(*this);
+ if (aSftFont.initialize() != SFErrCodes::Ok)
+ return false;
+
+ // Get details about the subset font.
+ TTGlobalFontInfo aTTInfo;
+ GetTTGlobalFontInfo(&aSftFont, &aTTInfo);
+ OUString aPSName(aTTInfo.psname, std::strlen(aTTInfo.psname), RTL_TEXTENCODING_UTF8);
+ SalGraphics::FillFontSubsetInfo(aTTInfo, aPSName, rInfo);
+
+ // write subset into destination file
+ return SalGraphics::CreateTTFfontSubset(aSftFont, aToFile, pGlyphIds, pEncoding, nGlyphCount);
+}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 1f032c25a79e..4f4c2cbfde4b 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -2327,9 +2327,6 @@ std::map< sal_Int32, sal_Int32 > PDFWriterImpl::emitSystemFont( const vcl::font:
aInfo.m_aFontBBox = tools::Rectangle( Point( -200, -200 ), Size( 1700, 1700 ) );
aInfo.m_aPSName = pFont->GetFamilyName();
- SalGraphics *pGraphics = GetGraphics();
- assert(pGraphics);
-
aSubType = OString( "/TrueType" );
OUString aTmpName;
@@ -2346,7 +2343,7 @@ std::map< sal_Int32, sal_Int32 > PDFWriterImpl::emitSystemFont( const vcl::font:
// We are interested only in filling aInfo
sal_GlyphId aGlyphIds[256] = { 0 };
sal_uInt8 pEncoding[256] = { 0 };
- pGraphics->CreateFontSubset(aTmpName, pFont, aGlyphIds, pEncoding, 256, aInfo);
+ pFont->CreateFontSubset(aTmpName, aGlyphIds, pEncoding, 256, aInfo);
osl_removeFile( aTmpName.pData );
// write font descriptor
@@ -2638,11 +2635,6 @@ void PDFWriterImpl::appendBuildinFontsToDict( OStringBuffer& rDict ) const
bool PDFWriterImpl::emitFonts()
{
- SalGraphics *pGraphics = GetGraphics();
-
- if (!pGraphics)
- return false;
-
OStringBuffer aLine( 1024 );
std::map< sal_Int32, sal_Int32 > aFontIDToObject;
@@ -2690,7 +2682,8 @@ bool PDFWriterImpl::emitFonts()
}
}
FontSubsetInfo aSubsetInfo;
- if( pGraphics->CreateFontSubset( aTmpName, subset.first, aGlyphIds, pEncoding, nGlyphs, aSubsetInfo ) )
+ const auto* pFace = subset.first;
+ if (pFace->CreateFontSubset(aTmpName, aGlyphIds, pEncoding, nGlyphs, aSubsetInfo))
{
// create font stream
osl::File aFontFile(aTmpName);
diff --git a/vcl/unx/generic/fontmanager/fontmanager.cxx b/vcl/unx/generic/fontmanager/fontmanager.cxx
index 1aed1a37d1d4..d9151ecf19c0 100644
--- a/vcl/unx/generic/fontmanager/fontmanager.cxx
+++ b/vcl/unx/generic/fontmanager/fontmanager.cxx
@@ -22,7 +22,6 @@
#include <osl/thread.h>
#include <unx/fontmanager.hxx>
-#include <fontsubset.hxx>
#include <impfontcharmap.hxx>
#include <unx/gendata.hxx>
#include <unx/helper.hxx>
@@ -938,116 +937,4 @@ int PrintFontManager::getFontDescend( fontID nFontID )
return pFont ? pFont->m_nDescend : 0;
}
-// TODO: move most of this stuff into the central font-subsetting code
-bool PrintFontManager::createFontSubset(
- FontSubsetInfo& rInfo,
- const vcl::font::PhysicalFontFace* pFace,
- const OUString& rOutFile,
- const sal_GlyphId* pGlyphIds,
- const sal_uInt8* pNewEncoding,
- int nGlyphs
- )
-{
- psp::fontID nFont = pFace->GetFontId();
- PrintFont* pFont = getFont( nFont );
- if( !pFont )
- return false;
-
- rInfo.m_nFontType = FontType::SFNT_TTF;
-
- // reshuffle array of requested glyphs to make sure glyph0==notdef
- sal_uInt8 pEnc[256];
- sal_uInt16 pGID[256];
- sal_uInt8 pOldIndex[256];
- memset( pEnc, 0, sizeof( pEnc ) );
- memset( pGID, 0, sizeof( pGID ) );
- memset( pOldIndex, 0, sizeof( pOldIndex ) );
- if( nGlyphs > 256 )
- return false;
- int nChar = 1;
- for( int i = 0; i < nGlyphs; i++ )
- {
- if( pNewEncoding[i] == 0 )
- {
- pOldIndex[ 0 ] = i;
- }
- else
- {
- SAL_WARN_IF( (pGlyphIds[i] & 0x007f0000), "vcl.fonts", "overlong glyph id" );
- SAL_WARN_IF( static_cast<int>(pNewEncoding[i]) >= nGlyphs, "vcl.fonts", "encoding wrong" );
- SAL_WARN_IF( pEnc[pNewEncoding[i]] != 0 || pGID[pNewEncoding[i]] != 0, "vcl.fonts", "duplicate encoded glyph" );
- pEnc[ pNewEncoding[i] ] = pNewEncoding[i];
- pGID[ pNewEncoding[i] ] = static_cast<sal_uInt16>(pGlyphIds[ i ]);
- pOldIndex[ pNewEncoding[i] ] = i;
- nChar++;
- }
- }
- nGlyphs = nChar; // either input value or increased by one
-
- TrueTypeFace aSftFont(*pFace);
- if (aSftFont.initialize() != SFErrCodes::Ok)
- return false;
-
- // prepare system name for write access for subset file target
- OUString aSysPath;
- if( osl_File_E_None != osl_getSystemPathFromFileURL( rOutFile.pData, &aSysPath.pData ) )
- return false;
- const rtl_TextEncoding aEncoding = osl_getThreadTextEncoding();
- const OString aToFile( OUStringToOString( aSysPath, aEncoding ) );
-
- // do CFF subsetting if possible
- sal_uInt32 nCffLength = 0;
- const sal_uInt8* pCffBytes = aSftFont.table(vcl::O_CFF, nCffLength);
- if (pCffBytes)
- {
- rInfo.LoadFont( FontType::CFF_FONT, pCffBytes, nCffLength );
-#if 1 // TODO: remove 16bit->long conversion when related methods handle non-16bit glyphids
- sal_GlyphId aRequestedGlyphIds[256];
- for( int i = 0; i < nGlyphs; ++i )
- aRequestedGlyphIds[i] = pGID[i];
-#endif
- // create subset file at requested path
- FILE* pOutFile = fopen( aToFile.getStr(), "wb" );
- if (!pOutFile)
- return false;
- // create font subset
- const char* const pGlyphSetName = nullptr; // TODO: better name?
- const bool bOK = rInfo.CreateFontSubset(
- FontType::TYPE1_PFB,
- pOutFile, pGlyphSetName,
- aRequestedGlyphIds, pEnc, nGlyphs);
- fclose( pOutFile );
- // For OTC, values from hhea or OS2 are better
- psp::PrintFontInfo aFontInfo;
- if( getFontInfo( nFont, aFontInfo ) )
- {
- rInfo.m_nAscent = aFontInfo.m_nAscend;
- rInfo.m_nDescent = -aFontInfo.m_nDescend;
- }
- return bOK;
- }
-
- // do TTF->Type42 or Type3 subsetting
- // fill in font info
- psp::PrintFontInfo aFontInfo;
- if( ! getFontInfo( nFont, aFontInfo ) )
- return false;
-
- rInfo.m_nAscent = aFontInfo.m_nAscend;
- rInfo.m_nDescent = aFontInfo.m_nDescend;
- rInfo.m_aPSName = getPSName( nFont );
-
- int xMin, yMin, xMax, yMax;
- getFontBoundingBox( nFont, xMin, yMin, xMax, yMax );
- rInfo.m_aFontBBox = tools::Rectangle( Point( xMin, yMin ), Size( xMax-xMin, yMax-yMin ) );
- rInfo.m_nCapHeight = yMax; // Well ...
-
- bool bSuccess = ( SFErrCodes::Ok == CreateTTFromTTGlyphs(&aSftFont,
- aToFile.getStr(),
- pGID,
- pEnc,
- nGlyphs ) );
- return bSuccess;
-}
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/unx/generic/gdi/font.cxx b/vcl/unx/generic/gdi/font.cxx
index bf0ca5c98ffb..1246d9b525f8 100644
--- a/vcl/unx/generic/gdi/font.cxx
+++ b/vcl/unx/generic/gdi/font.cxx
@@ -81,19 +81,6 @@ std::unique_ptr<GenericSalLayout> X11SalGraphics::GetTextLayout(int nFallbackLev
return mxTextRenderImpl->GetTextLayout(nFallbackLevel);
}
-bool X11SalGraphics::CreateFontSubset(
- const OUString& rToFile,
- const vcl::font::PhysicalFontFace* pFont,
- const sal_GlyphId* pGlyphIds,
- const sal_uInt8* pEncoding,
- int nGlyphCount,
- FontSubsetInfo& rInfo
- )
-{
- return mxTextRenderImpl->CreateFontSubset(rToFile, pFont,
- pGlyphIds, pEncoding, nGlyphCount, rInfo);
-}
-
const void* X11SalGraphics::GetEmbedFontData(const vcl::font::PhysicalFontFace* pFont, tools::Long* pDataLen)
{
return mxTextRenderImpl->GetEmbedFontData(pFont, pDataLen);
diff --git a/vcl/unx/generic/gdi/freetypetextrender.cxx b/vcl/unx/generic/gdi/freetypetextrender.cxx
index beff9f33e652..b1416721fea6 100644
--- a/vcl/unx/generic/gdi/freetypetextrender.cxx
+++ b/vcl/unx/generic/gdi/freetypetextrender.cxx
@@ -127,25 +127,6 @@ std::unique_ptr<GenericSalLayout> FreeTypeTextRenderImpl::GetTextLayout(int nFal
return std::make_unique<GenericSalLayout>(*mpFreetypeFont[nFallbackLevel]);
}
-bool FreeTypeTextRenderImpl::CreateFontSubset(
- const OUString& rToFile,
- const vcl::font::PhysicalFontFace* pFont,
- const sal_GlyphId* pGlyphIds,
- const sal_uInt8* pEncoding,
- int nGlyphCount,
- FontSubsetInfo& rInfo
- )
-{
- psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
- bool bSuccess = rMgr.createFontSubset( rInfo,
- pFont,
- rToFile,
- pGlyphIds,
- pEncoding,
- nGlyphCount );
- return bSuccess;
-}
-
const void* FreeTypeTextRenderImpl::GetEmbedFontData(const vcl::font::PhysicalFontFace* pFont, tools::Long* pDataLen)
{
return GenPspGraphics::GetEmbedFontDataHelper(pFont, pDataLen);
diff --git a/vcl/unx/generic/print/genpspgraphics.cxx b/vcl/unx/generic/print/genpspgraphics.cxx
index 630a02bdb061..dcfdadc64cda 100644
--- a/vcl/unx/generic/print/genpspgraphics.cxx
+++ b/vcl/unx/generic/print/genpspgraphics.cxx
@@ -315,25 +315,6 @@ std::unique_ptr<GenericSalLayout> GenPspGraphics::GetTextLayout(int nFallbackLev
return std::make_unique<PspSalLayout>(*m_pPrinterGfx, *m_pFreetypeFont[nFallbackLevel]);
}
-bool GenPspGraphics::CreateFontSubset(
- const OUString& rToFile,
- const vcl::font::PhysicalFontFace* pFont,
- const sal_GlyphId* pGlyphIds,
- const sal_uInt8* pEncoding,
- int nGlyphCount,
- FontSubsetInfo& rInfo
- )
-{
- psp::PrintFontManager& rMgr = psp::PrintFontManager::get();
- bool bSuccess = rMgr.createFontSubset( rInfo,
- pFont,
- rToFile,
- pGlyphIds,
- pEncoding,
- nGlyphCount );
- return bSuccess;
-}
-
FontAttributes GenPspGraphics::Info2FontAttributes( const psp::FastPrintFontInfo& rInfo )
{
FontAttributes aDFA;
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index e116ad049449..75ef19c86e8a 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -53,7 +53,6 @@
#include <comphelper/scopeguard.hxx>
#include <font/FontSelectPattern.hxx>
-#include <fontsubset.hxx>
#include <font/PhysicalFontCollection.hxx>
#include <font/PhysicalFontFaceCollection.hxx>
#include <font/PhysicalFontFace.hxx>
@@ -1493,38 +1492,6 @@ private:
}
-bool WinSalGraphics::CreateFontSubset( const OUString& rToFile,
- const vcl::font::PhysicalFontFace* pFace, const sal_GlyphId* pGlyphIds, const sal_uInt8* pEncoding,
- int nGlyphCount, FontSubsetInfo& rInfo )
-{
- OUString aSysPath;
- if( osl_File_E_None != osl_getSystemPathFromFileURL( rToFile.pData, &aSysPath.pData ) )
- return false;
- const rtl_TextEncoding aThreadEncoding = osl_getThreadTextEncoding();
- const OString aToFile(OUStringToOString(aSysPath, aThreadEncoding));
-
- // check if the font has a CFF-table
- auto aData = pFace->GetRawFontData(T_CFF);
- if (!aData.empty())
- return SalGraphics::CreateCFFfontSubset(aData.data(), aData.size(), aToFile,
- pGlyphIds, pEncoding, nGlyphCount,
- rInfo);
-
- // open font file
- TrueTypeFace aSftTTF(*pFace);
- if (aSftTTF.initialize() != SFErrCodes::Ok)
- return false;
-
- TTGlobalFontInfo aTTInfo;
- ::GetTTGlobalFontInfo(&aSftTTF, &aTTInfo);
- OUString aPSName = ImplSalGetUniString(aTTInfo.psname);
- FillFontSubsetInfo(aTTInfo, aPSName, rInfo);
-
- // write subset into destination file
- return SalGraphics::CreateTTFfontSubset(aSftTTF, aToFile,
- pGlyphIds, pEncoding, nGlyphCount);
-}
-
const void* WinSalGraphics::GetEmbedFontData(const vcl::font::PhysicalFontFace* pFont, tools::Long* pDataLen)
{
ScopedFontHDC aScopedFontHDC(*this, *pFont);