Compare commits

..

19 Commits

Author SHA1 Message Date
ef6af5a1ae Merge branch hotfix/v5.6.1 into master 2020-08-05 09:19:35 +00:00
6e5fe1202e Merge pull request #278 from ONLYOFFICE/fix/fixXP
Fix xp build
2020-08-03 12:00:48 +03:00
0005b20095 Fix xp build 2020-08-03 11:29:19 +03:00
82cdd75365 Merge branch hotfix/v5.6.0 into master 2020-07-28 13:31:16 +00:00
3410e157e0 Merge pull request #272 from ONLYOFFICE/feature/fixIOSBoost
Fix ios build
2020-07-21 16:02:46 +03:00
92d0edeb48 Fix ios build 2020-07-21 15:55:55 +03:00
ce397b13f6 Fix bug with redirects in downloads 2020-07-10 16:31:37 +03:00
d197c0da15 . 2020-07-06 16:55:04 +03:00
0e7a8c1af9 Fix rpath instead runpath 2020-07-06 16:14:41 +03:00
a52bcb3205 Fix previous commit 2020-07-06 14:05:06 +03:00
b57bf58068 Use std::vector in CArray realization. Deprecated class! 2020-07-06 13:50:43 +03:00
7be6410a13 Fix fonts selection 2020-07-03 11:25:24 +03:00
1ef73f12a4 Change font selection algorithm 2020-07-01 13:03:19 +03:00
9706ca50d5 Fix bug #39097
Implement color mask for images
2020-07-01 10:52:39 +03:00
7fba804f17 Fix bug #19078
Fix the problem with reading CID to GID map for CIDType2 fonts
2020-07-01 10:52:32 +03:00
d4f9eecbba Fix bug #45319 2020-07-01 10:52:23 +03:00
245dfe198a Fix bug 45336 2020-06-29 11:55:04 +03:00
d49bed47b6 Fix bug 31323 2020-06-23 11:15:50 +03:00
b95065fd70 Openssl build for windows xp 2020-06-16 15:28:10 +03:00
20 changed files with 398 additions and 153 deletions

View File

@ -5,8 +5,8 @@
# iOS simulator.
#
# To configure the script, define:
# BOOST_VERSION: Which version of Boost to build (e.g. 1.58.0)
# BOOST_VERSION2: Same as BOOST_VERSION, but with _ instead of . (e.g. 1_58_0)
# BOOST_VERSION: Which version of Boost to build (e.g. 1.72.0)
# BOOST_VERSION2: Same as BOOST_VERSION, but with _ instead of . (e.g. 1_72_0)
# BOOST_LIBS: Which Boost libraries to build
# MIN_IOS_VERSION: Minimum iOS Target Version (e.g. 8.0)
# IOS_SDK_VERSION: iOS SDK version (e.g. 9.0)
@ -24,8 +24,8 @@ BOOST_LIBS="regex"
BUILD_IOS=
CLEAN=
BOOST_VERSION=1.58.0
BOOST_VERSION2=1_58_0
BOOST_VERSION=1.72.0
BOOST_VERSION2=1_72_0
MIN_IOS_VERSION=8.0
IOS_SDK_VERSION=`xcodebuild BITCODE_GENERATION_MODE="bitcode" ENABLE_BITCODE="YES" OTHER_CFLAGS="-fembed-bitcode" -showsdks | grep iphoneos | \
egrep "[[:digit:]]+\.[[:digit:]]+" -o | tail -1`

View File

@ -1,7 +1,10 @@
INCLUDEPATH += $$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/include
OPEN_SSL_PLATFORM=$$CORE_BUILDS_PLATFORM_PREFIX
build_xp:OPEN_SSL_PLATFORM=$$join(OPEN_SSL_PLATFORM, OPEN_SSL_PLATFORM, "", "_xp")
core_windows:LIBS += -L$$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/lib -llibcrypto -llibssl
!core_windows:LIBS += -L$$PWD/build/$$CORE_BUILDS_PLATFORM_PREFIX/lib -lcrypto -lssl
INCLUDEPATH += $$PWD/build/$$OPEN_SSL_PLATFORM/include
core_windows:LIBS += -L$$PWD/build/$$OPEN_SSL_PLATFORM/lib -llibcrypto -llibssl
!core_windows:LIBS += -L$$PWD/build/$$OPEN_SSL_PLATFORM/lib -lcrypto -lssl
open_ssl_common {
DEFINES += COMMON_OPENSSL_BUILDING

View File

@ -80,14 +80,15 @@ int download_external(const std::wstring& sUrl, const std::wstring& sOutput)
case 0: // child process
{
const char* nargs[7];
const char* nargs[8];
nargs[0] = "/usr/bin/curl";
nargs[1] = "--url";
nargs[2] = sUrlA.c_str();
nargs[3] = "--output";
nargs[4] = sOutputA.c_str();
nargs[5] = "--silent";
nargs[6] = NULL;
nargs[6] = "-L";
nargs[7] = NULL;
const char* nenv[3];
nenv[0] = "LD_PRELOAD=";

View File

@ -6,7 +6,7 @@ BUILD_NUMBER = $$(BUILD_NUMBER)
!isEmpty(PRODUCT_VERSION){
!isEmpty(BUILD_NUMBER){
VERSION = $${PRODUCT_VERSION}.$${BUILD_NUMBER}
}
}
}
DEFINES += INTVER=$$VERSION
@ -67,6 +67,8 @@ isEqual(QT_MAJOR_VERSION, 5) {
}
}
DEFINES += INTERNAL_USE_ARRAY_AS_VECTOR
ios {
CONFIG += core_ios
DEFINES += _IOS IOS LINUX _LINUX MAC _MAC _XCODE
@ -158,7 +160,9 @@ core_windows {
core_linux {
equals(TEMPLATE, app) {
QMAKE_LFLAGS += -Wl,--rpath=./:./system
QMAKE_LFLAGS += "-Wl,-rpath,\'\$$ORIGIN\'"
QMAKE_LFLAGS += "-Wl,-rpath,\'\$$ORIGIN/system\'"
QMAKE_LFLAGS += -Wl,--disable-new-dtags
}
}
@ -373,6 +377,7 @@ defineTest(ADD_DEPENDENCY) {
isEqual(lib, doctrenderer):CORE_BUILDS_LIBRARIES_PATH_DST=$$CORE_BUILDS_LIBRARIES_PATH/xp
isEqual(lib, ascdocumentscore):CORE_BUILDS_LIBRARIES_PATH_DST=$$CORE_BUILDS_LIBRARIES_PATH/xp
isEqual(lib, videoplayer):CORE_BUILDS_LIBRARIES_PATH_DST=$$CORE_BUILDS_LIBRARIES_PATH/xp
isEqual(lib, ooxmlsignature):CORE_BUILDS_LIBRARIES_PATH_DST=$$CORE_BUILDS_LIBRARIES_PATH/xp
}
!bundle_dylibs:LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH_DST -l$$lib
bundle_dylibs:LIBS += -F$$CORE_BUILDS_LIBRARIES_PATH_DST -framework $$lib

View File

@ -35,7 +35,9 @@
#include "Types.h"
#include <string.h>
#if 0 //__APPLE__
#ifdef INTERNAL_USE_ARRAY_AS_VECTOR
// Use std::vector instead this class
#include <vector>
@ -87,7 +89,7 @@ public:
for (int i = 0; i < nAllocSize; i++)
Add();
return TRUE;
}
@ -137,6 +139,11 @@ public:
}
return m_aT[nIndex];
}
T* GetData()
{
return m_aT.data();
}
private:

View File

@ -778,7 +778,7 @@ int CFontList::GetFixedPitchPenalty(INT bCandFixed, INT bReqFixed)
}
CFontListNamePicker CFontList::m_oPicker;
int CFontList::GetFaceNamePenalty(std::wstring sCandName, std::wstring sReqName, bool bIsUseNamePicker)
int CFontList::GetFaceNamePenalty(const std::wstring& sCandName, const std::wstring& sReqName, bool bIsUseNamePicker)
{
if ( 0 == sReqName.length() )
return 0;
@ -789,6 +789,9 @@ int CFontList::GetFaceNamePenalty(std::wstring sCandName, std::wstring sReqName,
if ( sReqName == sCandName )
return 0;
if (CFontListNamePicker::IsEqualsFontsAdvanced(sCandName, sReqName))
return 100;
if ( std::wstring::npos != sReqName.find( sCandName ) || std::wstring::npos != sCandName.find( sReqName ) )
{
if (m_oPicker.IsLikeFonts(sCandName, sReqName))
@ -1010,6 +1013,93 @@ void CFontList::ToBuffer(BYTE** pDstData, LONG* pLen, std::wstring strDirectory,
*pLen = (LONG)(pDataMem - pData);
}
class CFontSelectFormatCorrection
{
private:
std::wstring* m_oldName;
INT* m_oldBold;
INT* m_oldItalic;
public:
CFontSelectFormatCorrection()
{
m_oldName = NULL;
m_oldBold = NULL;
m_oldItalic = NULL;
}
static CFontSelectFormatCorrection* CheckCorrection(NSFonts::CFontSelectFormat& oSelect)
{
// пробуем "подправить" настройки
std::wstring sName = *oSelect.wsName;
NSFonts::makeLower(sName);
INT* oldBold = NULL;
INT* oldItalic = NULL;
bool isCorrect = false;
if (std::wstring::npos != sName.find(L"bold"))
{
isCorrect = true;
size_t posn = 0;
while (std::wstring::npos != (posn = sName.find(L"bold", posn)))
sName.erase(posn, 4);
oldBold = oSelect.bBold;
if (!oSelect.bBold)
oSelect.bBold = new INT(TRUE);
}
if (std::wstring::npos != sName.find(L"italic") ||
std::wstring::npos != sName.find(L"oblique"))
{
isCorrect = true;
size_t posn = 0;
while (std::wstring::npos != (posn = sName.find(L"italic", posn)))
sName.erase(posn, 6);
while (std::wstring::npos != (posn = sName.find(L"oblique", posn)))
sName.erase(posn, 7);
oldItalic = oSelect.bItalic;
if (!oSelect.bItalic)
oSelect.bItalic = new INT(TRUE);
}
if (!isCorrect)
return NULL;
CFontSelectFormatCorrection* pCorrection = new CFontSelectFormatCorrection();
pCorrection->m_oldName = oSelect.wsName;
oSelect.wsName = new std::wstring(sName);
pCorrection->m_oldBold = oldBold;
pCorrection->m_oldItalic = oldItalic;
return pCorrection;
}
void Restore(NSFonts::CFontSelectFormat& oSelect)
{
RELEASEOBJECT((oSelect.wsName));
oSelect.wsName = m_oldName;
if (m_oldBold != oSelect.bBold)
{
RELEASEOBJECT((oSelect.bBold));
oSelect.bBold = m_oldBold;
}
if (m_oldItalic != oSelect.bItalic)
{
RELEASEOBJECT((oSelect.bItalic));
oSelect.bItalic = m_oldItalic;
}
m_oldName = NULL;
m_oldBold = NULL;
m_oldItalic = NULL;
}
};
NSFonts::CFontInfo* CFontList::GetByParams(NSFonts::CFontSelectFormat& oSelect, bool bIsDictionaryUse)
{
int nFontsCount = m_pList.size();
@ -1026,104 +1116,127 @@ NSFonts::CFontInfo* CFontList::GetByParams(NSFonts::CFontSelectFormat& oSelect,
int nMinPenalty = -1; // Минимальный вес
int nDefPenalty = 2147483647;
NSFonts::CFontInfo* pInfoMin = NULL;
for (std::vector<NSFonts::CFontInfo*>::iterator iter = m_pList.begin(); iter != m_pList.end(); iter++)
{
int nCurPenalty = 0;
NSFonts::CFontInfo* pInfo = *iter;
CFontSelectFormatCorrection* pSelectCorrection = NULL;
if ( NULL != oSelect.pPanose )
{
nCurPenalty += GetPanosePenalty( pInfo->m_aPanose, oSelect.pPanose );
}
while (true)
{
for (std::vector<NSFonts::CFontInfo*>::iterator iter = m_pList.begin(); iter != m_pList.end(); iter++)
{
int nCurPenalty = 0;
NSFonts::CFontInfo* pInfo = *iter;
ULONG arrCandRanges[6] = { pInfo->m_ulUnicodeRange1, pInfo->m_ulUnicodeRange2, pInfo->m_ulUnicodeRange3, pInfo->m_ulUnicodeRange4, pInfo->m_ulCodePageRange1, pInfo->m_ulCodePageRange2 };
if (true)
{
if (NULL != oSelect.ulRange1 &&
NULL != oSelect.ulRange2 &&
NULL != oSelect.ulRange3 &&
NULL != oSelect.ulRange4 &&
NULL != oSelect.ulCodeRange1 &&
NULL != oSelect.ulCodeRange2)
{
ULONG arrReqRanges[6] = { *oSelect.ulRange1, *oSelect.ulRange2, *oSelect.ulRange3, *oSelect.ulRange4, *oSelect.ulCodeRange1, *oSelect.ulCodeRange2 };
nCurPenalty += GetSigPenalty( arrCandRanges, arrReqRanges, nCurPenalty >= 1000 ? 50 : 10, 10 );
}
}
if ( NULL != oSelect.pPanose )
{
nCurPenalty += GetPanosePenalty( pInfo->m_aPanose, oSelect.pPanose );
}
unsigned char unCharset = UNKNOWN_CHARSET;
if (NULL != oSelect.unCharset)
unCharset = *oSelect.unCharset;
ULONG arrCandRanges[6] = { pInfo->m_ulUnicodeRange1, pInfo->m_ulUnicodeRange2, pInfo->m_ulUnicodeRange3, pInfo->m_ulUnicodeRange4, pInfo->m_ulCodePageRange1, pInfo->m_ulCodePageRange2 };
if ( NULL != oSelect.bFixedWidth )
nCurPenalty += GetFixedPitchPenalty( pInfo->m_bIsFixed, *oSelect.bFixedWidth );
if (true)
{
if (NULL != oSelect.ulRange1 &&
NULL != oSelect.ulRange2 &&
NULL != oSelect.ulRange3 &&
NULL != oSelect.ulRange4 &&
NULL != oSelect.ulCodeRange1 &&
NULL != oSelect.ulCodeRange2)
{
ULONG arrReqRanges[6] = { *oSelect.ulRange1, *oSelect.ulRange2, *oSelect.ulRange3, *oSelect.ulRange4, *oSelect.ulCodeRange1, *oSelect.ulCodeRange2 };
nCurPenalty += GetSigPenalty( arrCandRanges, arrReqRanges, nCurPenalty >= 1000 ? 50 : 10, 10 );
}
}
if ( oSelect.wsName != NULL && oSelect.wsAltName != NULL )
{
nCurPenalty += min( GetFaceNamePenalty( pInfo->m_wsFontName, *oSelect.wsName, true ),
GetFaceNamePenalty( pInfo->m_wsFontName, *oSelect.wsAltName, true ) );
}
else if ( oSelect.wsName != NULL )
nCurPenalty += GetFaceNamePenalty( pInfo->m_wsFontName, *oSelect.wsName, true );
else if ( oSelect.wsAltName != NULL )
nCurPenalty += GetFaceNamePenalty( pInfo->m_wsFontName, *oSelect.wsAltName, true );
unsigned char unCharset = UNKNOWN_CHARSET;
if (NULL != oSelect.unCharset)
unCharset = *oSelect.unCharset;
if ( NULL != oSelect.usWidth )
nCurPenalty += GetWidthPenalty( pInfo->m_usWidth, *oSelect.usWidth );
if ( NULL != oSelect.bFixedWidth )
nCurPenalty += GetFixedPitchPenalty( pInfo->m_bIsFixed, *oSelect.bFixedWidth );
if ( NULL != oSelect.usWeight )
nCurPenalty += GetWeightPenalty( pInfo->m_usWeigth, *oSelect.usWeight );
if ( oSelect.wsName != NULL && oSelect.wsAltName != NULL )
{
nCurPenalty += min( GetFaceNamePenalty( pInfo->m_wsFontName, *oSelect.wsName, true ),
GetFaceNamePenalty( pInfo->m_wsFontName, *oSelect.wsAltName, true ) );
}
else if ( oSelect.wsName != NULL )
nCurPenalty += GetFaceNamePenalty( pInfo->m_wsFontName, *oSelect.wsName, true );
else if ( oSelect.wsAltName != NULL )
nCurPenalty += GetFaceNamePenalty( pInfo->m_wsFontName, *oSelect.wsAltName, true );
if ( NULL != oSelect.bBold )
nCurPenalty += GetBoldPenalty( pInfo->m_bBold, *oSelect.bBold );
if ( NULL != oSelect.usWidth )
nCurPenalty += GetWidthPenalty( pInfo->m_usWidth, *oSelect.usWidth );
if ( NULL != oSelect.bItalic )
nCurPenalty += GetItalicPenalty( pInfo->m_bItalic, *oSelect.bItalic );
if ( NULL != oSelect.usWeight )
nCurPenalty += GetWeightPenalty( pInfo->m_usWeigth, *oSelect.usWeight );
if ( NULL != oSelect.wsFamilyClass )
nCurPenalty += GetFamilyUnlikelyPenalty( pInfo->m_sFamilyClass, *oSelect.wsFamilyClass );
else if (NULL != oSelect.sFamilyClass)
nCurPenalty += GetFamilyUnlikelyPenalty( pInfo->m_sFamilyClass, *oSelect.sFamilyClass );
//nCurPenalty += GetFontFormatPenalty( pInfo->m_eFontFormat, fontTrueType );
nCurPenalty += GetCharsetPenalty( arrCandRanges, unCharset );
//if ( NULL != oSelect.bBold )
// nCurPenalty += GetBoldPenalty( pInfo->m_bBold, *oSelect.bBold );
//if ( NULL != oSelect.bItalic )
// nCurPenalty += GetItalicPenalty( pInfo->m_bItalic, *oSelect.bItalic );
if ( NULL != oSelect.shAvgCharWidth )
nCurPenalty += GetAvgWidthPenalty( pInfo->m_shAvgCharWidth, *oSelect.shAvgCharWidth );
// проверяем всегда!!! иначе только по имени может подобраться болд, и появляется зависимость от порядка шрифтов
nCurPenalty += GetBoldPenalty( pInfo->m_bBold, (NULL != oSelect.bBold) ? *oSelect.bBold : FALSE );
nCurPenalty += GetItalicPenalty( pInfo->m_bItalic, (NULL != oSelect.bItalic) ? *oSelect.bItalic : FALSE );
if ( NULL != oSelect.shAscent )
nCurPenalty += GetAscentPenalty( pInfo->m_shAscent, *oSelect.shAscent );
if ( NULL != oSelect.wsFamilyClass )
nCurPenalty += GetFamilyUnlikelyPenalty( pInfo->m_sFamilyClass, *oSelect.wsFamilyClass );
else if (NULL != oSelect.sFamilyClass)
nCurPenalty += GetFamilyUnlikelyPenalty( pInfo->m_sFamilyClass, *oSelect.sFamilyClass );
if ( NULL != oSelect.shDescent )
nCurPenalty += GetDescentPenalty( pInfo->m_shDescent, *oSelect.shDescent );
//nCurPenalty += GetFontFormatPenalty( pInfo->m_eFontFormat, fontTrueType );
nCurPenalty += GetCharsetPenalty( arrCandRanges, unCharset );
if ( NULL != oSelect.shLineGap )
nCurPenalty += GetLineGapPenalty( pInfo->m_shLineGap, *oSelect.shLineGap );
if ( NULL != oSelect.shAvgCharWidth )
nCurPenalty += GetAvgWidthPenalty( pInfo->m_shAvgCharWidth, *oSelect.shAvgCharWidth );
if ( NULL != oSelect.shXHeight )
nCurPenalty += GetXHeightPenalty( pInfo->m_shXHeight, *oSelect.shXHeight );
if ( NULL != oSelect.shAscent )
nCurPenalty += GetAscentPenalty( pInfo->m_shAscent, *oSelect.shAscent );
if ( NULL != oSelect.shCapHeight )
nCurPenalty += GetCapHeightPenalty( pInfo->m_shCapHeight, *oSelect.shCapHeight );
if ( NULL != oSelect.shDescent )
nCurPenalty += GetDescentPenalty( pInfo->m_shDescent, *oSelect.shDescent );
if ( nMinPenalty < 0 )
{
pInfoMin = pInfo;
nMinPenalty = nCurPenalty;
}
else if ( nCurPenalty < nMinPenalty )
{
pInfoMin = pInfo;
nMinPenalty = nCurPenalty;
}
if ( NULL != oSelect.shLineGap )
nCurPenalty += GetLineGapPenalty( pInfo->m_shLineGap, *oSelect.shLineGap );
// Нашелся шрифт, удовлетворяющий всем параметрам, дальше искать нет смысла
if ( 0 == nCurPenalty )
break;
}
if ( NULL != oSelect.shXHeight )
nCurPenalty += GetXHeightPenalty( pInfo->m_shXHeight, *oSelect.shXHeight );
if ( NULL != oSelect.shCapHeight )
nCurPenalty += GetCapHeightPenalty( pInfo->m_shCapHeight, *oSelect.shCapHeight );
if ( nMinPenalty < 0 )
{
pInfoMin = pInfo;
nMinPenalty = nCurPenalty;
}
else if ( nCurPenalty < nMinPenalty )
{
pInfoMin = pInfo;
nMinPenalty = nCurPenalty;
}
// Нашелся шрифт, удовлетворяющий всем параметрам, дальше искать нет смысла
if ( 0 == nCurPenalty )
break;
}
if (0 == nMinPenalty)
break;
if (NULL == oSelect.wsName || pSelectCorrection)
break;
pSelectCorrection = CFontSelectFormatCorrection::CheckCorrection(oSelect);
if (NULL == pSelectCorrection)
break;
}
if (pSelectCorrection)
{
pSelectCorrection->Restore(oSelect);
RELEASEOBJECT(pSelectCorrection);
}
return pInfoMin;
}

View File

@ -186,6 +186,17 @@ public:
return 1500;
}
return IsEqualsFontsAdvanced(name, req) ? 3000 : 10000;
}
static bool IsEqualsFontsAdvanced(const std::wstring& name, const std::wstring& req)
{
int lenName = (int)name.length();
int lenReq = (int)req.length();
const wchar_t* pName = name.c_str();
const wchar_t* pReq = req.c_str();
pName = name.c_str();
pReq = req.c_str();
@ -232,7 +243,7 @@ public:
delete [] pNameD;
delete [] pReqD;
return bIsEq ? 3000 : 10000;
return bIsEq;
}
};
@ -273,7 +284,7 @@ private:
int GetCharsetPenalty(ULONG ulCandRanges[6], unsigned char unReqCharset);
int GetSigPenalty(ULONG ulCandRanges[6], ULONG ulReqRanges[6], double dRangeWeight = 1, double dRangeWeightSuferflouous = 0);
int GetFixedPitchPenalty(INT bCandFixed, INT bReqFixed);
int GetFaceNamePenalty(std::wstring sCandName, std::wstring sReqName, bool bIsUseNamePicker = false);
int GetFaceNamePenalty(const std::wstring& sCandName, const std::wstring& sReqName, bool bIsUseNamePicker = false);
int GetFamilyUnlikelyPenalty(SHORT nCandFamilyClass, SHORT nReqFamilyClass);
int GetFamilyUnlikelyPenalty(int nCandFamilyClass, std::wstring sReqFamilyClass);
int GetWidthPenalty(USHORT usCandWidth, USHORT usReqWidth);

View File

@ -679,7 +679,7 @@ HRESULT CGraphicsRenderer::CommandDrawTextExCHAR(const LONG& c, const LONG& gid,
HRESULT CGraphicsRenderer::CommandDrawTextEx(const std::wstring& bsUnicodeText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h)
{
if (NULL != pGids)
if (NULL != pGids && 0 != nGidsCount && !(1 == nGidsCount && 0 == *pGids))
{
m_oFont.StringGID = TRUE;
if (c_nHyperlinkType == m_lCurrentCommandType)

View File

@ -60,3 +60,4 @@ SOURCES += \
CONFIG += open_ssl_common
include(../../../Common/3dParty/openssl/openssl.pri)
build_xp:DESTDIR=$$DESTDIR/xp

View File

@ -49,6 +49,73 @@
#include <unistd.h>
#include <sys/wait.h>
#include <stdio.h>
extern char** environ;
char** linux_environ_get(const std::string& str_library_path = "")
{
int count = 0;
for (int i = 0; environ[i] != NULL; i++)
++count;
count += 2;
char** env = new char*[count];
for (int i = 0; i < count; i++)
env[i] = NULL;
bool is_ld_library_path = false;
for (int i = 0; environ[i] != NULL; i++)
{
std::string s = environ[i];
if (0 == s.find("LD_LIBRARY_PATH"))
{
s += (":" + str_library_path);
is_ld_library_path = true;
}
env[i] = new char[s.length() + 1];
memcpy(env[i], s.c_str(), s.length() * sizeof(char));
env[i][s.length()] = '\0';
}
if (!is_ld_library_path)
{
int index = count - 2;
std::string s = "LD_LIBRARY_PATH=";
s += str_library_path;
env[index] = new char[s.length() + 1];
memcpy(env[index], s.c_str(), s.length() * sizeof(char));
env[index][s.length()] = '\0';
}
return env;
}
void linux_environ_clear(char** data)
{
for (int i = 0; data[i] != NULL; i++)
delete [] data[i];
delete [] data;
}
void linux_environ_print(char** env)
{
std::wstring file = NSFile::GetProcessDirectory() + L"/env.log";
std::string fileA = U_TO_UTF8(file);
for (int i = 0; env[i] != NULL; i++)
{
FILE* f = fopen(fileA.c_str(), "a+");
std::string s = env[i];
// replace %%
size_t posn = 0;
while (std::string::npos != (posn = s.find("%", posn)))
{
s.replace(posn, 1, "%%");
posn += 2;
}
fprintf(f, s.c_str());
fprintf(f, "\n");
fclose(f);
}
}
#endif
class CHtmlFile_Private
@ -432,10 +499,11 @@ int CHtmlFile::Convert(const std::vector<std::wstring>& arFiles, const std::wstr
std::string::size_type posLast = sProgramm.find_last_of('/');
std::string sProgrammDir = sProgramm.substr(0, posLast);
if (std::string::npos != posLast)
sLibraryDir = "LD_LIBRARY_PATH=" + sProgrammDir + ":" + sProgrammDir + "/../";
sLibraryDir = sProgrammDir + ":" + sProgrammDir + "/../";
if (!IsLinuxXVFB())
{
sLibraryDir = "LD_LIBRARY_PATH=" + sLibraryDir;
const char* nargs[2];
nargs[0] = sXmlA.c_str();
nargs[1] = NULL;
@ -461,12 +529,17 @@ int CHtmlFile::Convert(const std::vector<std::wstring>& arFiles, const std::wstr
nargs[4] = sXmlA.c_str();
nargs[5] = NULL;
/*
const char* nenv[4];
nenv[0] = sLibraryDir.c_str();
nenv[1] = NULL;//"DISPLAY=:99";
nenv[2] = NULL;
*/
execve("/usr/bin/xvfb-run", (char * const *)nargs, (char * const *)nenv);
char** env = linux_environ_get(sLibraryDir);
//linux_environ_print(env);
execve("/usr/bin/xvfb-run", (char * const *)nargs, (char * const *)env);
linux_environ_clear(env);
exit(EXIT_SUCCESS);
}

View File

@ -39,6 +39,8 @@
#define SVG_INLINE_MAX_SIZE 500000 // 500Kb
#define SVG_TO_RASTER_MIN_SIZE 50000000 // 1Mb
const long c_nClipType2 = 0x0021; // c_nClipType + 1
namespace NSHtmlRenderer
{
#define USE_SIMPLE_GRAPHICS_NOSVG
@ -1672,7 +1674,8 @@ namespace NSHtmlRenderer
}
}
m_oClipMetafile.WriteLONG(CMetafile::ctEndCommand, c_nClipType);
m_oClipMetafile.WriteLONG(CMetafile::ctEndCommand, c_nClipType2);
m_oClipMetafile.WriteLONG(m_lClipMode);
m_oClipMetafile.WriteCommandType(CMetafile::ctPathCommandEnd);
}
@ -1726,7 +1729,8 @@ namespace NSHtmlRenderer
}
}
m_oClipMetafile.WriteLONG(CMetafile::ctEndCommand, c_nClipType);
m_oClipMetafile.WriteLONG(CMetafile::ctEndCommand, c_nClipType2);
m_oClipMetafile.WriteLONG(m_lClipMode);
m_oClipMetafile.WriteCommandType(CMetafile::ctPathCommandEnd);
return nRet;

View File

@ -33,6 +33,7 @@
#include "../../DesktopEditor/graphics/pro/Fonts.h"
#include "../../DesktopEditor/graphics/pro/Graphics.h"
#include "../../DesktopEditor/fontengine/ApplicationFontsWorker.h"
#include "../../PdfReader/PdfReader.h"
#include "../../DjVuFile/DjVu.h"
@ -77,17 +78,15 @@ int main(int argc, char *argv[])
return 0;
#endif
NSFonts::IApplicationFonts* pFonts = NSFonts::NSApplication::Create();
if (true)
{
pFonts->Initialize();
}
else
{
std::vector<std::wstring> arFiles = pFonts->GetSetupFontFiles();
NSDirectory::GetFiles2(L"D:\\GIT\\core-fonts", arFiles, true);
pFonts->InitializeFromArrayFiles(arFiles);
}
CApplicationFontsWorker oWorker;
oWorker.m_sDirectory = NSFile::GetProcessDirectory() + L"/fonts_cache";
//oWorker.m_arAdditionalFolders.push_back(L"D:\\GIT\\core-fonts");
oWorker.m_bIsNeedThumbnails = false;
if (!NSDirectory::Exists(oWorker.m_sDirectory))
NSDirectory::CreateDirectory(oWorker.m_sDirectory);
NSFonts::IApplicationFonts* pFonts = oWorker.Check();
#ifdef METAFILE_TEST

View File

@ -53,5 +53,8 @@ linux-g++ | linux-g++-64 | linux-g++-32 {
SOURCES += main.cpp
SOURCES += ../src/ASCSVGWriter.cpp
SOURCES += \
../src/ASCSVGWriter.cpp \
../../DesktopEditor/fontengine/ApplicationFontsWorker.cpp
HEADERS += ../include/ASCSVGWriter.h

View File

@ -613,6 +613,7 @@ namespace PdfReader
std::wstring wsTempFileName = L"";
Ref oEmbRef;
bool bFontSubstitution = false;
// 1. Если шрифт внедренный, тогда скидываем его в темповый файл.
// 2. Если шрифт лежит вне пдф, а в самом пдф есть ссылка на него, тогда используем эту ссылку.
// 3. В противном случае подбираем шрифт.
@ -1018,6 +1019,8 @@ namespace PdfReader
{
wsFileName = pFontInfo->m_wsFontPath;
eFontType = pFont->IsCIDFont() ? fontCIDType2 : fontTrueType;
bFontSubstitution = true;
}
else // В крайнем случае, в данном шрифте просто не пишем ничего
{
@ -1274,12 +1277,11 @@ namespace PdfReader
case fontCIDType2OT:
{
// Создаем карту CID-to-GID
// Если у нас есть мап ToUnicode, тогда на основе его читаем из файла гиды по юникодным значениям,
// если не нашли, но у нас есть мап CIDtoGID, тогда строим по последнему.
// Если у нас шрифт был не встроен и подбирался и есть мап ToUnicode, тогда на основе его читаем из файла гиды по юникодным значениям.
// Для встроенных шрифтов используем мап CIDtoGID
pCodeToGID = NULL;
nLen = 0;
if (L"" != wsFileName)
if (L"" != wsFileName && bFontSubstitution)
{
CharCodeToUnicode *pCodeToUnicode = NULL;
if ((pCodeToUnicode = ((GrCIDFont *)pFont)->GetToUnicode()))
@ -1316,7 +1318,7 @@ namespace PdfReader
}
else
{
pCodeToGID[nCode] = nCode;
pCodeToGID[nCode] = 0;
}
}
}
@ -1326,8 +1328,7 @@ namespace PdfReader
pCodeToUnicode->Release();
}
}
if (!pCodeToGID && ((GrCIDFont *)pFont)->GetCIDToGID())
else if (((GrCIDFont *)pFont)->GetCIDToGID())
{
nLen = ((GrCIDFont *)pFont)->GetCIDToGIDLen();
pCodeToGID = (unsigned short *)MemUtilsMallocArray(nLen, sizeof(unsigned short));
@ -3262,10 +3263,12 @@ namespace PdfReader
Aggplus::CImage oImage;
oImage.Create(pBufferPtr, nWidth, nHeight, -4 * nWidth);
// Пишем данные в pBufferPtr
ImageStream *pImageStream = new ImageStream(pStream, nWidth, pColorMap->GetComponentsCount(), pColorMap->GetBitsPerComponent());
int nComponentsCount = pColorMap->GetComponentsCount();
pImageStream->Reset();
// Пишем данные в pBufferPtr
ImageStream *pImageStream = new ImageStream(pStream, nWidth, nComponentsCount, pColorMap->GetBitsPerComponent());
pImageStream->Reset();
unsigned char unAlpha = m_bTransparentGroup ? 255.0 * pGState->GetFillOpacity() : 255;
@ -3276,12 +3279,29 @@ namespace PdfReader
{
int nIndex = 4 * (nX + nY * nWidth);
pImageStream->GetPixel(unPixel);
GrRGB oRGB;
pColorMap->GetRGB(unPixel, &oRGB);
pBufferPtr[nIndex + 0] = ColorToByte(oRGB.b);
pBufferPtr[nIndex + 1] = ColorToByte(oRGB.g);
pBufferPtr[nIndex + 2] = ColorToByte(oRGB.r);
pBufferPtr[nIndex + 3] = unAlpha;
if (pMaskColors)
{
bool isMask = true;
for (int nCompIndex = 0; nCompIndex < nComponentsCount; ++nCompIndex)
{
if (pMaskColors[nCompIndex * 2] > unPixel[nCompIndex] || unPixel[nCompIndex] > pMaskColors[nCompIndex * 2 + 1])
{
isMask = false;
break;
}
}
if (isMask)
pBufferPtr[nIndex + 3] = 0;
}
}
}

View File

@ -503,7 +503,7 @@ CPdfRenderer::CPdfRenderer(NSFonts::IApplicationFonts* pAppFonts, bool isPDFA) :
return;
}
m_pDocument->SetCompressionMode(COMP_ALL);
m_pDocument->SetCompressionMode(COMP_ALL);
m_bValid = true;
m_dPageHeight = 297;
@ -1864,32 +1864,32 @@ void CPdfRenderer::UpdateBrush()
double dL, dR, dT, dB;
m_oPath.GetBounds(dL, dT, dR, dB);
double dXStepSpacing = 0, dYStepSpacing = 0;
if (c_BrushTextureModeStretch == lTextureMode)
{
// Чтобы избавиться от погрешностей из-за которых могут возникать полоски, немного увеличим границы пата.
dL -= 1;
dT -= 1;
dB += 1;
dR += 1;
// Растягиваем картинку по размерам пата
dW = std::max(10.0, dR - dL);
dH = std::max(10.0, dB - dT);
dW = std::max(10.0, dR - dL);
dH = std::max(10.0, dB - dT);
// Чтобы избавиться от погрешностей из-за которых могут возникать полоски или обрезание картинки,
// удвоим расстрояние между соседними тайлами. Плохого тут нет, т.к. нам нужен всего 1 тайл
dXStepSpacing = dW;
dYStepSpacing = dH;
}
else
{
// Размеры картинки заданы в пикселях. Размеры тайла - это размеры картинки в пунктах.
dW = nImageW * 72 / 96;
dH = nImageH * 72 / 96;
}
}
// Нам нужно, чтобы левый нижний угол границ нашего пата являлся точкой переноса для матрицы преобразования.
CMatrix* pMatrix = m_pPage->GetTransform();
pMatrix->Apply(dL, dB);
pMatrix->Apply(dL, dT);
CMatrix oPatternMatrix = *pMatrix;
oPatternMatrix.x = dL;
oPatternMatrix.y = dB;
m_pPage->SetPatternColorSpace(m_pDocument->CreateImageTilePattern(dW, dH, pImage, &oPatternMatrix));
oPatternMatrix.y = dT;
m_pPage->SetPatternColorSpace(m_pDocument->CreateImageTilePattern(dW, dH, pImage, &oPatternMatrix, imagetilepatterntype_Default, dXStepSpacing, dYStepSpacing));
}
}
else if (c_BrushTypeHatch1 == lBrushType)

View File

@ -744,9 +744,9 @@ namespace PdfWriter
return pShading;
}
CImageTilePattern*CDocument::CreateImageTilePattern(double dW, double dH, CImageDict* pImageDict, CMatrix* pMatrix, EImageTilePatternType eType)
CImageTilePattern*CDocument::CreateImageTilePattern(double dW, double dH, CImageDict* pImageDict, CMatrix* pMatrix, EImageTilePatternType eType, double dXStepSpacing, double dYStepSpacing)
{
return new CImageTilePattern(m_pXref, dW, dH, pImageDict, pMatrix, eType);
return new CImageTilePattern(m_pXref, dW, dH, pImageDict, pMatrix, eType, dXStepSpacing, dYStepSpacing);
}
CImageTilePattern*CDocument::CreateHatchPattern(double dW, double dH, const BYTE& nR1, const BYTE& nG1, const BYTE& nB1, const BYTE& nAlpha1, const BYTE& nR2, const BYTE& nG2, const BYTE& nB2, const BYTE& nAlpha2, const std::wstring& wsHatch)
{

View File

@ -117,7 +117,7 @@ namespace PdfWriter
CFont14* CreateFont14(EStandard14Fonts eType);
CFontCidTrueType* CreateTrueTypeFont(const std::wstring& wsFontPath, unsigned int unIndex);
CImageTilePattern*CreateImageTilePattern(double dW, double dH, CImageDict* pImageDict, CMatrix* pMatrix = NULL, EImageTilePatternType eType = imagetilepatterntype_Default);
CImageTilePattern*CreateImageTilePattern(double dW, double dH, CImageDict* pImageDict, CMatrix* pMatrix = NULL, EImageTilePatternType eType = imagetilepatterntype_Default, double dXStepSpacing = 0, double dYStepSpacing = 0);
CImageTilePattern*CreateHatchPattern(double dW, double dH, const BYTE& nR1, const BYTE& nG1, const BYTE& nB1, const BYTE& nAlpha1, const BYTE& nR2, const BYTE& nG2, const BYTE& nB2, const BYTE& nAlpha2, const std::wstring& wsHatch);
CShading* CreateAxialShading(CPage* pPage, double dX0, double dY0, double dX1, double dY1, unsigned char* pColors, unsigned char* pAlphas, double* pPoints, int nCount, CExtGrState*& pExtGrState);
CShading* CreateRadialShading(CPage* pPage, double dX0, double dY0, double dR0, double dX1, double dY1, double dR1, unsigned char* pColors, unsigned char* pAlphas, double* pPoints, int nCount, CExtGrState*& pExtGrState);

View File

@ -44,7 +44,7 @@ namespace PdfWriter
//----------------------------------------------------------------------------------------
// CImageTilePattern
//----------------------------------------------------------------------------------------
CImageTilePattern::CImageTilePattern(CXref* pXref, const double& dW, const double& dH, CImageDict* pImageDict, CMatrix* pMatrix, EImageTilePatternType eType) : CPattern(pXref)
CImageTilePattern::CImageTilePattern(CXref* pXref, const double& dW, const double& dH, CImageDict* pImageDict, CMatrix* pMatrix, EImageTilePatternType eType, double dXStepSpacing, double dYStepSpacing) : CPattern(pXref)
{
Add("Type", "Pattern");
Add("PatternType", 1);
@ -84,9 +84,13 @@ namespace PdfWriter
if (imagetilepatterntype_Default == eType)
{
Add("BBox", CArrayObject::CreateBox(0, 0, dW, dH));
Add("XStep", dW);
Add("YStep", dH);
if (dXStepSpacing > 0.01 && dYStepSpacing > 0.01)
Add("BBox", CArrayObject::CreateBox(-dXStepSpacing / 2, -dYStepSpacing / 2, dW + dXStepSpacing / 2, dH + dYStepSpacing / 2));
else
Add("BBox", CArrayObject::CreateBox(0, 0, dW, dH));
Add("XStep", dW + dXStepSpacing);
Add("YStep", dH + dYStepSpacing);
pStream->WriteReal(dW);
pStream->WriteStr(" 0 0 ");
@ -97,8 +101,8 @@ namespace PdfWriter
else if (imagetilepatterntype_InverseX == eType)
{
Add("BBox", CArrayObject::CreateBox(0, 0, 2 * dW, dH));
Add("XStep", 2 * dW);
Add("YStep", dH);
Add("XStep", 2 * dW + dXStepSpacing);
Add("YStep", dH + dYStepSpacing);
pStream->WriteStr("q\12");
pStream->WriteReal(dW);
@ -119,8 +123,8 @@ namespace PdfWriter
else if (imagetilepatterntype_InverseY == eType)
{
Add("BBox", CArrayObject::CreateBox(0, 0, dW, 2 * dH));
Add("XStep", dW);
Add("YStep", 2 * dH);
Add("XStep", dW + dXStepSpacing);
Add("YStep", 2 * dH + dYStepSpacing);
pStream->WriteStr("q\12");
pStream->WriteReal(dW);
@ -141,8 +145,8 @@ namespace PdfWriter
else if (imagetilepatterntype_InverseXY == eType)
{
Add("BBox", CArrayObject::CreateBox(0, 0, 2 * dW, 2 * dH));
Add("XStep", 2 * dW);
Add("YStep", 2 * dH);
Add("XStep", 2 * dW + dXStepSpacing);
Add("YStep", 2 * dH + dYStepSpacing);
pStream->WriteStr("q\12");
pStream->WriteReal(dW);
@ -183,4 +187,4 @@ namespace PdfWriter
pStream->WriteStr("/X1 Do\12");
}
}
}
}

View File

@ -51,8 +51,8 @@ namespace PdfWriter
class CImageTilePattern : public CPattern
{
public:
CImageTilePattern(CXref* pXref, const double& dW, const double& dH, CImageDict* pImageDict, CMatrix* pMatrix = NULL, EImageTilePatternType eType = imagetilepatterntype_Default);
CImageTilePattern(CXref* pXref, const double& dW, const double& dH, CImageDict* pImageDict, CMatrix* pMatrix = NULL, EImageTilePatternType eType = imagetilepatterntype_Default, double dXStepSpacing = 0, double dYStepSpacing = 0);
};
}
#endif // _PDF_WRITER_SRC_PATTERN_H
#endif // _PDF_WRITER_SRC_PATTERN_H

View File

@ -15,8 +15,9 @@ include(../Common/base.pri)
DEFINES += UNICODECONVERTER_USE_DYNAMIC_LIBRARY
core_linux {
QMAKE_LFLAGS += -Wl,--rpath=./
core_linux {
QMAKE_LFLAGS += "-Wl,-rpath,\'\$$ORIGIN\'"
QMAKE_LFLAGS += -Wl,--disable-new-dtags
}
core_ios {