summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2020-09-13 15:01:22 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2020-09-14 21:56:03 +0200
commit94da816f900ad588a49e84a07c4e788a27a13238 (patch)
tree5738fbd471f39c53735ca285f25ddac397bf4eb1
parentQt5 implement GetGlyphWidths (diff)
downloadcore-feature/drop-findcmap.tar.gz
core-feature/drop-findcmap.zip
WIN OSX Qt5 unify CreateFontSubset code feature/drop-findcmap
This is basically just some refactoring. Most interestingly the MacOS used to work with 257 glyphs. I couldn't find any explaination for the 256 glyph limit. Sadly the PrintFontManager is out of scope. That needs more inspection. Change-Id: Ibfa0e905f5efeb7d4a609884d64b4ed2615a9d3d
-rw-r--r--vcl/inc/salgdi.hxx14
-rw-r--r--vcl/inc/sft.hxx2
-rw-r--r--vcl/qt5/Qt5Graphics_Text.cxx63
-rw-r--r--vcl/quartz/salgdicommon.cxx123
-rw-r--r--vcl/source/gdi/salgdilayout.cxx108
-rw-r--r--vcl/win/gdi/salfont.cxx69
6 files changed, 152 insertions, 227 deletions
diff --git a/vcl/inc/salgdi.hxx b/vcl/inc/salgdi.hxx
index 9d86421e4e10..3a8fb1700862 100644
--- a/vcl/inc/salgdi.hxx
+++ b/vcl/inc/salgdi.hxx
@@ -57,6 +57,7 @@ namespace basegfx {
namespace vcl
{
class AbstractTrueTypeFont;
+typedef struct TTGlobalFontInfo_ TTGlobalFontInfo;
}
typedef sal_Unicode sal_Ucs; // TODO: use sal_UCS4 instead of sal_Unicode
@@ -622,6 +623,19 @@ protected:
static void GetGlyphWidths(const vcl::AbstractTrueTypeFont& rTTF,
const PhysicalFontFace& rFontFace, bool bVertical,
std::vector<sal_Int32>& rWidths, Ucs2UIntMap& rUnicodeEnc);
+
+ static bool CreateTTFfontSubset(vcl::AbstractTrueTypeFont& aTTF, const OString& rSysPath,
+ const bool bVertical, const sal_GlyphId* pGlyphIds,
+ const sal_uInt8* pEncoding, sal_Int32* pGlyphWidths,
+ int nGlyphCount);
+
+ static bool CreateCFFfontSubset(const unsigned char* pFontBytes, int nByteLength,
+ const OString& rSysPath, const sal_GlyphId* pGlyphIds,
+ const sal_uInt8* pEncoding, sal_Int32* pGlyphWidths,
+ int nGlyphCount, FontSubsetInfo& rInfo);
+
+ static void FillFontSubsetInfo(const vcl::TTGlobalFontInfo& rTTInfo, const OUString& pPSName,
+ FontSubsetInfo& rInfo);
};
bool SalGraphics::IsNativeControlSupported(ControlType eType, ControlPart ePart)
diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx
index 86cb718809b3..8711364ed46f 100644
--- a/vcl/inc/sft.hxx
+++ b/vcl/inc/sft.hxx
@@ -144,7 +144,7 @@ namespace vcl
/** Return value of GetTTGlobalFontInfo() */
- typedef struct {
+ typedef struct TTGlobalFontInfo_ {
char *family; /**< family name */
sal_Unicode *ufamily; /**< family name UCS2 */
char *subfamily; /**< subfamily name */
diff --git a/vcl/qt5/Qt5Graphics_Text.cxx b/vcl/qt5/Qt5Graphics_Text.cxx
index 351bb3023213..de39fc7009b8 100644
--- a/vcl/qt5/Qt5Graphics_Text.cxx
+++ b/vcl/qt5/Qt5Graphics_Text.cxx
@@ -219,7 +219,6 @@ bool Qt5Graphics::CreateFontSubset(const OUString& rToFile, const PhysicalFontFa
const sal_GlyphId* pGlyphIds, const sal_uInt8* pEncoding,
sal_Int32* pGlyphWidths, int nGlyphCount, FontSubsetInfo& rInfo)
{
- // 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;
@@ -228,23 +227,16 @@ bool Qt5Graphics::CreateFontSubset(const OUString& rToFile, const PhysicalFontFa
const Qt5FontFace* pQt5FontFace = static_cast<const Qt5FontFace*>(pFontFace);
const QFont aFont = pQt5FontFace->CreateFont();
const QRawFont aRawFont(QRawFont::fromFont(aFont));
- const QFontInfo aFontInfo(aFont);
const OString aToFile(OUStringToOString(aSysPath, osl_getThreadTextEncoding()));
- const int nOrigGlyphCount = nGlyphCount;
+ // handle CFF-subsetting
QByteArray aCFFtable = aRawFont.fontTable("CFF ");
if (!aCFFtable.isEmpty())
- {
- FILE* pOutFile = fopen(aToFile.getStr(), "wb");
- rInfo.LoadFont(FontType::CFF_FONT, reinterpret_cast<const sal_uInt8*>(aCFFtable.data()),
- aCFFtable.size());
- bool bRet = rInfo.CreateFontSubset(FontType::TYPE1_PFB, pOutFile, nullptr, pGlyphIds,
- pEncoding, nGlyphCount, pGlyphWidths);
- fclose(pOutFile);
- return bRet;
- }
+ return SalGraphics::CreateCFFfontSubset(
+ reinterpret_cast<const sal_uInt8*>(aCFFtable.data()), aCFFtable.size(), aToFile,
+ pGlyphIds, pEncoding, pGlyphWidths, nGlyphCount, rInfo);
- // get details about the subsetted font
+ // fill details about the subsetted font
rInfo.m_nFontType = FontType::SFNT_TTF;
rInfo.m_aPSName = toOUString(aRawFont.familyName());
rInfo.m_nCapHeight = aRawFont.capHeight();
@@ -257,49 +249,8 @@ bool Qt5Graphics::CreateFontSubset(const OUString& rToFile, const PhysicalFontFa
if (GetTTGlobalFontHeadInfo(&aTTF, nXmin, nYmin, nXmax, nYmax, nMacStyleFlags))
rInfo.m_aFontBBox = tools::Rectangle(Point(nXmin, nYmin), Point(nXmax, nYmax));
- sal_uInt16 aShortIDs[nGlyphCount + 1];
- sal_uInt8 aTempEncs[nGlyphCount + 1];
-
- int nNotDef = -1;
-
- for (int i = 0; i < nGlyphCount; ++i)
- {
- aTempEncs[i] = pEncoding[i];
-
- sal_GlyphId aGlyphId(pGlyphIds[i]);
- aShortIDs[i] = static_cast<sal_uInt16>(aGlyphId);
- if (!aGlyphId && nNotDef < 0)
- nNotDef = i; // first NotDef glyph found
- }
-
- if (nNotDef != 0)
- {
- // add fake NotDef glyph if needed
- if (nNotDef < 0)
- nNotDef = nGlyphCount++;
- // NotDef glyph must be in pos 0 => swap glyphids
- aShortIDs[nNotDef] = aShortIDs[0];
- aTempEncs[nNotDef] = aTempEncs[0];
- aShortIDs[0] = 0;
- aTempEncs[0] = 0;
- }
-
- std::unique_ptr<sal_uInt16[]> pGlyphMetrics
- = GetTTSimpleGlyphMetrics(&aTTF, aShortIDs, nGlyphCount, false);
- if (!pGlyphMetrics)
- return false;
-
- sal_uInt16 nNotDefAdv = pGlyphMetrics[0];
- pGlyphMetrics[0] = pGlyphMetrics[nNotDef];
- pGlyphMetrics[nNotDef] = nNotDefAdv;
-
- for (int i = 0; i < nOrigGlyphCount; ++i)
- pGlyphWidths[i] = pGlyphMetrics[i];
-
- // write subset into destination file
- vcl::SFErrCodes nRC
- = vcl::CreateTTFromTTGlyphs(&aTTF, aToFile.getStr(), aShortIDs, aTempEncs, nGlyphCount);
- return (nRC == vcl::SFErrCodes::Ok);
+ return SalGraphics::CreateTTFfontSubset(aTTF, aToFile, false /* use FontSelectPattern? */,
+ pGlyphIds, pEncoding, pGlyphWidths, nGlyphCount);
}
const void* Qt5Graphics::GetEmbedFontData(const PhysicalFontFace*, long* /*pDataLen*/)
diff --git a/vcl/quartz/salgdicommon.cxx b/vcl/quartz/salgdicommon.cxx
index c72e8ee5cabd..3f2ec10bbd30 100644
--- a/vcl/quartz/salgdicommon.cxx
+++ b/vcl/quartz/salgdicommon.cxx
@@ -145,7 +145,7 @@ static void AddPolyPolygonToPath( CGMutablePathRef xPath,
bool AquaSalGraphics::CreateFontSubset( const OUString& rToFile,
const PhysicalFontFace* pFontData,
const sal_GlyphId* pGlyphIds, const sal_uInt8* pEncoding,
- sal_Int32* pGlyphWidths, int nGlyphCount,
+ sal_Int32* pGlyphWidths, const int nGlyphCount,
FontSubsetInfo& rInfo )
{
// TODO: move more of the functionality here into the generic subsetter code
@@ -153,36 +153,21 @@ bool AquaSalGraphics::CreateFontSubset( const OUString& rToFile,
// 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;
- }
// get the raw-bytes from the font to be subset
std::vector<unsigned char> aBuffer;
bool bCffOnly = false;
if( !GetRawFontData( pFontData, aBuffer, &bCffOnly ) )
- {
return false;
- }
const OString aToFile( OUStringToOString( aSysPath,
osl_getThreadTextEncoding()));
// handle CFF-subsetting
- if( bCffOnly )
- {
- // provide the raw-CFF data to the subsetter
- ByteCount nCffLen = aBuffer.size();
- rInfo.LoadFont( FontType::CFF_FONT, aBuffer.data(), nCffLen );
-
- // NOTE: assuming that all glyphids requested on Aqua are fully translated
-
- // make the subsetter provide the requested subset
- FILE* pOutFile = fopen( aToFile.getStr(), "wb" );
- bool bRC = rInfo.CreateFontSubset( FontType::TYPE1_PFB, pOutFile, nullptr,
- pGlyphIds, pEncoding, nGlyphCount, pGlyphWidths );
- fclose( pOutFile );
- return bRC;
- }
+ // NOTE: assuming that all glyphids requested on Aqua are fully translated
+ if (bCffOnly)
+ return SalGraphics::CreateCFFfontSubset(aBuffer.data(), aBuffer.size(), aToFile, pGlyphIds,
+ pEncoding, pGlyphWidths, nGlyphCount, rInfo);
// TODO: modernize psprint's horrible fontsubset C-API
// this probably only makes sense after the switch to another SCM
@@ -190,102 +175,22 @@ bool AquaSalGraphics::CreateFontSubset( const OUString& rToFile,
// prepare data for psprint's font subsetter
TrueTypeFont* pSftFont = nullptr;
- SFErrCodes nRC = ::OpenTTFontBuffer( static_cast<void*>(aBuffer.data()), aBuffer.size(), 0, &pSftFont);
- if( nRC != SFErrCodes::Ok )
- {
+ if (::OpenTTFontBuffer( static_cast<void*>(aBuffer.data()), aBuffer.size(), 0, &pSftFont)
+ != SFErrCodes::Ok)
return false;
- }
+
// get details about the subsetted font
TTGlobalFontInfo aTTInfo;
::GetTTGlobalFontInfo( pSftFont, &aTTInfo );
- rInfo.m_nFontType = FontType::SFNT_TTF;
- rInfo.m_aPSName = OUString( aTTInfo.psname, std::strlen(aTTInfo.psname),
- RTL_TEXTENCODING_UTF8 );
- rInfo.m_aFontBBox = tools::Rectangle( Point( aTTInfo.xMin, aTTInfo.yMin ),
- Point( aTTInfo.xMax, aTTInfo.yMax ) );
- rInfo.m_nCapHeight = aTTInfo.yMax; // Well ...
- rInfo.m_nAscent = aTTInfo.winAscent;
- rInfo.m_nDescent = aTTInfo.winDescent;
- // mac fonts usually do not have an OS2-table
- // => get valid ascent/descent values from other tables
- if( !rInfo.m_nAscent )
- {
- rInfo.m_nAscent = +aTTInfo.typoAscender;
- }
- if( !rInfo.m_nAscent )
- {
- rInfo.m_nAscent = +aTTInfo.ascender;
- }
- if( !rInfo.m_nDescent )
- {
- rInfo.m_nDescent = +aTTInfo.typoDescender;
- }
- if( !rInfo.m_nDescent )
- {
- rInfo.m_nDescent = -aTTInfo.descender;
- }
-
- // subset glyphs and get their properties
- // take care that subset fonts require the NotDef glyph in pos 0
- int nOrigCount = nGlyphCount;
- sal_uInt16 aShortIDs[ 257 ];
- sal_uInt8 aTempEncs[ 257 ];
- int nNotDef = -1;
-
- assert( (nGlyphCount <= 256 && "too many glyphs for subsetting" ));
-
- for( int i = 0; i < nGlyphCount; ++i )
- {
- aTempEncs[i] = pEncoding[i];
-
- sal_GlyphId aGlyphId(pGlyphIds[i]);
- aShortIDs[i] = static_cast<sal_uInt16>( aGlyphId );
- if( !aGlyphId && nNotDef < 0 )
- {
- nNotDef = i; // first NotDef glyph found
- }
- }
-
- if( nNotDef != 0 )
- {
- // add fake NotDef glyph if needed
- if( nNotDef < 0 )
- {
- nNotDef = nGlyphCount++;
- }
- // NotDef glyph must be in pos 0 => swap glyphids
- aShortIDs[ nNotDef ] = aShortIDs[0];
- aTempEncs[ nNotDef ] = aTempEncs[0];
- aShortIDs[0] = 0;
- aTempEncs[0] = 0;
- }
-
- // TODO: where to get bVertical?
- const bool bVertical = false;
-
- // fill the pGlyphWidths array
- // while making sure that the NotDef glyph is at index==0
- std::unique_ptr<sal_uInt16[]> pGlyphMetrics = ::GetTTSimpleGlyphMetrics( pSftFont, aShortIDs,
- nGlyphCount, bVertical );
- if( !pGlyphMetrics )
- {
- return false;
- }
-
- sal_uInt16 nNotDefAdv = pGlyphMetrics[0];
- pGlyphMetrics[0] = pGlyphMetrics[nNotDef];
- pGlyphMetrics[nNotDef] = nNotDefAdv;
- for( int i = 0; i < nOrigCount; ++i )
- {
- pGlyphWidths[i] = pGlyphMetrics[i];
- }
- pGlyphMetrics.reset();
+ OUString aPSName(aTTInfo.psname, std::strlen(aTTInfo.psname), RTL_TEXTENCODING_UTF8);
+ FillFontSubsetInfo(aTTInfo, aPSName, rInfo);
// write subset into destination file
- nRC = ::CreateTTFromTTGlyphs( pSftFont, aToFile.getStr(), aShortIDs,
- aTempEncs, nGlyphCount );
+ bool bRet
+ = SalGraphics::CreateTTFfontSubset(*pSftFont, aToFile, false /* use FontSelectPattern? */,
+ pGlyphIds, pEncoding, pGlyphWidths, nGlyphCount);
::CloseTTFont(pSftFont);
- return (nRC == SFErrCodes::Ok);
+ return bRet;
}
static void alignLinePoint( const SalPoint* i_pIn, float& o_fX, float& o_fY )
diff --git a/vcl/source/gdi/salgdilayout.cxx b/vcl/source/gdi/salgdilayout.cxx
index 777b2b1115e4..5758bfd2acec 100644
--- a/vcl/source/gdi/salgdilayout.cxx
+++ b/vcl/source/gdi/salgdilayout.cxx
@@ -29,6 +29,7 @@
#endif
#endif
#include <PhysicalFontFace.hxx>
+#include <fontsubset.hxx>
#include <salgdi.hxx>
#include <salframe.hxx>
#include <sft.hxx>
@@ -942,4 +943,111 @@ void SalGraphics::GetGlyphWidths(const vcl::AbstractTrueTypeFont& rTTF,
}
}
+bool SalGraphics::CreateTTFfontSubset(vcl::AbstractTrueTypeFont& rTTF, const OString& rSysPath,
+ const bool bVertical, const sal_GlyphId* pGlyphIds,
+ const sal_uInt8* pEncoding, sal_Int32* pGlyphWidths,
+ const int nOrigGlyphCount)
+{
+ // Multiple questions:
+ // - Why is there a glyph limit?
+ // MacOS used to handle 257 glyphs...
+ // Also the much more complex PrintFontManager variant has this limit.
+ // Also the very first implementation has the limit in
+ // commit 8789ed701e98031f2a1657ea0dfd6f7a0b050992
+ // - Why doesn't the PrintFontManager care about the fake glpyh? It
+ // is used on all unx platforms to create the subset font.
+ // - Should the SAL_WARN actually be asserts, like on MacOS?
+ if (nOrigGlyphCount > 256)
+ {
+ SAL_WARN("vcl.fonts", "too many glyphs for subsetting");
+ return false;
+ }
+
+ int nGlyphCount = nOrigGlyphCount;
+ sal_uInt16 aShortIDs[256];
+ sal_uInt8 aTempEncs[256];
+
+ // handle the undefined / first font glyph
+ int nNotDef = -1, i;
+ for (i = 0; i < nGlyphCount; ++i)
+ {
+ aTempEncs[i] = pEncoding[i];
+ aShortIDs[i] = static_cast<sal_uInt16>(pGlyphIds[i]);
+ if (!aShortIDs[i])
+ if (nNotDef < 0)
+ nNotDef = i;
+ }
+
+ // nNotDef glyph must be in pos 0 => swap glyphids
+ if (nNotDef != 0)
+ {
+ if (nNotDef < 0)
+ {
+ if (nGlyphCount == 256)
+ {
+ SAL_WARN("vcl.fonts", "too many glyphs for subsetting");
+ return false;
+ }
+ nNotDef = nGlyphCount++;
+ }
+
+ aShortIDs[nNotDef] = aShortIDs[0];
+ aTempEncs[nNotDef] = aTempEncs[0];
+ aShortIDs[0] = 0;
+ aTempEncs[0] = 0;
+ }
+
+ std::unique_ptr<sal_uInt16[]> pMetrics
+ = GetTTSimpleGlyphMetrics(&rTTF, aShortIDs, nGlyphCount, bVertical);
+ if (!pMetrics)
+ return false;
+
+ sal_uInt16 nNotDefAdv = pMetrics[0];
+ pMetrics[0] = pMetrics[nNotDef];
+ pMetrics[nNotDef] = nNotDefAdv;
+ for (i = 0; i < nOrigGlyphCount; ++i)
+ pGlyphWidths[i] = pMetrics[i];
+ pMetrics.reset();
+
+ // write subset into destination file
+ return (CreateTTFromTTGlyphs(&rTTF, rSysPath.getStr(), aShortIDs, aTempEncs, nGlyphCount)
+ == vcl::SFErrCodes::Ok);
+}
+
+bool SalGraphics::CreateCFFfontSubset(const unsigned char* pFontBytes, int nByteLength,
+ const OString& rSysPath, const sal_GlyphId* pGlyphIds,
+ const sal_uInt8* pEncoding, sal_Int32* pGlyphWidths,
+ int nGlyphCount, FontSubsetInfo& rInfo)
+{
+ FILE* pOutFile = fopen(rSysPath.getStr(), "wb");
+ rInfo.LoadFont(FontType::CFF_FONT, pFontBytes, nByteLength);
+ bool bRet = rInfo.CreateFontSubset(FontType::TYPE1_PFB, pOutFile, nullptr, pGlyphIds, pEncoding,
+ nGlyphCount, pGlyphWidths);
+ fclose(pOutFile);
+ return bRet;
+}
+
+void SalGraphics::FillFontSubsetInfo(const vcl::TTGlobalFontInfo& rTTInfo, const OUString& pPSName,
+ FontSubsetInfo& rInfo)
+{
+ rInfo.m_aPSName = pPSName;
+ rInfo.m_nFontType = FontType::SFNT_TTF;
+ rInfo.m_aFontBBox
+ = tools::Rectangle(Point(rTTInfo.xMin, rTTInfo.yMin), Point(rTTInfo.xMax, rTTInfo.yMax));
+ rInfo.m_nCapHeight = rTTInfo.yMax; // Well ...
+ rInfo.m_nAscent = rTTInfo.winAscent;
+ rInfo.m_nDescent = rTTInfo.winDescent;
+
+ // mac fonts usually do not have an OS2-table
+ // => get valid ascent/descent values from other tables
+ if (!rInfo.m_nAscent)
+ rInfo.m_nAscent = +rTTInfo.typoAscender;
+ if (!rInfo.m_nAscent)
+ rInfo.m_nAscent = +rTTInfo.ascender;
+ if (!rInfo.m_nDescent)
+ rInfo.m_nDescent = +rTTInfo.typoDescender;
+ if (!rInfo.m_nDescent)
+ rInfo.m_nDescent = -rTTInfo.descender;
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/win/gdi/salfont.cxx b/vcl/win/gdi/salfont.cxx
index bc7f83b8b6f2..0d7930d20e71 100644
--- a/vcl/win/gdi/salfont.cxx
+++ b/vcl/win/gdi/salfont.cxx
@@ -1605,17 +1605,12 @@ bool WinSalGraphics::CreateFontSubset( const OUString& rToFile,
// check if the font has a CFF-table
const DWORD nCffTag = CalcTag( "CFF " );
const RawFontData aRawCffData( getHDC(), nCffTag );
- if( aRawCffData.get() )
+ if (aRawCffData.get())
{
pWinFontData->UpdateFromHDC( getHDC() );
-
- // provide a font subset from the CFF-table
- FILE* pOutFile = fopen( aToFile.getStr(), "wb" );
- rInfo.LoadFont( FontType::CFF_FONT, aRawCffData.get(), aRawCffData.size() );
- bool bRC = rInfo.CreateFontSubset( FontType::TYPE1_PFB, pOutFile, nullptr,
- pGlyphIds, pEncoding, nGlyphCount, pGlyphWidths );
- fclose( pOutFile );
- return bRC;
+ return SalGraphics::CreateCFFfontSubset(aRawCffData.get(), aRawCffData.size(), aToFile,
+ pGlyphIds, pEncoding, pGlyphWidths, nGlyphCount,
+ rInfo);
}
// get raw font file data
@@ -1635,60 +1630,12 @@ bool WinSalGraphics::CreateFontSubset( const OUString& rToFile,
TTGlobalFontInfo aTTInfo;
::GetTTGlobalFontInfo( aSftTTF.get(), &aTTInfo );
- rInfo.m_nFontType = FontType::SFNT_TTF;
- rInfo.m_aPSName = ImplSalGetUniString( aTTInfo.psname );
- rInfo.m_nAscent = aTTInfo.winAscent;
- rInfo.m_nDescent = aTTInfo.winDescent;
- rInfo.m_aFontBBox = tools::Rectangle( Point( aTTInfo.xMin, aTTInfo.yMin ),
- Point( aTTInfo.xMax, aTTInfo.yMax ) );
- rInfo.m_nCapHeight = aTTInfo.yMax; // Well ...
-
- // subset TTF-glyphs and get their properties
- // take care that subset fonts require the NotDef glyph in pos 0
- int nOrigCount = nGlyphCount;
- sal_uInt16 aShortIDs[ 256 ];
- sal_uInt8 aTempEncs[ 256 ];
-
- int nNotDef=-1, i;
- for( i = 0; i < nGlyphCount; ++i )
- {
- aTempEncs[i] = pEncoding[i];
- aShortIDs[i] = static_cast<sal_uInt16>(pGlyphIds[i]);
- if (!aShortIDs[i])
- if( nNotDef < 0 )
- nNotDef = i; // first NotDef glyph found
- }
-
- if( nNotDef != 0 )
- {
- // add fake NotDef glyph if needed
- if( nNotDef < 0 )
- nNotDef = nGlyphCount++;
-
- // NotDef glyph must be in pos 0 => swap glyphids
- aShortIDs[ nNotDef ] = aShortIDs[0];
- aTempEncs[ nNotDef ] = aTempEncs[0];
- aShortIDs[0] = 0;
- aTempEncs[0] = 0;
- }
- SAL_WARN_IF( nGlyphCount >= 257, "vcl", "too many glyphs for subsetting" );
-
- // fill pWidth array
- std::unique_ptr<sal_uInt16[]> pMetrics =
- ::GetTTSimpleGlyphMetrics( aSftTTF.get(), aShortIDs, nGlyphCount, aIFSD.mbVertical );
- if( !pMetrics )
- return false;
- sal_uInt16 nNotDefAdv = pMetrics[0];
- pMetrics[0] = pMetrics[nNotDef];
- pMetrics[nNotDef] = nNotDefAdv;
- for( i = 0; i < nOrigCount; ++i )
- pGlyphWidths[i] = pMetrics[i];
- pMetrics.reset();
+ OUString aPSName = ImplSalGetUniString(aTTInfo.psname);
+ FillFontSubsetInfo(aTTInfo, aPSName, rInfo);
// write subset into destination file
- nRC = ::CreateTTFromTTGlyphs( aSftTTF.get(), aToFile.getStr(), aShortIDs,
- aTempEncs, nGlyphCount );
- return (nRC == SFErrCodes::Ok);
+ return SalGraphics::CreateTTFfontSubset(*aSftTTF.get(), aToFile, aIFSD.mbVertical, pGlyphIds,
+ pEncoding, pGlyphWidths, nGlyphCount);
}
const void* WinSalGraphics::GetEmbedFontData(const PhysicalFontFace* pFont, long* pDataLen)