Kaydet (Commit) 5de78478 authored tarafından Jan-Marek Glogowski's avatar Jan-Marek Glogowski

WIN remove private-font fallback handling

The fallback code is from times, when FR_PRIVATE was not available
(pre Win2k). So just remove this special global font handling.

Change-Id: Ie54b0269513ab63d84e5c8bb4d4555a775161757
Reviewed-on: https://gerrit.libreoffice.org/66516
Tested-by: Jenkins
Reviewed-by: 's avatarJan-Marek Glogowski <glogow@fbihome.de>
üst 3bd7f23e
...@@ -1064,8 +1064,7 @@ static int CALLBACK SalEnumFontsProcExW( const LOGFONTW* lpelfe, ...@@ -1064,8 +1064,7 @@ static int CALLBACK SalEnumFontsProcExW( const LOGFONTW* lpelfe,
struct TempFontItem struct TempFontItem
{ {
OUString maFontFilePath; OUString maFontResourcePath;
OUString maResourcePath;
TempFontItem* mpNextItem; TempFontItem* mpNextItem;
}; };
...@@ -1076,57 +1075,23 @@ bool ImplAddTempFont( SalData& rSalData, const OUString& rFontFileURL ) ...@@ -1076,57 +1075,23 @@ bool ImplAddTempFont( SalData& rSalData, const OUString& rFontFileURL )
OSL_VERIFY( !osl::FileBase::getSystemPathFromFileURL( rFontFileURL, aUSytemPath ) ); OSL_VERIFY( !osl::FileBase::getSystemPathFromFileURL( rFontFileURL, aUSytemPath ) );
nRet = AddFontResourceExW( o3tl::toW(aUSytemPath.getStr()), FR_PRIVATE, nullptr ); nRet = AddFontResourceExW( o3tl::toW(aUSytemPath.getStr()), FR_PRIVATE, nullptr );
SAL_WARN_IF(!nRet, "vcl.fonts", "Adding private font failed: " << rFontFileURL);
if ( !nRet ) if (nRet > 0)
{ {
static int nCounter = 0; TempFontItem* pNewItem = new TempFontItem;
wchar_t aFileName[] = L"soAA.fot"; pNewItem->maFontResourcePath = aUSytemPath;
aFileName[2] = sal::static_int_cast<wchar_t>(L'A' + (15 & (nCounter>>4))); pNewItem->mpNextItem = rSalData.mpTempFontItem;
aFileName[3] = sal::static_int_cast<wchar_t>(L'A' + (15 & nCounter)); rSalData.mpTempFontItem = pNewItem;
wchar_t aResourceName[512];
int const nMaxLen = SAL_N_ELEMENTS(aResourceName) - 16;
int nLen = GetTempPathW( nMaxLen, aResourceName );
wcsncpy( aResourceName + nLen, aFileName, SAL_N_ELEMENTS( aResourceName ) - nLen );
// security: end buffer in any case
aResourceName[ SAL_N_ELEMENTS(aResourceName)-1 ] = 0;
DeleteFileW( aResourceName );
// TODO: font should be private => need to investigate why it doesn't work then
if( !CreateScalableFontResourceW( 0, aResourceName, o3tl::toW(aUSytemPath.getStr()), nullptr ) )
return false;
++nCounter;
nRet = AddFontResourceW( aResourceName );
if( nRet > 0 )
{
TempFontItem* pNewItem = new TempFontItem;
pNewItem->maResourcePath = o3tl::toU( aResourceName );
pNewItem->maFontFilePath = aUSytemPath;
pNewItem->mpNextItem = rSalData.mpTempFontItem;
rSalData.mpTempFontItem = pNewItem;
}
} }
return (nRet > 0); return (nRet > 0);
} }
void ImplReleaseTempFonts( SalData& rSalData ) void ImplReleaseTempFonts( SalData& rSalData )
{ {
int nCount = 0; while (TempFontItem* p = rSalData.mpTempFontItem)
while( TempFontItem* p = rSalData.mpTempFontItem )
{ {
++nCount; RemoveFontResourceExW(o3tl::toW(p->maFontResourcePath.getStr()),
if( p->maResourcePath.getLength() ) FR_PRIVATE, nullptr);
{
const wchar_t* pResourcePath = o3tl::toW(p->maResourcePath.getStr());
RemoveFontResourceW( pResourcePath );
DeleteFileW( pResourcePath );
}
else
{
RemoveFontResourceW( o3tl::toW(p->maFontFilePath.getStr()) );
}
rSalData.mpTempFontItem = p->mpNextItem; rSalData.mpTempFontItem = p->mpNextItem;
delete p; delete p;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment