summaryrefslogtreecommitdiff
path: root/vcl/unx/generic/fontmanager/fontmanager.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'vcl/unx/generic/fontmanager/fontmanager.cxx')
-rw-r--r--vcl/unx/generic/fontmanager/fontmanager.cxx90
1 files changed, 53 insertions, 37 deletions
diff --git a/vcl/unx/generic/fontmanager/fontmanager.cxx b/vcl/unx/generic/fontmanager/fontmanager.cxx
index 6266d7646663..0d48a692e97e 100644
--- a/vcl/unx/generic/fontmanager/fontmanager.cxx
+++ b/vcl/unx/generic/fontmanager/fontmanager.cxx
@@ -178,25 +178,38 @@ std::vector<PrintFontManager::PrintFont> PrintFontManager::analyzeFontFile( int
OString aFullPath = aDir + "/" + rFontFile;
- // #i1872# reject unreadable files
- if( access( aFullPath.getStr(), R_OK ) )
- return aNewFonts;
-
- bool bSupported = false;
- if (pFormat)
+ bool bSupported;
+ bool bHack = false;
+ int nFD;
+ int n;
+ if (sscanf(aFullPath.getStr(), "/:FD:/%d%n", &nFD, &n) == 1 && aFullPath.getStr()[n] == '\0')
{
- if (!strcmp(pFormat, "TrueType") ||
- !strcmp(pFormat, "CFF"))
- bSupported = true;
+ // Hack, pathname that actually means we will use a pre-opened file descriptor
+ bSupported = true;
+ bHack = true;
}
- if (!bSupported)
+ else
{
- OString aExt( rFontFile.copy( rFontFile.lastIndexOf( '.' )+1 ) );
- if( aExt.equalsIgnoreAsciiCase("ttf")
- || aExt.equalsIgnoreAsciiCase("ttc")
- || aExt.equalsIgnoreAsciiCase("tte") // #i33947# for Gaiji support
- || aExt.equalsIgnoreAsciiCase("otf") ) // check for TTF- and PS-OpenType too
- bSupported = true;
+ // #i1872# reject unreadable files
+ if( access( aFullPath.getStr(), R_OK ) )
+ return aNewFonts;
+
+ bSupported = false;
+ if (pFormat)
+ {
+ if (!strcmp(pFormat, "TrueType") ||
+ !strcmp(pFormat, "CFF"))
+ bSupported = true;
+ }
+ if (!bSupported)
+ {
+ OString aExt( rFontFile.copy( rFontFile.lastIndexOf( '.' )+1 ) );
+ if( aExt.equalsIgnoreAsciiCase("ttf")
+ || aExt.equalsIgnoreAsciiCase("ttc")
+ || aExt.equalsIgnoreAsciiCase("tte") // #i33947# for Gaiji support
+ || aExt.equalsIgnoreAsciiCase("otf") ) // check for TTF- and PS-OpenType too
+ bSupported = true;
+ }
}
if (bSupported)
@@ -207,33 +220,36 @@ std::vector<PrintFontManager::PrintFont> PrintFontManager::analyzeFontFile( int
{
SAL_INFO("vcl.fonts", "ttc: " << aFullPath << " contains " << nLength << " fonts");
- sal_uInt64 fileSize = 0;
-
- OUString aURL;
- if (osl::File::getFileURLFromSystemPath(OStringToOUString(aFullPath, osl_getThreadTextEncoding()),
- aURL) == osl::File::E_None)
+ if (!bHack)
{
- osl::File aFile(aURL);
- if (aFile.open(osl_File_OpenFlag_Read | osl_File_OpenFlag_NoLock) == osl::File::E_None)
+ sal_uInt64 fileSize = 0;
+
+ OUString aURL;
+ if (osl::File::getFileURLFromSystemPath(OStringToOUString(aFullPath, osl_getThreadTextEncoding()),
+ aURL) == osl::File::E_None)
{
- osl::DirectoryItem aItem;
- if (osl::DirectoryItem::get(aURL, aItem) == osl::File::E_None)
+ osl::File aFile(aURL);
+ if (aFile.open(osl_File_OpenFlag_Read | osl_File_OpenFlag_NoLock) == osl::File::E_None)
{
- osl::FileStatus aFileStatus( osl_FileStatus_Mask_FileSize );
- if (aItem.getFileStatus(aFileStatus) == osl::File::E_None)
- fileSize = aFileStatus.getFileSize();
+ osl::DirectoryItem aItem;
+ if (osl::DirectoryItem::get(aURL, aItem) == osl::File::E_None)
+ {
+ osl::FileStatus aFileStatus( osl_FileStatus_Mask_FileSize );
+ if (aItem.getFileStatus(aFileStatus) == osl::File::E_None)
+ fileSize = aFileStatus.getFileSize();
+ }
}
}
- }
- //Feel free to calc the exact max possible number of fonts a file
- //could contain given its physical size. But this will clamp it to
- //a sane starting point
- //http://processingjs.nihongoresources.com/the_smallest_font/
- //https://github.com/grzegorzrolek/null-ttf
- const int nMaxFontsPossible = fileSize / 528;
- if (nLength > nMaxFontsPossible)
- nLength = nMaxFontsPossible;
+ //Feel free to calc the exact max possible number of fonts a file
+ //could contain given its physical size. But this will clamp it to
+ //a sane starting point
+ //http://processingjs.nihongoresources.com/the_smallest_font/
+ //https://github.com/grzegorzrolek/null-ttf
+ const int nMaxFontsPossible = fileSize / 528;
+ if (nLength > nMaxFontsPossible)
+ nLength = nMaxFontsPossible;
+ }
for( int i = 0; i < nLength; i++ )
{