vcl/generic/fontmanager/fontmanager.cxx | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
New commits: commit c3e4ad052f7fceda20441809e48573dc6a1589ae Author: Caolán McNamara <caol...@redhat.com> Date: Sat Oct 5 10:32:12 2013 +0100 CID#736943 clamp no of ttc entries to physical max Change-Id: Ic63defe9c14c6ee2b86bd5b7730a570238ca3981 (cherry picked from commit 225539ab08043b6937fdd67d9ae308ebd4104646) Reviewed-on: https://gerrit.libreoffice.org/6149 Reviewed-by: Michael Stahl <mst...@redhat.com> Tested-by: Michael Stahl <mst...@redhat.com> diff --git a/vcl/generic/fontmanager/fontmanager.cxx b/vcl/generic/fontmanager/fontmanager.cxx index aa84fc7..a915d7d 100644 --- a/vcl/generic/fontmanager/fontmanager.cxx +++ b/vcl/generic/fontmanager/fontmanager.cxx @@ -1192,6 +1192,39 @@ bool PrintFontManager::analyzeFontFile( int nDirID, const OString& rFontFile, :: #if OSL_DEBUG_LEVEL > 1 fprintf( stderr, "ttc: %s contains %d fonts\n", aFullPath.getStr(), nLength ); #endif + + sal_uInt64 fileSize; + + OUString aURL; + if (!osl::File::getFileURLFromSystemPath(OStringToOUString(aFullPath, osl_getThreadTextEncoding()), + aURL)) + { + fileSize = 0; + } + else + { + osl::File aFile(aURL); + if (aFile.open(osl_File_OpenFlag_Read | osl_File_OpenFlag_NoLock) != osl::File::E_None) + fileSize = 0; + else + { + osl::DirectoryItem aItem; + osl::DirectoryItem::get( aURL, aItem ); + osl::FileStatus aFileStatus( osl_FileStatus_Mask_FileSize ); + aItem.getFileStatus( aFileStatus ); + 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 + int nMaxFontsPossible = fileSize / 528; + + nLength = std::min(nLength, nMaxFontsPossible); + for( int i = 0; i < nLength; i++ ) { TrueTypeFontFile* pFont = new TrueTypeFontFile();
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits