mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Set small fontscache size by allfontsgen working... (#244)
This commit is contained in:
@ -392,6 +392,7 @@ namespace NSCommon
|
||||
{
|
||||
NSFonts::IFontManager* pManager = applicationFonts->GenerateFontManager();
|
||||
NSFonts::IFontsCache* pCache = NSFonts::NSFontCache::Create();
|
||||
pCache->SetCacheSize(3);
|
||||
pCache->SetStreams(applicationFonts->GetStreams());
|
||||
pManager->SetOwnerCache(pCache);
|
||||
|
||||
@ -427,6 +428,9 @@ namespace NSCommon
|
||||
pRenderer->put_Width(lWidthPix * 25.4 / dDpi);
|
||||
pRenderer->put_Height(lHeightPix * 25.4 / dDpi);
|
||||
|
||||
bool isUseMapForStreams = false;
|
||||
std::map<std::wstring, bool> mapUsedFiles;
|
||||
|
||||
for (int index = 0; index < nCountFonts; ++index)
|
||||
{
|
||||
std::map<std::wstring, CFontInfoJS>::iterator pPair = mapFonts.find(arrFonts[index]);
|
||||
@ -476,6 +480,9 @@ namespace NSCommon
|
||||
|
||||
if (NULL != pInfoCur)
|
||||
{
|
||||
if (isUseMapForStreams)
|
||||
mapUsedFiles.insert(std::pair<std::wstring, bool>(pInfoCur->m_wsFontPath, true));
|
||||
|
||||
pManager->LoadFontFromFile(pInfoCur->m_wsFontPath, 0, 14, dDpi, dDpi);
|
||||
}
|
||||
pRenderer->put_FontPath(pInfoCur->m_wsFontPath);
|
||||
@ -503,6 +510,9 @@ namespace NSCommon
|
||||
|
||||
if (NULL != pInfoCur)
|
||||
{
|
||||
if (isUseMapForStreams)
|
||||
mapUsedFiles.insert(std::pair<std::wstring, bool>(pInfoCur->m_wsFontPath, true));
|
||||
|
||||
pManager->LoadFontFromFile(pInfoCur->m_wsFontPath, 0, 14, dDpi, dDpi);
|
||||
}
|
||||
pRenderer->put_FontPath(pInfoCur->m_wsFontPath);
|
||||
@ -514,6 +524,11 @@ namespace NSCommon
|
||||
pRenderer->put_FontSize(14);
|
||||
|
||||
pRenderer->CommandDrawText(pPair->second.m_sName, 5, 25.4 * (index * lH1_px + lH1_px) / dDpi - 2, 0, 0);
|
||||
|
||||
if (isUseMapForStreams)
|
||||
applicationFonts->GetStreams()->CheckStreams(mapUsedFiles);
|
||||
else
|
||||
applicationFonts->GetStreams()->Clear();
|
||||
}
|
||||
|
||||
std::wstring strThumbnailPath = strFolderThumbnails + L"/fonts_thumbnail";
|
||||
|
||||
@ -104,7 +104,19 @@ NSFonts::IFontStream* CApplicationFontStreams::GetStream(const std::wstring &str
|
||||
}
|
||||
void CApplicationFontStreams::CheckStreams(std::map<std::wstring,bool> &mapFiles)
|
||||
{
|
||||
// TODO:
|
||||
std::map<std::wstring, CFontStream*>::iterator iter = m_mapStreams.begin();
|
||||
while (iter != m_mapStreams.end())
|
||||
{
|
||||
CFontStream* pFile = iter->second;
|
||||
|
||||
if (mapFiles.find(iter->first) != mapFiles.end())
|
||||
{
|
||||
iter = m_mapStreams.erase(iter);
|
||||
RELEASEINTERFACE(pFile);
|
||||
}
|
||||
else
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
|
||||
void CApplicationFontStreams::Clear()
|
||||
|
||||
Reference in New Issue
Block a user