mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-04-07 13:55:33 +08:00
Merge branch 'release/v7.0.0' into develop
This commit is contained in:
@ -27,7 +27,9 @@ ixwebsocket {
|
||||
|
||||
use_zlib {
|
||||
ZLIB_SOURCES = $$PWD/../../../OfficeUtils/src/zlib-1.2.11
|
||||
INCLUDEPATH += $$ZLIB_SOURCES
|
||||
INCLUDEPATH += \
|
||||
$$ZLIB_SOURCES \
|
||||
$$ZLIB_SOURCES/..
|
||||
SOURCES += \
|
||||
$$ZLIB_SOURCES/adler32.c \
|
||||
$$ZLIB_SOURCES/compress.c \
|
||||
@ -43,7 +45,8 @@ use_zlib {
|
||||
$$ZLIB_SOURCES/inftrees.c \
|
||||
$$ZLIB_SOURCES/trees.c \
|
||||
$$ZLIB_SOURCES/uncompr.c \
|
||||
$$ZLIB_SOURCES/zutil.c
|
||||
$$ZLIB_SOURCES/zutil.c \
|
||||
$$ZLIB_SOURCES/../zlib_addon.c
|
||||
}
|
||||
|
||||
socketrocket {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -84,41 +84,158 @@ namespace NSFonts
|
||||
fontUnknown = 3
|
||||
};
|
||||
|
||||
class CFontInfo
|
||||
{
|
||||
public:
|
||||
CFontInfo(const std::wstring& wsFontName,
|
||||
const std::wstring& wsStyle,
|
||||
const std::wstring& wsFontPath,
|
||||
long lIndex,
|
||||
INT bBold,
|
||||
INT bItalic,
|
||||
INT bFixedWidth,
|
||||
BYTE *pPanose,
|
||||
UINT ulRange1,
|
||||
UINT ulRange2,
|
||||
UINT ulRange3,
|
||||
UINT ulRange4,
|
||||
UINT ulCodeRange1,
|
||||
UINT ulCodeRange2,
|
||||
USHORT usWeigth,
|
||||
USHORT usWidth,
|
||||
SHORT sFamilyClass,
|
||||
EFontFormat eFormat,
|
||||
SHORT shAvgCharWidth,
|
||||
SHORT shAscent,
|
||||
SHORT shDescent,
|
||||
SHORT shLineGap,
|
||||
SHORT shXHeight,
|
||||
SHORT shCapHeight,
|
||||
USHORT usType)
|
||||
{
|
||||
m_wsFontName = wsFontName;
|
||||
m_wsFontPath = wsFontPath;
|
||||
m_wsStyle = wsStyle;
|
||||
m_lIndex = lIndex;
|
||||
|
||||
m_bBold = bBold;
|
||||
m_bItalic = bItalic;
|
||||
|
||||
m_bIsFixed = bFixedWidth;
|
||||
|
||||
if ( pPanose )
|
||||
memcpy( (void*)m_aPanose, (const void *)pPanose, 10 );
|
||||
else
|
||||
memset( (void*)m_aPanose, 0x00, 10 );
|
||||
|
||||
m_ulUnicodeRange1 = ulRange1;
|
||||
m_ulUnicodeRange2 = ulRange2;
|
||||
m_ulUnicodeRange3 = ulRange3;
|
||||
m_ulUnicodeRange4 = ulRange4;
|
||||
m_ulCodePageRange1 = ulCodeRange1;
|
||||
m_ulCodePageRange2 = ulCodeRange2;
|
||||
m_usWeigth = usWeigth;
|
||||
m_usWidth = usWidth;
|
||||
|
||||
m_sFamilyClass = sFamilyClass;
|
||||
|
||||
m_eFontFormat = eFormat;
|
||||
|
||||
m_shAvgCharWidth = shAvgCharWidth;
|
||||
m_shAscent = shAscent;
|
||||
m_shDescent = shDescent;
|
||||
m_shLineGap = shLineGap;
|
||||
m_shXHeight = shXHeight;
|
||||
m_shCapHeight = shCapHeight;
|
||||
|
||||
m_usType = usType;
|
||||
}
|
||||
|
||||
~CFontInfo()
|
||||
{
|
||||
}
|
||||
|
||||
int IsEquals(const CFontInfo *pFontInfo)
|
||||
{
|
||||
return (m_wsFontName == pFontInfo->m_wsFontName &&
|
||||
m_wsStyle == pFontInfo->m_wsStyle &&
|
||||
m_wsFontPath == pFontInfo->m_wsFontPath &&
|
||||
m_bItalic == pFontInfo->m_bItalic &&
|
||||
m_bBold == pFontInfo->m_bBold);
|
||||
}
|
||||
|
||||
public:
|
||||
std::wstring m_wsFontName; // Имя шрифта
|
||||
std::wstring m_wsFontPath; // Путь к файлу с шрифтом
|
||||
long m_lIndex; // Номер шрифта в файле(если в файле больше 1 шрифта)
|
||||
std::wstring m_wsStyle;
|
||||
|
||||
INT m_bBold; // Bold text
|
||||
INT m_bItalic; // Italic text
|
||||
INT m_bIsFixed; // Моноширинный шрифт?
|
||||
|
||||
BYTE m_aPanose[10];
|
||||
UINT m_ulUnicodeRange1; // Bits 0-31
|
||||
UINT m_ulUnicodeRange2; // Bits 32-63
|
||||
UINT m_ulUnicodeRange3; // Bits 64-95
|
||||
UINT m_ulUnicodeRange4; // Bits 96-127
|
||||
|
||||
UINT m_ulCodePageRange1; // Bits 0-31
|
||||
UINT m_ulCodePageRange2; // Bits 32-63
|
||||
|
||||
USHORT m_usWeigth;
|
||||
USHORT m_usWidth;
|
||||
|
||||
SHORT m_sFamilyClass;
|
||||
EFontFormat m_eFontFormat;
|
||||
|
||||
SHORT m_shAvgCharWidth; // Средняя ширина символов
|
||||
SHORT m_shAscent; // Ascent
|
||||
SHORT m_shDescent; // Descent
|
||||
SHORT m_shLineGap; // Межсимвольный интервал
|
||||
SHORT m_shXHeight; // Высота буквы 'x' (в нижнем регистре)
|
||||
SHORT m_shCapHeight; // Высота буквы 'H' (в верхнем регистре)
|
||||
|
||||
USHORT m_usType;
|
||||
|
||||
std::vector<std::wstring> names;
|
||||
};
|
||||
|
||||
class CFontSelectFormat
|
||||
{
|
||||
public:
|
||||
std::wstring* wsName;
|
||||
std::wstring* wsAltName;
|
||||
std::wstring* wsName;
|
||||
std::wstring* wsAltName;
|
||||
|
||||
std::wstring* wsFamilyClass;
|
||||
SHORT* sFamilyClass;
|
||||
std::wstring* wsFamilyClass;
|
||||
SHORT* sFamilyClass;
|
||||
|
||||
INT* bBold;
|
||||
INT* bItalic;
|
||||
INT* bBold;
|
||||
INT* bItalic;
|
||||
|
||||
INT* bFixedWidth;
|
||||
INT* bFixedWidth;
|
||||
|
||||
BYTE* pPanose;
|
||||
BYTE* pPanose;
|
||||
|
||||
UINT* ulRange1;
|
||||
UINT* ulRange2;
|
||||
UINT* ulRange3;
|
||||
UINT* ulRange4;
|
||||
UINT* ulCodeRange1;
|
||||
UINT* ulCodeRange2;
|
||||
UINT* ulRange1;
|
||||
UINT* ulRange2;
|
||||
UINT* ulRange3;
|
||||
UINT* ulRange4;
|
||||
UINT* ulCodeRange1;
|
||||
UINT* ulCodeRange2;
|
||||
|
||||
USHORT* usWeight;
|
||||
USHORT* usWidth;
|
||||
USHORT* usWeight;
|
||||
USHORT* usWidth;
|
||||
|
||||
int* nFontFormat;
|
||||
BYTE* unCharset;
|
||||
int* nFontFormat;
|
||||
BYTE* unCharset;
|
||||
|
||||
SHORT* shAvgCharWidth;
|
||||
SHORT* shAscent;
|
||||
SHORT* shDescent;
|
||||
SHORT* shLineGap;
|
||||
SHORT* shXHeight;
|
||||
SHORT* shCapHeight;
|
||||
SHORT* shAvgCharWidth;
|
||||
SHORT* shAscent;
|
||||
SHORT* shDescent;
|
||||
SHORT* shLineGap;
|
||||
SHORT* shXHeight;
|
||||
SHORT* shCapHeight;
|
||||
|
||||
// mask for allowed os2.fsType field
|
||||
// https://docs.microsoft.com/en-us/typography/opentype/spec/os2#fstype
|
||||
@ -282,123 +399,40 @@ namespace NSFonts
|
||||
|
||||
RELEASEOBJECT(usType);
|
||||
}
|
||||
};
|
||||
|
||||
class CFontInfo
|
||||
{
|
||||
public:
|
||||
CFontInfo(const std::wstring& wsFontName,
|
||||
const std::wstring& wsStyle,
|
||||
const std::wstring& wsFontPath,
|
||||
long lIndex,
|
||||
INT bBold,
|
||||
INT bItalic,
|
||||
INT bFixedWidth,
|
||||
BYTE *pPanose,
|
||||
UINT ulRange1,
|
||||
UINT ulRange2,
|
||||
UINT ulRange3,
|
||||
UINT ulRange4,
|
||||
UINT ulCodeRange1,
|
||||
UINT ulCodeRange2,
|
||||
USHORT usWeigth,
|
||||
USHORT usWidth,
|
||||
SHORT sFamilyClass,
|
||||
EFontFormat eFormat,
|
||||
SHORT shAvgCharWidth,
|
||||
SHORT shAscent,
|
||||
SHORT shDescent,
|
||||
SHORT shLineGap,
|
||||
SHORT shXHeight,
|
||||
SHORT shCapHeight,
|
||||
USHORT usType)
|
||||
void Fill(CFontInfo* pFontInfo)
|
||||
{
|
||||
m_wsFontName = wsFontName;
|
||||
m_wsFontPath = wsFontPath;
|
||||
m_wsStyle = wsStyle;
|
||||
m_lIndex = lIndex;
|
||||
Destroy();
|
||||
|
||||
m_bBold = bBold;
|
||||
m_bItalic = bItalic;
|
||||
wsName = new std::wstring(pFontInfo->m_wsFontName);
|
||||
|
||||
m_bIsFixed = bFixedWidth;
|
||||
bItalic = new INT(pFontInfo->m_bItalic ? 1 : 0);
|
||||
bBold = new INT(pFontInfo->m_bBold ? 1 : 0);
|
||||
bFixedWidth = new INT(pFontInfo->m_bIsFixed ? 1 : 0);
|
||||
|
||||
if ( pPanose )
|
||||
memcpy( (void*)m_aPanose, (const void *)pPanose, 10 );
|
||||
else
|
||||
memset( (void*)m_aPanose, 0x00, 10 );
|
||||
pPanose = new BYTE[10];
|
||||
memcpy((void*)pPanose, pFontInfo->m_aPanose, 10);
|
||||
|
||||
m_ulUnicodeRange1 = ulRange1;
|
||||
m_ulUnicodeRange2 = ulRange2;
|
||||
m_ulUnicodeRange3 = ulRange3;
|
||||
m_ulUnicodeRange4 = ulRange4;
|
||||
m_ulCodePageRange1 = ulCodeRange1;
|
||||
m_ulCodePageRange2 = ulCodeRange2;
|
||||
m_usWeigth = usWeigth;
|
||||
m_usWidth = usWidth;
|
||||
ulRange1 = new UINT(pFontInfo->m_ulUnicodeRange1);
|
||||
ulRange2 = new UINT(pFontInfo->m_ulUnicodeRange2);
|
||||
ulRange3 = new UINT(pFontInfo->m_ulUnicodeRange3);
|
||||
ulRange4 = new UINT(pFontInfo->m_ulUnicodeRange4);
|
||||
|
||||
m_sFamilyClass = sFamilyClass;
|
||||
ulCodeRange1 = new UINT(pFontInfo->m_ulCodePageRange1);
|
||||
ulCodeRange2 = new UINT(pFontInfo->m_ulCodePageRange2);
|
||||
|
||||
m_eFontFormat = eFormat;
|
||||
usWeight = new USHORT(pFontInfo->m_usWeigth);
|
||||
usWidth = new USHORT(pFontInfo->m_usWidth);
|
||||
|
||||
m_shAvgCharWidth = shAvgCharWidth;
|
||||
m_shAscent = shAscent;
|
||||
m_shDescent = shDescent;
|
||||
m_shLineGap = shLineGap;
|
||||
m_shXHeight = shXHeight;
|
||||
m_shCapHeight = shCapHeight;
|
||||
shAvgCharWidth = new SHORT(pFontInfo->m_shAvgCharWidth);
|
||||
shAscent = new SHORT(pFontInfo->m_shAscent);
|
||||
shDescent = new SHORT(pFontInfo->m_shDescent);
|
||||
shLineGap = new SHORT(pFontInfo->m_shLineGap);
|
||||
shXHeight = new SHORT(pFontInfo->m_shXHeight);
|
||||
shCapHeight = new SHORT(pFontInfo->m_shCapHeight);
|
||||
|
||||
m_usType = usType;
|
||||
usType = new USHORT(pFontInfo->m_usType);
|
||||
}
|
||||
|
||||
~CFontInfo()
|
||||
{
|
||||
}
|
||||
|
||||
int IsEquals(const CFontInfo *pFontInfo)
|
||||
{
|
||||
return (m_wsFontName == pFontInfo->m_wsFontName &&
|
||||
m_wsStyle == pFontInfo->m_wsStyle &&
|
||||
m_wsFontPath == pFontInfo->m_wsFontPath &&
|
||||
m_bItalic == pFontInfo->m_bItalic &&
|
||||
m_bBold == pFontInfo->m_bBold);
|
||||
}
|
||||
|
||||
public:
|
||||
std::wstring m_wsFontName; // Имя шрифта
|
||||
std::wstring m_wsFontPath; // Путь к файлу с шрифтом
|
||||
long m_lIndex; // Номер шрифта в файле(если в файле больше 1 шрифта)
|
||||
std::wstring m_wsStyle;
|
||||
|
||||
INT m_bBold; // Bold text
|
||||
INT m_bItalic; // Italic text
|
||||
INT m_bIsFixed; // Моноширинный шрифт?
|
||||
|
||||
BYTE m_aPanose[10];
|
||||
UINT m_ulUnicodeRange1; // Bits 0-31
|
||||
UINT m_ulUnicodeRange2; // Bits 32-63
|
||||
UINT m_ulUnicodeRange3; // Bits 64-95
|
||||
UINT m_ulUnicodeRange4; // Bits 96-127
|
||||
|
||||
UINT m_ulCodePageRange1; // Bits 0-31
|
||||
UINT m_ulCodePageRange2; // Bits 32-63
|
||||
|
||||
USHORT m_usWeigth;
|
||||
USHORT m_usWidth;
|
||||
|
||||
SHORT m_sFamilyClass;
|
||||
EFontFormat m_eFontFormat;
|
||||
|
||||
SHORT m_shAvgCharWidth; // Средняя ширина символов
|
||||
SHORT m_shAscent; // Ascent
|
||||
SHORT m_shDescent; // Descent
|
||||
SHORT m_shLineGap; // Межсимвольный интервал
|
||||
SHORT m_shXHeight; // Высота буквы 'x' (в нижнем регистре)
|
||||
SHORT m_shCapHeight; // Высота буквы 'H' (в верхнем регистре)
|
||||
|
||||
USHORT m_usType;
|
||||
|
||||
std::vector<std::wstring> names;
|
||||
};
|
||||
|
||||
class CFontListToBufferSerializer
|
||||
@ -433,10 +467,10 @@ namespace NSFonts
|
||||
class GRAPHICS_DECL ISimpleGraphicsPath
|
||||
{
|
||||
public:
|
||||
virtual bool _MoveTo(double x, double y) = 0;
|
||||
virtual bool _LineTo(double x, double y) = 0;
|
||||
virtual bool _CurveTo(double x1, double y1, double x2, double y2, double x3, double y3) = 0;
|
||||
virtual bool _Close() = 0;
|
||||
virtual bool _MoveTo(double x, double y) = 0;
|
||||
virtual bool _LineTo(double x, double y) = 0;
|
||||
virtual bool _CurveTo(double x1, double y1, double x2, double y2, double x3, double y3) = 0;
|
||||
virtual bool _Close() = 0;
|
||||
};
|
||||
|
||||
class GRAPHICS_DECL IFontPath : public NSBase::CBaseRefCounter
|
||||
@ -649,7 +683,7 @@ namespace NSFonts
|
||||
virtual ~IFontList();
|
||||
|
||||
public:
|
||||
virtual std::vector<NSFonts::CFontInfo*>* GetFonts() = 0;
|
||||
virtual std::vector<NSFonts::CFontInfo*>* GetFonts() = 0;
|
||||
virtual CFontInfo* GetByParams(CFontSelectFormat& oSelect, bool bIsDictionaryUse = true) = 0;
|
||||
virtual void ToBuffer(BYTE** pDstData, LONG* pLen, CFontListToBufferSerializer& oSerializer) = 0;
|
||||
};
|
||||
@ -684,8 +718,8 @@ namespace NSFonts
|
||||
|
||||
virtual std::wstring GetFontBySymbol(int symbol) = 0;
|
||||
};
|
||||
|
||||
namespace NSApplication
|
||||
|
||||
namespace NSApplication
|
||||
{
|
||||
GRAPHICS_DECL IApplicationFonts* Create();
|
||||
}
|
||||
|
||||
@ -2247,6 +2247,14 @@ void CPdfRenderer::GetFontPath(const std::wstring &wsFontName, const bool &bBold
|
||||
oFontSelect.bItalic = new INT(bItalic ? 1 : 0);
|
||||
oFontSelect.bBold = new INT(bBold ? 1 : 0);
|
||||
NSFonts::CFontInfo* pFontInfo = m_pFontManager->GetFontInfoByParams(oFontSelect, false);
|
||||
if (pFontInfo->m_usType & FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING)
|
||||
{
|
||||
oFontSelect.Fill(pFontInfo);
|
||||
if (NULL != oFontSelect.usType)
|
||||
*oFontSelect.usType = (~FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING);
|
||||
|
||||
pFontInfo = m_pFontManager->GetFontInfoByParams(oFontSelect, false);
|
||||
}
|
||||
|
||||
wsFontPath = pFontInfo->m_wsFontPath;
|
||||
lFaceIndex = pFontInfo->m_lIndex;
|
||||
|
||||
@ -49,7 +49,7 @@ namespace PdfWriter
|
||||
//----------------------------------------------------------------------------------------
|
||||
// CFontTrueType
|
||||
//----------------------------------------------------------------------------------------
|
||||
CFontTrueType::CFontTrueType(CXref* pXref, CDocument* pDocument, const std::wstring& wsFontPath, unsigned int unIndex) : CFontDict(pXref, pDocument)
|
||||
CFontTrueType::CFontTrueType(CXref* pXref, CDocument* pDocument, const std::wstring& wsFontPath, unsigned int unIndex) : CFontDict(pXref, pDocument), m_bCanEmbed(false)
|
||||
{
|
||||
CFontFileTrueType* pFontTT = CFontFileTrueType::LoadFromFile(wsFontPath, unIndex);
|
||||
m_pFontFile = pFontTT;
|
||||
@ -69,21 +69,34 @@ namespace PdfWriter
|
||||
pFontDescriptor->Add("Type", "FontDescriptor");
|
||||
m_pFontDescriptor = pFontDescriptor;
|
||||
|
||||
// Выставляем бит Symbolic, а бит NonSymbolic убираем
|
||||
unsigned int nFlags = 0;
|
||||
if (!(nFlags & 4))
|
||||
UIntChangeBit(nFlags, 2);
|
||||
if (nFlags & 32)
|
||||
UIntChangeBit(nFlags, 5);
|
||||
|
||||
pFontDescriptor->Add("Flags", nFlags);
|
||||
|
||||
m_pFontFileDict = new CDictObject(m_pXref);
|
||||
pFontDescriptor->Add("FontFile2", m_pFontFileDict);
|
||||
|
||||
Add("FontDescriptor", pFontDescriptor);
|
||||
|
||||
ReadName();
|
||||
|
||||
if (m_bCanEmbed)
|
||||
{
|
||||
// Выставляем бит Symbolic, а бит NonSymbolic убираем
|
||||
unsigned int nFlags = 0;
|
||||
if (!(nFlags & 4))
|
||||
UIntChangeBit(nFlags, 2);
|
||||
if (nFlags & 32)
|
||||
UIntChangeBit(nFlags, 5);
|
||||
|
||||
pFontDescriptor->Add("Flags", nFlags);
|
||||
|
||||
m_pFontFileDict = new CDictObject(m_pXref);
|
||||
pFontDescriptor->Add("FontFile2", m_pFontFileDict);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Ставим флаг NonSymbolic, т.к. Adobe плохо подбирает шрифт с Symbolic флагом
|
||||
// TODO: Хорошо бы сделать проверку, стоит ли ставить флаг Symbolic
|
||||
unsigned int nFlags = 0;
|
||||
UIntChangeBit(nFlags, 5);
|
||||
pFontDescriptor->Add("Flags", nFlags);
|
||||
m_pFontFileDict = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
CFontTrueType::~CFontTrueType()
|
||||
{
|
||||
@ -92,7 +105,7 @@ namespace PdfWriter
|
||||
}
|
||||
void CFontTrueType::BeforeWrite()
|
||||
{
|
||||
if (m_pFontFile)
|
||||
if (m_pFontFile && m_pFontFileDict)
|
||||
{
|
||||
CStream* pStream = m_pFontFileDict->GetStream();
|
||||
m_pFontFile->WriteTTF(pStream);
|
||||
@ -177,6 +190,11 @@ namespace PdfWriter
|
||||
m_pFontDescriptor->Add("StemV", 80);
|
||||
m_pFontDescriptor->Add("FontWeight", m_pFontFile->GetWeight());
|
||||
|
||||
// Сейчас мы этот класс используем для внедрения шрифтов, которые будут использоваться для заполнения
|
||||
// внутри форм. Если класс будет использоваться для чего-то другого, тогда надо задавать ограничения на внедрение
|
||||
FT_UShort fsType = FT_Get_FSType_Flags(pFace);
|
||||
m_bCanEmbed = !(fsType & FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING) && !(fsType & FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING);
|
||||
|
||||
FT_Done_Face(pFace);
|
||||
RELEASEARRAYOBJECTS(pFaceMemory);
|
||||
}
|
||||
|
||||
@ -88,6 +88,7 @@ namespace PdfWriter
|
||||
CDictObject* m_pFontDescriptor;
|
||||
int m_nLineHeight;
|
||||
int m_nAscent;
|
||||
bool m_bCanEmbed;
|
||||
|
||||
|
||||
friend class CDocument;
|
||||
|
||||
Reference in New Issue
Block a user