summaryrefslogtreecommitdiff
path: root/vcl/unx/generic/fontmanager
diff options
context:
space:
mode:
authorKhaled Hosny <khaled@aliftype.com>2022-09-11 01:23:16 +0200
committerخالد حسني <khaled@aliftype.com>2022-09-11 09:51:53 +0200
commit4286e745bccc7393ecd8b06346306d13d23316b5 (patch)
treea3ee27126cf59c27eaa549c9c3e3a70e9860812f /vcl/unx/generic/fontmanager
parentaa0a71b5cec118d4a4a922f6833ff20d7e4ba8ba (diff)
vcl: Add a PhysicalFontFace-backed TrueTypeFont
This is mainly to be able to get the font table data from the PhysicalFontFace so that an actual font file or full font data are not required (since they are not always available, e.g. with CoreText fonts). This is slightly based on QtTrueTypeFont that this code replaces. Change-Id: I6926706dfc6765076100ac0314a30f9ff970ddb6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139760 Tested-by: Jenkins Reviewed-by: خالد حسني <khaled@aliftype.com>
Diffstat (limited to 'vcl/unx/generic/fontmanager')
-rw-r--r--vcl/unx/generic/fontmanager/fontmanager.cxx19
1 files changed, 4 insertions, 15 deletions
diff --git a/vcl/unx/generic/fontmanager/fontmanager.cxx b/vcl/unx/generic/fontmanager/fontmanager.cxx
index 33ccb9987dad..1aed1a37d1d4 100644
--- a/vcl/unx/generic/fontmanager/fontmanager.cxx
+++ b/vcl/unx/generic/fontmanager/fontmanager.cxx
@@ -984,12 +984,8 @@ bool PrintFontManager::createFontSubset(
}
nGlyphs = nChar; // either input value or increased by one
- // prepare system name for read access for subset source file
- // TODO: since this file is usually already mmapped there is no need to open it again
- const OString aFromFile = getFontFile( *pFont );
-
- TrueTypeFont* pTTFont = nullptr; // TODO: rename to SfntFont
- if( OpenTTFontFile( aFromFile.getStr(), pFont->m_nCollectionEntry, &pTTFont, pFace->GetFontCharMap() ) != SFErrCodes::Ok )
+ TrueTypeFace aSftFont(*pFace);
+ if (aSftFont.initialize() != SFErrCodes::Ok)
return false;
// prepare system name for write access for subset file target
@@ -1001,7 +997,7 @@ bool PrintFontManager::createFontSubset(
// do CFF subsetting if possible
sal_uInt32 nCffLength = 0;
- const sal_uInt8* pCffBytes = pTTFont->table(vcl::O_CFF, nCffLength);
+ const sal_uInt8* pCffBytes = aSftFont.table(vcl::O_CFF, nCffLength);
if (pCffBytes)
{
rInfo.LoadFont( FontType::CFF_FONT, pCffBytes, nCffLength );
@@ -1013,10 +1009,7 @@ bool PrintFontManager::createFontSubset(
// create subset file at requested path
FILE* pOutFile = fopen( aToFile.getStr(), "wb" );
if (!pOutFile)
- {
- CloseTTFont( pTTFont );
return false;
- }
// create font subset
const char* const pGlyphSetName = nullptr; // TODO: better name?
const bool bOK = rInfo.CreateFontSubset(
@@ -1031,8 +1024,6 @@ bool PrintFontManager::createFontSubset(
rInfo.m_nAscent = aFontInfo.m_nAscend;
rInfo.m_nDescent = -aFontInfo.m_nDescend;
}
- // cleanup before early return
- CloseTTFont( pTTFont );
return bOK;
}
@@ -1051,13 +1042,11 @@ bool PrintFontManager::createFontSubset(
rInfo.m_aFontBBox = tools::Rectangle( Point( xMin, yMin ), Size( xMax-xMin, yMax-yMin ) );
rInfo.m_nCapHeight = yMax; // Well ...
- bool bSuccess = ( SFErrCodes::Ok == CreateTTFromTTGlyphs( pTTFont,
+ bool bSuccess = ( SFErrCodes::Ok == CreateTTFromTTGlyphs(&aSftFont,
aToFile.getStr(),
pGID,
pEnc,
nGlyphs ) );
- CloseTTFont( pTTFont );
-
return bSuccess;
}