Commit 399a1dd5 authored by Ilya.Kirillov's avatar Ilya.Kirillov Committed by Alexander Trofimov

Немного переделана работа со шрифтами: теперь список открытых FontFace...

Немного переделана работа со шрифтами: теперь список открытых FontFace храниться в документе, и если происходит их переполнение, то самые неиспользуемые закрываются.

git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@63326 954022d7-b5bf-4e40-9824-e11837661b57
parent 6af1ad10
...@@ -318,6 +318,7 @@ namespace NSOnlineOfficeBinToPdf ...@@ -318,6 +318,7 @@ namespace NSOnlineOfficeBinToPdf
bIsPathOpened = false; bIsPathOpened = false;
pPdf->EndCommand(c_nPageType); pPdf->EndCommand(c_nPageType);
break; break;
} }
case ctPenColor: case ctPenColor:
......
...@@ -232,8 +232,6 @@ private: ...@@ -232,8 +232,6 @@ private:
double m_dX; double m_dX;
double m_dY; double m_dY;
int m_nUpdateFlags;
CFontDict* m_pFont; CFontDict* m_pFont;
double m_dSize; double m_dSize;
LONG m_lColor; LONG m_lColor;
...@@ -382,7 +380,7 @@ void CPdfRenderer::CCommandManager::Clear() ...@@ -382,7 +380,7 @@ void CPdfRenderer::CCommandManager::Clear()
for (int nIndex = 0, nCount = m_vCommands.size(); nIndex < nCount; nIndex++) for (int nIndex = 0, nCount = m_vCommands.size(); nIndex < nCount; nIndex++)
{ {
CRendererCommandBase* pCommand = m_vCommands.at(nIndex); CRendererCommandBase* pCommand = m_vCommands.at(nIndex);
delete[] pCommand; delete pCommand;
} }
m_vCommands.clear(); m_vCommands.clear();
} }
...@@ -1374,7 +1372,6 @@ bool CPdfRenderer::DrawText(unsigned int* pUnicodes, unsigned int unLen, const d ...@@ -1374,7 +1372,6 @@ bool CPdfRenderer::DrawText(unsigned int* pUnicodes, unsigned int unLen, const d
return false; return false;
unsigned char* pCodes = m_pFont->EncodeString(pUnicodes, unLen); unsigned char* pCodes = m_pFont->EncodeString(pUnicodes, unLen);
delete[] pUnicodes;
CTransform& t = m_oTransform; CTransform& t = m_oTransform;
m_oCommandManager.SetTransform(t.m11, -t.m12, -t.m21, t.m22, MM_2_PT(t.dx + t.m21 * m_dPageHeight), MM_2_PT(m_dPageHeight - m_dPageHeight * t.m22 - t.dy)); m_oCommandManager.SetTransform(t.m11, -t.m12, -t.m21, t.m22, MM_2_PT(t.dx + t.m21 * m_dPageHeight), MM_2_PT(m_dPageHeight - m_dPageHeight * t.m22 - t.dy));
...@@ -1444,8 +1441,8 @@ void CPdfRenderer::UpdateTransform() ...@@ -1444,8 +1441,8 @@ void CPdfRenderer::UpdateTransform()
t.m12 = -m_oTransform.m12; t.m12 = -m_oTransform.m12;
t.m21 = -m_oTransform.m21; t.m21 = -m_oTransform.m21;
t.m22 = m_oTransform.m22; t.m22 = m_oTransform.m22;
t.dx = MM_2_PT(t.dx + t.m21 * m_dPageHeight); t.dx = MM_2_PT(m_oTransform.dx + m_oTransform.m21 * m_dPageHeight);
t.dy = MM_2_PT(m_dPageHeight - m_dPageHeight * t.m22 - t.dy); t.dy = MM_2_PT(m_dPageHeight - m_dPageHeight * m_oTransform.m22 - m_oTransform.dy);
if (!t.IsIdentity()) if (!t.IsIdentity())
m_pPage->Concat(t.m11, t.m12, t.m21, t.m22, t.dx, t.dy); m_pPage->Concat(t.m11, t.m12, t.m21, t.m22, t.dx, t.dy);
...@@ -1629,6 +1626,7 @@ void CPdfRenderer::UpdateBrush() ...@@ -1629,6 +1626,7 @@ void CPdfRenderer::UpdateBrush()
m_pShading = m_pDocument->CreateRadialShading(m_pPage, MM_2_PT(dX0), MM_2_PT(m_dPageHeight - dY0), MM_2_PT(dR0), MM_2_PT(dX1), MM_2_PT(m_dPageHeight - dY1), MM_2_PT(dR1), pColors, pAlphas, pPoints, lCount, m_pShadingExtGrState); m_pShading = m_pDocument->CreateRadialShading(m_pPage, MM_2_PT(dX0), MM_2_PT(m_dPageHeight - dY0), MM_2_PT(dR0), MM_2_PT(dX1), MM_2_PT(m_dPageHeight - dY1), MM_2_PT(dR1), pColors, pAlphas, pPoints, lCount, m_pShadingExtGrState);
} }
delete[] pColors; delete[] pColors;
delete[] pAlphas;
} }
} }
} }
......
...@@ -913,8 +913,8 @@ void ConvertFolder(std::wstring wsFolderPath, const int nType) ...@@ -913,8 +913,8 @@ void ConvertFolder(std::wstring wsFolderPath, const int nType)
} }
void TestMetafile() void TestMetafile()
{ {
//ConvertFolder(L"D://Test Files//Emf//", MetaFile::c_lMetaEmf); ConvertFolder(L"D://Test Files//Emf//", MetaFile::c_lMetaEmf);
ConvertFolder(L"D://Test Files//Wmf//", MetaFile::c_lMetaWmf); //ConvertFolder(L"D://Test Files//Wmf//", MetaFile::c_lMetaWmf);
} }
void TestOnlineBin() void TestOnlineBin()
{ {
...@@ -961,8 +961,8 @@ void main() ...@@ -961,8 +961,8 @@ void main()
//TestDocument7(); //TestDocument7();
//TestDocument8(); //TestDocument8();
//TestDocument9(); //TestDocument9();
//TestMetafile(); TestMetafile();
TestOnlineBin(); //TestOnlineBin();
char q; char q;
std::cin >> q; std::cin >> q;
......
This diff is collapsed.
...@@ -44,6 +44,7 @@ namespace PdfWriter ...@@ -44,6 +44,7 @@ namespace PdfWriter
m_pJbig2 = NULL; m_pJbig2 = NULL;
memset((void*)m_sTTFontTag, 0x00, 8); memset((void*)m_sTTFontTag, 0x00, 8);
m_pTransparencyGroup = NULL; m_pTransparencyGroup = NULL;
m_pFreeTypeLibrary = NULL;
} }
CDocument::~CDocument() CDocument::~CDocument()
{ {
...@@ -93,27 +94,35 @@ namespace PdfWriter ...@@ -93,27 +94,35 @@ namespace PdfWriter
void CDocument::Close() void CDocument::Close()
{ {
// Все объекты удаляются внутри CXref // Все объекты удаляются внутри CXref
if (m_pXref) RELEASEOBJECT(m_pXref);
{
delete m_pXref;
m_pXref = NULL;
}
m_pTrailer = NULL; m_pTrailer = NULL;
m_pResources = NULL;
m_pCatalog = NULL; m_pCatalog = NULL;
m_pOutlines = NULL; m_pOutlines = NULL;
m_pPageTree = NULL; m_pPageTree = NULL;
m_pCurPage = NULL; m_pCurPage = NULL;
m_nCurPageNum = 0;
m_bEncrypt = false; m_bEncrypt = false;
m_pEncryptDict = NULL; m_pEncryptDict = NULL;
m_pInfo = NULL; m_pInfo = NULL;
m_unCompressMode = COMP_NONE; m_unCompressMode = COMP_NONE;
m_pJbig2 = NULL;
m_pTransparencyGroup= NULL;
memset((void*)m_sTTFontTag, 0x00, 8); memset((void*)m_sTTFontTag, 0x00, 8);
m_vExtGrStates.clear();
m_vPages.clear(); m_vPages.clear();
m_vExtGrStates.clear();
m_vStrokeAlpha.clear();
m_vFillAlpha.clear();
m_vShadings.clear(); m_vShadings.clear();
m_vTTFonts.clear(); m_vTTFonts.clear();
m_vFreeTypeFonts.clear();
if (m_pFreeTypeLibrary)
{
FT_Done_FreeType(m_pFreeTypeLibrary);
m_pFreeTypeLibrary = NULL;
}
} }
bool CDocument::SaveToFile(const std::wstring& wsPath) bool CDocument::SaveToFile(const std::wstring& wsPath)
{ {
...@@ -453,6 +462,41 @@ namespace PdfWriter ...@@ -453,6 +462,41 @@ namespace PdfWriter
return m_sTTFontTag; return m_sTTFontTag;
} }
void CDocument::AddFreeTypeFont(CFontCidTrueType* pFont)
{
for (int nIndex = 0, nCount = m_vFreeTypeFonts.size(); nIndex < nCount; nIndex++)
{
if (pFont == m_vFreeTypeFonts.at(nIndex))
{
if (nIndex >= 10)
{
m_vFreeTypeFonts.erase(m_vFreeTypeFonts.begin() + nIndex);
m_vFreeTypeFonts.insert(m_vFreeTypeFonts.begin(), pFont);
}
return;
}
}
m_vFreeTypeFonts.insert(m_vFreeTypeFonts.begin(), pFont);
int nFontsCount = m_vFreeTypeFonts.size();
if (nFontsCount > MAX_OPENED_FT_FACES)
{
for (int nFontIndex = MAX_OPENED_FT_FACES; nFontIndex < nFontsCount; nFontIndex++)
{
CFontCidTrueType* pFont = m_vFreeTypeFonts.at(nFontIndex);
pFont->CloseFontFace();
}
m_vFreeTypeFonts.erase(m_vFreeTypeFonts.begin() + MAX_OPENED_FT_FACES, m_vFreeTypeFonts.end());
}
}
FT_Library CDocument::GetFreeTypeLibrary()
{
if (!m_pFreeTypeLibrary)
FT_Init_FreeType(&m_pFreeTypeLibrary);
return m_pFreeTypeLibrary;
}
CJbig2Global* CDocument::GetJbig2Global() CJbig2Global* CDocument::GetJbig2Global()
{ {
if (m_pJbig2 && m_pJbig2->GetImagesCount() > 4) if (m_pJbig2 && m_pJbig2->GetImagesCount() > 4)
......
...@@ -5,6 +5,10 @@ ...@@ -5,6 +5,10 @@
#include <string> #include <string>
#include "Types.h" #include "Types.h"
#include "../../DesktopEditor/fontengine/FontManager.h"
#include "../../DesktopEditor/common/File.h"
#include FT_TRUETYPE_TABLES_H
#ifdef CreateFont #ifdef CreateFont
#undef CreateFont #undef CreateFont
#endif #endif
...@@ -79,6 +83,8 @@ namespace PdfWriter ...@@ -79,6 +83,8 @@ namespace PdfWriter
private: private:
char* GetTTFontTag(); char* GetTTFontTag();
void AddFreeTypeFont(CFontCidTrueType* pFont);
FT_Library GetFreeTypeLibrary();
CExtGrState* FindExtGrState(double dAlphaStroke = -1, double dAlphaFill = -1, EBlendMode eMode = blendmode_Unknown, int nStrokeAdjustment = -1); CExtGrState* FindExtGrState(double dAlphaStroke = -1, double dAlphaFill = -1, EBlendMode eMode = blendmode_Unknown, int nStrokeAdjustment = -1);
void SaveToStream(CStream* pStream); void SaveToStream(CStream* pStream);
void PrepareEncryption(); void PrepareEncryption();
...@@ -124,6 +130,8 @@ namespace PdfWriter ...@@ -124,6 +130,8 @@ namespace PdfWriter
std::vector<CShading*> m_vShadings; std::vector<CShading*> m_vShadings;
std::vector<TFontInfo> m_vTTFonts; std::vector<TFontInfo> m_vTTFonts;
CDictObject* m_pTransparencyGroup; CDictObject* m_pTransparencyGroup;
std::vector<CFontCidTrueType*> m_vFreeTypeFonts;
FT_Library m_pFreeTypeLibrary;
friend class CFontCidTrueType; friend class CFontCidTrueType;
}; };
......
...@@ -108,29 +108,10 @@ namespace PdfWriter ...@@ -108,29 +108,10 @@ namespace PdfWriter
CreateCIDFont2(pFont); CreateCIDFont2(pFont);
m_pFace = NULL;
//-----------------------------------------------------------------------------------------
FT_Init_FreeType(&m_pLibrary);
NSFile::CFileBinary oFile;
oFile.OpenFile(m_wsFontPath, false);
DWORD lFileSize = oFile.SizeFile();
m_pFaceMemory = new FT_Byte[lFileSize];
if (!m_pFaceMemory)
{
FT_Done_FreeType(m_pLibrary);
return;
}
NSFile::CFileBinary::ReadAllBytes(m_wsFontPath, &m_pFaceMemory, lFileSize);
FT_New_Memory_Face(m_pLibrary, m_pFaceMemory, lFileSize, m_unFontIndex, &m_pFace);
if (!m_pFace)
{
FT_Done_FreeType(m_pLibrary);
delete[] m_pFaceMemory;
m_pFaceMemory = NULL; m_pFaceMemory = NULL;
return; m_nGlyphsCount = 0;
} m_nSymbolicCmap = -1;
} }
CFontCidTrueType::~CFontCidTrueType() CFontCidTrueType::~CFontCidTrueType()
{ {
...@@ -140,9 +121,6 @@ namespace PdfWriter ...@@ -140,9 +121,6 @@ namespace PdfWriter
if (m_pFace) if (m_pFace)
FT_Done_Face(m_pFace); FT_Done_Face(m_pFace);
if (m_pLibrary)
FT_Done_FreeType(m_pLibrary);
if (m_pFaceMemory) if (m_pFaceMemory)
delete[] m_pFaceMemory; delete[] m_pFaceMemory;
} }
...@@ -199,7 +177,12 @@ namespace PdfWriter ...@@ -199,7 +177,12 @@ namespace PdfWriter
} }
unsigned char* CFontCidTrueType::EncodeString(unsigned int* pUnicodes, unsigned int unLen) unsigned char* CFontCidTrueType::EncodeString(unsigned int* pUnicodes, unsigned int unLen)
{ {
if (!OpenFontFace())
return NULL;
unsigned char* pEncodedString = new unsigned char[unLen * 2]; unsigned char* pEncodedString = new unsigned char[unLen * 2];
if (!pEncodedString)
return NULL;
// 0x0000..0xFFFF // 0x0000..0xFFFF
// Gid . // Gid .
...@@ -222,6 +205,9 @@ namespace PdfWriter ...@@ -222,6 +205,9 @@ namespace PdfWriter
m_vUnicodes.push_back(unUnicode); m_vUnicodes.push_back(unUnicode);
unsigned short ushGID = GetGID(m_pFace, unUnicode); unsigned short ushGID = GetGID(m_pFace, unUnicode);
if (0 == ushGID && -1 != m_nSymbolicCmap)
ushGID = GetGID(m_pFace, unUnicode + 0xF000);
m_vCodeToGid.push_back(ushGID); m_vCodeToGid.push_back(ushGID);
// //
...@@ -270,7 +256,8 @@ namespace PdfWriter ...@@ -270,7 +256,8 @@ namespace PdfWriter
unsigned char* pGlyphs; unsigned char* pGlyphs;
unsigned int unGlyphsCount; unsigned int unGlyphsCount;
GetWidthsAndGids(&pCodeToGid, &pWidths, &pGlyphs, unGlyphsCount); if (!GetWidthsAndGids(&pCodeToGid, &pWidths, &pGlyphs, unGlyphsCount))
return;
CStream* pStream = m_pFontFileDict->GetStream(); CStream* pStream = m_pFontFileDict->GetStream();
m_pFontFile->WriteTTF(pStream, NULL, pCodeToGid, m_ushCodesCount, pGlyphs, unGlyphsCount); m_pFontFile->WriteTTF(pStream, NULL, pCodeToGid, m_ushCodesCount, pGlyphs, unGlyphsCount);
...@@ -295,106 +282,60 @@ namespace PdfWriter ...@@ -295,106 +282,60 @@ namespace PdfWriter
pStream->WriteChar((ushGid & 0xFF)); pStream->WriteChar((ushGid & 0xFF));
} }
RELEASEARRAYOBJECTS(pCodeToGid);
RELEASEARRAYOBJECTS(pWidths);
RELEASEARRAYOBJECTS(pGlyphs);
WriteToUnicode(); WriteToUnicode();
} }
} }
void CFontCidTrueType::GetWidthsAndGids(unsigned short** ppCodeToGid, unsigned int** ppWidths, unsigned char** ppGlyphs, unsigned int& unGlyphsCount) bool CFontCidTrueType::GetWidthsAndGids(unsigned short** ppCodeToGid, unsigned int** ppWidths, unsigned char** ppGlyphs, unsigned int& unGlyphsCount)
{ {
FT_Library pLibrary = NULL; *ppCodeToGid = NULL;
FT_Init_FreeType(&pLibrary); *ppWidths = NULL;
FT_Face pFace = NULL; *ppGlyphs = NULL;
unGlyphsCount = 0;
NSFile::CFileBinary oFile; if (!m_nGlyphsCount)
oFile.OpenFile(m_wsFontPath, false); return false;
DWORD lFileSize = oFile.SizeFile();
FT_Byte* pMemory = new FT_Byte[lFileSize];
if (!pMemory)
{
FT_Done_FreeType(pLibrary);
return;
}
NSFile::CFileBinary::ReadAllBytes(m_wsFontPath, &pMemory, lFileSize); unsigned short* pCodeToGID = new unsigned short[m_ushCodesCount];
if (!pCodeToGID)
return false;
FT_New_Memory_Face(pLibrary, pMemory, lFileSize, m_unFontIndex, &pFace); unsigned int* pWidths = new unsigned int[m_ushCodesCount];
if (!pFace) if (!pWidths)
{ {
FT_Done_FreeType(pLibrary); delete[] pCodeToGID;
return; return false;
} }
memset((void*)pWidths, 0x00, m_ushCodesCount * sizeof(unsigned int));
int nSymbolic = GetSymbolicCmapIndex(pFace);
unsigned short* pCodeToGID = new unsigned short[m_ushCodesCount];
for (unsigned short ushCode = 0; ushCode < m_ushCodesCount; ushCode++) for (unsigned short ushCode = 0; ushCode < m_ushCodesCount; ushCode++)
{ {
unsigned int unUnicode = m_vUnicodes[ushCode]; pCodeToGID[ushCode] = m_vCodeToGid.at(ushCode);
pCodeToGID[ushCode] = GetGID(pFace, unUnicode); pWidths[ushCode] = m_vWidths.at(ushCode);
if (0 == pCodeToGID[ushCode] && -1 != nSymbolic)
pCodeToGID[ushCode] = GetGID(pFace, unUnicode + 0xF000);
} }
// , unsigned char *pGlyphs = new unsigned char[m_nGlyphsCount];
long lGlyfsCount = pFace->num_glyphs; if (!pGlyphs)
unsigned char *pUseGlyf = new unsigned char[lGlyfsCount];
memset((void *)pUseGlyf, 0x00, pFace->num_glyphs * sizeof(unsigned char));
//
unsigned int* pWidths = new unsigned int[m_ushCodesCount];
memset((void*)pWidths, 0x00, m_ushCodesCount * sizeof(unsigned int));
for (unsigned short ushCode = 0; ushCode < m_ushCodesCount; ushCode++)
{ {
unsigned short ushGID = pCodeToGID[ushCode]; delete[] pCodeToGID;
delete[] pWidths;
if ((long)ushGID >= lGlyfsCount) return false;
continue;
//
pUseGlyf[ushGID] = 1;
// (CompositeGlyf), (subglyfs)
if (0 == FT_Load_Glyph(pFace, ushGID, FT_LOAD_NO_SCALE | FT_LOAD_NO_RECURSE))
{
for (int nSubIndex = 0; nSubIndex < pFace->glyph->num_subglyphs; nSubIndex++)
{
FT_Int nSubGID;
FT_UInt unFlags;
FT_Int nArg1;
FT_Int nArg2;
FT_Matrix oMatrix;
FT_Get_SubGlyph_Info(pFace->glyph, nSubIndex, &nSubGID, &unFlags, &nArg1, &nArg2, &oMatrix);
pUseGlyf[nSubGID] = 1;
} }
if (0 != pFace->units_per_EM) memset((void *)pGlyphs, 0x00, m_nGlyphsCount * sizeof(unsigned char));
pWidths[ushCode] = (unsigned int)pFace->glyph->metrics.horiAdvance * 1000 / pFace->units_per_EM; for (auto oIt : m_mGlyphs)
else {
pWidths[ushCode] = (unsigned int)pFace->glyph->metrics.horiAdvance; pGlyphs[oIt.first] = 1;
}
} }
// ,
std::string sFontName = m_pDocument->GetTTFontTag() + std::string(pFace->family_name);
if (pFace->style_flags & FT_STYLE_FLAG_ITALIC)
sFontName += "-Italic";
if (pFace->style_flags & FT_STYLE_FLAG_BOLD)
sFontName += "-Bold";
const char* sName = sFontName.c_str();
Add("BaseFont", sName);
m_pFont->Add("BaseFont", sName);
m_pFontDescriptor->Add("FontName", sName);
FT_Done_Face(pFace);
FT_Done_FreeType(pLibrary);
delete[] pMemory;
*ppCodeToGid = pCodeToGID; *ppCodeToGid = pCodeToGID;
*ppWidths = pWidths; *ppWidths = pWidths;
*ppGlyphs = pUseGlyf; *ppGlyphs = pGlyphs;
unGlyphsCount = lGlyfsCount; unGlyphsCount = m_nGlyphsCount;
return true;
} }
void CFontCidTrueType::WriteToUnicode() void CFontCidTrueType::WriteToUnicode()
{ {
...@@ -432,4 +373,47 @@ namespace PdfWriter ...@@ -432,4 +373,47 @@ namespace PdfWriter
pS->WriteStr("endbfchar\n"); pS->WriteStr("endbfchar\n");
m_pToUnicodeStream->WriteStr(c_sToUnicodeFooter); m_pToUnicodeStream->WriteStr(c_sToUnicodeFooter);
} }
void CFontCidTrueType::CloseFontFace()
{
if (m_pFace)
{
FT_Done_Face(m_pFace);
m_pFace = NULL;
}
RELEASEARRAYOBJECTS(m_pFaceMemory);
}
bool CFontCidTrueType::OpenFontFace()
{
if (m_pFace)
{
m_pDocument->AddFreeTypeFont(this);
return true;
}
m_nGlyphsCount = 0;
m_nSymbolicCmap = -1;
FT_Library pLibrary = m_pDocument->GetFreeTypeLibrary();
if (!pLibrary)
return false;
DWORD dwFileSize;
m_pFaceMemory = NULL;
NSFile::CFileBinary::ReadAllBytes(m_wsFontPath, &m_pFaceMemory, dwFileSize);
if (!m_pFaceMemory)
return false;
FT_New_Memory_Face(pLibrary, m_pFaceMemory, dwFileSize, m_unFontIndex, &m_pFace);
if (!m_pFace)
{
RELEASEARRAYOBJECTS(m_pFaceMemory);
return false;
}
m_pDocument->AddFreeTypeFont(this);
m_nGlyphsCount = m_pFace->num_glyphs;
m_nSymbolicCmap = GetSymbolicCmapIndex(m_pFace);
return true;
}
} }
...@@ -33,13 +33,14 @@ namespace PdfWriter ...@@ -33,13 +33,14 @@ namespace PdfWriter
return fontCIDType2; return fontCIDType2;
} }
private: private:
void BeforeWrite(); void BeforeWrite();
void GetWidthsAndGids(unsigned short** ppCodeToGid, unsigned int** pWidths, unsigned char** ppGlyphs, unsigned int& unGlyphsCount); bool GetWidthsAndGids(unsigned short** ppCodeToGid, unsigned int** pWidths, unsigned char** ppGlyphs, unsigned int& unGlyphsCount);
void CreateCIDFont2(CDictObject* pFont); void CreateCIDFont2(CDictObject* pFont);
void WriteToUnicode(); void WriteToUnicode();
bool OpenFontFace();
void CloseFontFace();
private: private:
...@@ -61,9 +62,12 @@ namespace PdfWriter ...@@ -61,9 +62,12 @@ namespace PdfWriter
std::vector<unsigned int> m_vWidths; std::vector<unsigned int> m_vWidths;
std::map<unsigned short, bool> m_mGlyphs; std::map<unsigned short, bool> m_mGlyphs;
FT_Library m_pLibrary;
FT_Face m_pFace; FT_Face m_pFace;
FT_Byte* m_pFaceMemory; FT_Byte* m_pFaceMemory;
int m_nGlyphsCount;
int m_nSymbolicCmap;
friend class CDocument;
}; };
} }
......
...@@ -231,6 +231,8 @@ namespace PdfWriter ...@@ -231,6 +231,8 @@ namespace PdfWriter
else else
{ {
double* pValues = new double[(nCount - 1) * 2]; double* pValues = new double[(nCount - 1) * 2];
if (pValues)
{
for (int nIndex = 0; nIndex < nCount - 1; nIndex++) for (int nIndex = 0; nIndex < nCount - 1; nIndex++)
{ {
pValues[2 * nIndex + 0] = pColors[nIndex] / 255.0; pValues[2 * nIndex + 0] = pColors[nIndex] / 255.0;
...@@ -242,6 +244,7 @@ namespace PdfWriter ...@@ -242,6 +244,7 @@ namespace PdfWriter
delete[] pValues; delete[] pValues;
} }
} }
}
void CShading::SetExtend(bool bBegin, bool bEnd) void CShading::SetExtend(bool bBegin, bool bEnd)
{ {
CArrayObject* pExtend = new CArrayObject(); CArrayObject* pExtend = new CArrayObject();
......
...@@ -587,7 +587,7 @@ namespace PdfWriter ...@@ -587,7 +587,7 @@ namespace PdfWriter
unsigned int unRemainBytes = m_nBufferSize - Tell(); unsigned int unRemainBytes = m_nBufferSize - Tell();
if (unRemainBytes < unSize) if (unRemainBytes < unSize)
{ {
unsigned int unShrinkSize = max(unSize, 4096); unsigned int unShrinkSize = max(unSize, STREAM_BUF_SIZ);
Shrink(unShrinkSize); Shrink(unShrinkSize);
} }
MemCpy(m_pCur, pBuffer, unSize); MemCpy(m_pCur, pBuffer, unSize);
......
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