mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
новая версия
git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@61555 954022d7-b5bf-4e40-9824-e11837661b57
This commit is contained in:
committed by
Alexander Trofimov
parent
2ebe97014c
commit
e7a531cdfa
@ -1258,13 +1258,36 @@ void CFontList::LoadFromArrayFiles(CArray<std::wstring>& oArray)
|
||||
pParams[2].tag = FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY;
|
||||
pParams[2].data = NULL;
|
||||
pParams[3].tag = FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY;
|
||||
pParams[3].data = NULL;
|
||||
|
||||
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;
|
||||
@ -1464,6 +1487,8 @@ void CFontList::LoadFromArrayFiles(CArray<std::wstring>& oArray)
|
||||
FT_Done_Face( pFace );
|
||||
}
|
||||
}
|
||||
|
||||
RELEASEARRAYOBJECTS(pDataFontFile);
|
||||
|
||||
::free( pParams );
|
||||
FT_Done_FreeType(pLibrary);
|
||||
|
||||
@ -9,10 +9,12 @@ CFontStream::CFontStream()
|
||||
m_pData = NULL;
|
||||
m_lSize = 0;
|
||||
m_lRef = 1;
|
||||
m_bIsAttach = false;
|
||||
}
|
||||
CFontStream::~CFontStream()
|
||||
{
|
||||
RELEASEARRAYOBJECTS(m_pData);
|
||||
if (!m_bIsAttach)
|
||||
RELEASEARRAYOBJECTS(m_pData);
|
||||
}
|
||||
|
||||
int CFontStream::AddRef()
|
||||
@ -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();
|
||||
m_pData = new BYTE[m_lSize];
|
||||
|
||||
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)
|
||||
{
|
||||
RELEASEARRAYOBJECTS(m_pData);
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user