Commit e7a531cd authored by Oleg.Korshul's avatar Oleg.Korshul Committed by Alexander Trofimov

новая версия

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@61555 954022d7-b5bf-4e40-9824-e11837661b57
parent 2ebe9701
......@@ -1260,11 +1260,34 @@ void CFontList::LoadFromArrayFiles(CArray<std::wstring>& oArray)
pParams[3].tag = FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY;
pParams[3].data = NULL;
// определяем размер буфера, чтобы не выделять много кусков, а обойтись одним
int nMaxFontSize = 0;
for (int nIndex = 0; nIndex < nCount; ++nIndex)
{
NSFile::CFileBinary oFile;
if (oFile.OpenFile(oArray[nIndex]))
{
int nSizeTmp = (int)oFile.GetFileSize();
if (nSizeTmp > 100000000)
{
// такие огромные шрифты не учитываем
oArray.RemoveAt(nIndex);
nIndex--;
nCount--;
}
if (nMaxFontSize < nSizeTmp)
nMaxFontSize = nSizeTmp;
}
}
BYTE* pDataFontFile = new BYTE[nMaxFontSize];
for (int nIndex = 0; nIndex < nCount; ++nIndex)
{
// open file
CFontStream oStream;
if (!oStream.CreateFromFile(oArray[nIndex]))
if (!oStream.CreateFromFile(oArray[nIndex], pDataFontFile))
continue;
FT_Open_Args oOpenArgs;
......@@ -1465,6 +1488,8 @@ void CFontList::LoadFromArrayFiles(CArray<std::wstring>& oArray)
}
}
RELEASEARRAYOBJECTS(pDataFontFile);
::free( pParams );
FT_Done_FreeType(pLibrary);
}
......
......@@ -9,9 +9,11 @@ CFontStream::CFontStream()
m_pData = NULL;
m_lSize = 0;
m_lRef = 1;
m_bIsAttach = false;
}
CFontStream::~CFontStream()
{
if (!m_bIsAttach)
RELEASEARRAYOBJECTS(m_pData);
}
......@@ -28,14 +30,21 @@ int CFontStream::Release()
return ret;
}
INT CFontStream::CreateFromFile(const std::wstring& strFileName)
INT CFontStream::CreateFromFile(const std::wstring& strFileName, BYTE* pDataUse)
{
NSFile::CFileBinary oFile;
if (!oFile.OpenFile(strFileName))
return FALSE;
m_lSize = oFile.GetFileSize();
if (NULL == pDataUse)
m_pData = new BYTE[m_lSize];
else
{
m_bIsAttach = true;
m_pData = pDataUse;
}
DWORD dwRead = 0;
DWORD dwNeedRead = (DWORD)m_lSize;
......@@ -43,7 +52,9 @@ INT CFontStream::CreateFromFile(const std::wstring& strFileName)
if (dwNeedRead != dwRead)
{
if (!m_bIsAttach)
RELEASEARRAYOBJECTS(m_pData);
m_lSize = 0;
return FALSE;
}
......
......@@ -14,6 +14,7 @@ private:
public:
BYTE* m_pData;
LONG m_lSize;
bool m_bIsAttach;
public:
CFontStream();
......@@ -24,7 +25,7 @@ public:
public:
virtual INT CreateFromFile(const std::wstring& strFileName);
virtual INT CreateFromFile(const std::wstring& strFileName, BYTE* pDataUse = NULL);
};
class CApplicationFontStreams
......
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