From 903d903aadde14d2c91c649c4566e8c9db6baffb Mon Sep 17 00:00:00 2001 From: Oleg Korshul Date: Tue, 17 Apr 2018 11:59:12 +0300 Subject: [PATCH] doctrenderer builds --- Common/FileDownloader/FileDownloader.h | 2 +- DesktopEditor/doctrenderer/docbuilder_p.h | 10 +- DesktopEditor/doctrenderer/doctrenderer.pro | 28 +---- DesktopEditor/doctrenderer/nativecontrol.h | 40 +++++-- DesktopEditor/fontengine/ApplicationFonts.h | 2 +- DesktopEditor/fontengine/FontFile.cpp | 21 ++++ DesktopEditor/fontengine/FontFile.h | 6 +- .../fontengine/application_generate_fonts.h | 103 ++++++++---------- DesktopEditor/graphics/pro/Fonts.h | 3 + 9 files changed, 114 insertions(+), 101 deletions(-) diff --git a/Common/FileDownloader/FileDownloader.h b/Common/FileDownloader/FileDownloader.h index e547d9212e..b46ff1e939 100644 --- a/Common/FileDownloader/FileDownloader.h +++ b/Common/FileDownloader/FileDownloader.h @@ -32,7 +32,7 @@ #pragma once #include -#include "kernel_config.h" +#include "../kernel_config.h" class CFileDownloader_private; class KERNEL_DECL CFileDownloader diff --git a/DesktopEditor/doctrenderer/docbuilder_p.h b/DesktopEditor/doctrenderer/docbuilder_p.h index b1a696fdfc..3840d10f18 100644 --- a/DesktopEditor/doctrenderer/docbuilder_p.h +++ b/DesktopEditor/doctrenderer/docbuilder_p.h @@ -759,8 +759,8 @@ namespace NSDoctRenderer if (!bIsEqual || bIsCheckSystemFonts) { - CApplicationFonts oApplicationF; - std::vector strFontsW_Cur = oApplicationF.GetSetupFontFiles(); + NSFonts::IApplicationFonts* pApplicationF; + std::vector strFontsW_Cur = pApplicationF->GetSetupFontFiles(); if (strFonts.size() != strFontsW_Cur.size()) bIsEqual = false; @@ -798,9 +798,11 @@ namespace NSDoctRenderer } oFile.CloseFile(); - oApplicationF.InitializeFromArrayFiles(strFontsW_Cur, 2); - NSCommon::SaveAllFontsJS(oApplicationF, strAllFontsJSPath, L"", strFontsSelectionBin); + pApplicationF->InitializeFromArrayFiles(strFontsW_Cur, 2); + NSCommon::SaveAllFontsJS(pApplicationF, strAllFontsJSPath, L"", strFontsSelectionBin); } + + RELEASEOBJECT(pApplicationF); } } diff --git a/DesktopEditor/doctrenderer/doctrenderer.pro b/DesktopEditor/doctrenderer/doctrenderer.pro index 84a3e80e13..50901a1a00 100644 --- a/DesktopEditor/doctrenderer/doctrenderer.pro +++ b/DesktopEditor/doctrenderer/doctrenderer.pro @@ -16,11 +16,9 @@ CORE_ROOT_DIR = $$PWD/../.. PWD_ROOT_DIR = $$PWD include(../../Common/base.pri) -include(../Qt_build/graphics/project/graphics_fonts.pri) -include(../xml/build/qt/libxml2.pri) - -CONFIG += build_all_zlib build_zlib_as_sources -include(../../OfficeUtils/OfficeUtils.pri) +DEFINES += KERNEL_USE_DYNAMIC_LIBRARY +DEFINES += GRAPHICS_USE_DYNAMIC_LIBRARY +LIBS += -L$$CORE_BUILDS_LIBRARIES_PATH -lUnicodeConverter -lkernel -lgraphics include(../../Common/3dParty/v8/v8.pri) @@ -44,23 +42,3 @@ HEADERS += doctrenderer.h \ # downloader DEFINES += BUIDLER_OPEN_DOWNLOAD_ENABLED DEFINES += BUIDLER_OPEN_BASE64_ENABLED - -HEADERS += ../../Common/FileDownloader/FileDownloader.h -core_windows { - SOURCES += \ - ../../Common/FileDownloader/FileDownloader_win.cpp - - LIBS += -lurlmon -} -core_linux { - SOURCES += \ - ../../Common/FileDownloader/FileDownloader_curl.cpp - - LIBS += -lcurl -} -core_mac { - OBJECTIVE_SOURCES += \ - ../../Common/FileDownloader/FileDownloader_mac.mm - - LIBS += -framework AppKit -} diff --git a/DesktopEditor/doctrenderer/nativecontrol.h b/DesktopEditor/doctrenderer/nativecontrol.h index e7f4e381d0..699116f681 100644 --- a/DesktopEditor/doctrenderer/nativecontrol.h +++ b/DesktopEditor/doctrenderer/nativecontrol.h @@ -32,15 +32,30 @@ #ifndef NATIVECONTROL #define NATIVECONTROL -#include "memorystream.h" #include -#include "../fontengine/ApplicationFonts.h" #include + +#include "../graphics/pro/Fonts.h" #include "../../graphics/Timer.h" #include "../../common/Directory.h" +#include "../../common/Array.h" #include "../../../../OfficeUtils/src/OfficeUtils.h" + +#include "memorystream.h" #include "../../fontengine/application_generate_fonts_common.h" +#if defined(CreateDirectory) +#undef CreateDirectory +#endif + +#if defined(GetTempPath) +#undef GetTempPath +#endif + +#if defined(CreateFile) +#undef CreateFile +#endif + class CZipWorker { public: @@ -372,18 +387,17 @@ public: { if (0 == m_map_fonts.size()) { - CApplicationFonts oApplication; + NSFonts::IApplicationFonts* pApplication = NSFonts::NSApplication::Create(); if (m_strFontsDirectory == L"") - oApplication.Initialize(); + pApplication->Initialize(); else - oApplication.InitializeFromFolder(m_strFontsDirectory); + pApplication->InitializeFromFolder(m_strFontsDirectory); - CArray* pFonts = oApplication.GetList()->GetFonts(); + std::vector* pFonts = pApplication->GetList()->GetFonts(); - int nCount = pFonts->GetCount(); - for (int nIndex = 0; nIndex < nCount; ++nIndex) + for (std::vector::iterator i = pFonts->begin(); i < pFonts->end(); i++) { - CFontInfo* pCurrent = pFonts->operator [](nIndex); + NSFonts::CFontInfo* pCurrent = *i; size_t pos1 = pCurrent->m_wsFontPath.find_last_of(wchar_t('/')); size_t pos2 = pCurrent->m_wsFontPath.find_last_of(wchar_t('\\')); @@ -410,13 +424,17 @@ public: } } - CFontSelectFormat oFormat; + NSFonts::CFontSelectFormat oFormat; oFormat.wsName = new std::wstring(L"Arial"); m_sDefaultFont = L""; - CFontInfo* pInfo = oApplication.GenerateFontManager()->GetFontInfoByParams(oFormat); + NSFonts::IFontManager* pManager = pApplication->GenerateFontManager(); + NSFonts::CFontInfo* pInfo = pManager->GetFontInfoByParams(oFormat); if (NULL != pInfo) m_sDefaultFont = pInfo->m_wsFontPath; + + RELEASEINTERFACE(pManager); + RELEASEOBJECT(pApplication); } } }; diff --git a/DesktopEditor/fontengine/ApplicationFonts.h b/DesktopEditor/fontengine/ApplicationFonts.h index 83e51083f4..6171de3855 100644 --- a/DesktopEditor/fontengine/ApplicationFonts.h +++ b/DesktopEditor/fontengine/ApplicationFonts.h @@ -112,7 +112,7 @@ private: public: static EFontFormat GetFontFormat(FT_Face pFace); - void ToBuffer(BYTE** pDstData, LONG* pLen, std::wstring strDirectory = L"", bool bIsOnlyFileName = false); + virtual void ToBuffer(BYTE** pDstData, LONG* pLen, std::wstring strDirectory = L"", bool bIsOnlyFileName = false); public: void LoadFromArrayFiles (std::vector& arrFiles, int nFlag = 0); diff --git a/DesktopEditor/fontengine/FontFile.cpp b/DesktopEditor/fontengine/FontFile.cpp index c586a70a4d..752dba80a7 100644 --- a/DesktopEditor/fontengine/FontFile.cpp +++ b/DesktopEditor/fontengine/FontFile.cpp @@ -1829,3 +1829,24 @@ bool CFontFile::IsBold() return ((m_pFace->style_flags & FT_STYLE_FLAG_BOLD) != 0) ? true : false; } + +bool CFontFile::IsSymbolic(bool bIsOS2Check) +{ + if (!m_pFace) + return false; + + bool bIsSymbol = (-1 != m_nSymbolic) ? true : false; + + if (!bIsSymbol && bIsOS2Check) + { + TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(m_pFace, ft_sfnt_os2); + + if (NULL != pOS2) + { + if (0 == (pOS2->ulCodePageRange1 & 0xF0000000)) + bIsSymbol = true; + } + } + + return bIsSymbol; +} diff --git a/DesktopEditor/fontengine/FontFile.h b/DesktopEditor/fontengine/FontFile.h index 640c76405c..3b0b8996f2 100644 --- a/DesktopEditor/fontengine/FontFile.h +++ b/DesktopEditor/fontengine/FontFile.h @@ -271,8 +271,10 @@ public: // path NSFonts::IFontPath* GetGlyphPath(int nCode); - bool IsItalic(); - bool IsBold(); + virtual bool IsItalic(); + virtual bool IsBold(); + + virtual bool IsSymbolic(bool bIsOS2Check = false); }; //------------------------------------------------------------------------------------------------------------------------------- diff --git a/DesktopEditor/fontengine/application_generate_fonts.h b/DesktopEditor/fontengine/application_generate_fonts.h index d9a32deeee..96636527a9 100644 --- a/DesktopEditor/fontengine/application_generate_fonts.h +++ b/DesktopEditor/fontengine/application_generate_fonts.h @@ -35,13 +35,14 @@ #include #include -#include "./ApplicationFonts.h" +#include "../graphics/pro/Fonts.h" #include "../common/File.h" #include "../common/Directory.h" +#include "../common/Array.h" #include "../common/StringBuilder.h" #ifndef ASC_APPLICATION_FONTS_NO_THUMBNAILS -#include "../graphics/GraphicsRenderer.h" +#include "../graphics/pro/Graphics.h" #endif #include "./application_generate_fonts_common.h" @@ -153,7 +154,7 @@ namespace NSCommon } }; - class CSymbolSimpleChecker : public CApplicationFontsSymbolsChecker + class CSymbolSimpleChecker : public NSFonts::CApplicationFontsSymbolsChecker { public: int m_nMaxSymbols; @@ -182,7 +183,7 @@ namespace NSCommon } }; - class CSymbolSimpleChecker2 : public CApplicationFontsSymbolsChecker + class CSymbolSimpleChecker2 : public NSFonts::CApplicationFontsSymbolsChecker { public: int m_nMaxSymbols; @@ -324,18 +325,18 @@ namespace NSCommon } }; - static void SaveAllFontsJS(CApplicationFonts& applicationFonts, std::wstring strFile, std::wstring strFolderThumbnails, std::wstring strFontSelectionBin) + static void SaveAllFontsJS(NSFonts::IApplicationFonts* applicationFonts, std::wstring strFile, std::wstring strFolderThumbnails, std::wstring strFontSelectionBin) { - CArray* pList = applicationFonts.GetList()->GetFonts(); - int nCount = pList->GetCount(); + std::vector* pList = applicationFonts->GetList()->GetFonts(); + int nCount = pList->size(); // сначала строим массив всех файлов шрифтов std::map mapFontFiles; std::map mapFontFiles2; LONG lFontFiles = 0; - for (int i = 0; i < nCount; ++i) + for (std::vector::iterator i = pList->begin(); i != pList->end(); i++) { - CFontInfo* pInfo = pList->operator [](i); + NSFonts::CFontInfo* pInfo = *i; if (mapFontFiles.find(pInfo->m_wsFontPath) == mapFontFiles.end()) { @@ -350,9 +351,9 @@ namespace NSCommon std::map mapFonts; CArray arrFonts; - for (int i = 0; i < nCount; ++i) + for (std::vector::iterator i = pList->begin(); i != pList->end(); i++) { - CFontInfo* pInfo = (CFontInfo*)pList->operator [](i); + NSFonts::CFontInfo* pInfo = *i; std::wstring strPath = pInfo->m_wsFontPath; std::wstring strName = pInfo->m_wsFontName; @@ -462,9 +463,9 @@ namespace NSCommon #ifndef ASC_APPLICATION_FONTS_NO_THUMBNAILS if (L"" != strFolderThumbnails) { - CFontManager* pManager = applicationFonts.GenerateFontManager(); - CFontsCache* pCache = new CFontsCache(); - pCache->SetStreams(applicationFonts.GetStreams()); + NSFonts::IFontManager* pManager = applicationFonts->GenerateFontManager(); + NSFonts::IFontsCache* pCache = NSFonts::NSFontCache::Create(); + pCache->SetStreams(applicationFonts->GetStreams()); pManager->SetOwnerCache(pCache); for (int iX = 1; iX <= 2; ++iX) @@ -491,13 +492,13 @@ namespace NSCommon pImageData[i] = 0; } - CGraphicsRenderer oRenderer; - oRenderer.CreateFromBgraFrame(&oFrame); + NSGraphics::IGraphicsRenderer pRenderer = NSGraphics::Create(); + pRenderer->CreateFromBgraFrame(&oFrame); - oRenderer.SetFontManager(pManager); + pRenderer->SetFontManager(pManager); - oRenderer.put_Width(lWidthPix * 25.4 / dDpi); - oRenderer.put_Height(lHeightPix * 25.4 / dDpi); + pRenderer->put_Width(lWidthPix * 25.4 / dDpi); + pRenderer->put_Height(lHeightPix * 25.4 / dDpi); for (int index = 0; index < nCountFonts; ++index) { @@ -532,63 +533,51 @@ namespace NSCommon if (mapFontFiles2.end() != pPair2) strFontPath = pPair2->second; - oRenderer.put_FontPath(strFontPath); - oRenderer.put_FontFaceIndex(lFaceIndex); + pRenderer->put_FontPath(strFontPath); + pRenderer->put_FontFaceIndex(lFaceIndex); pManager->LoadFontFromFile(strFontPath, lFaceIndex, 14, dDpi, dDpi); bool bIsSymbol = FALSE; - if (pManager->m_pFont) + if (pManager->GetFile()) { - bIsSymbol = (-1 != (pManager->m_pFont->m_nSymbolic)) ? true : false; - - if (!bIsSymbol) - { - TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(pManager->m_pFont->m_pFace, ft_sfnt_os2); - - int y = 0; - ++y; - - if (NULL != pOS2) - { - if (0 == (pOS2->ulCodePageRange1 & 0xF0000000)) - bIsSymbol = true; - } - } + bIsSymbol = pManager->GetFile()->IsSymbolic(true); } if (bIsSymbol) { - CFontSelectFormat oSelectFormat; + NSFonts::CFontSelectFormat oSelectFormat; oSelectFormat.wsName = new std::wstring(L"Courier New"); - CFontInfo* pInfoCur = pManager->GetFontInfoByParams(oSelectFormat); + NSFonts::CFontInfo* pInfoCur = pManager->GetFontInfoByParams(oSelectFormat); if (NULL != pInfoCur) { pManager->LoadFontFromFile(pInfoCur->m_wsFontPath, 0, 14, dDpi, dDpi); } - oRenderer.put_FontPath(pInfoCur->m_wsFontPath); - oRenderer.put_FontFaceIndex(0); + pRenderer->put_FontPath(pInfoCur->m_wsFontPath); + pRenderer->put_FontFaceIndex(0); } - oRenderer.PathCommandStart(); - oRenderer.BeginCommand(c_nClipType); - oRenderer.PathCommandRect(0, 25.4 * (index * lH1_px) / dDpi, dW_mm, 25.4 * lH1_px / dDpi); - oRenderer.EndCommand(c_nClipType); - oRenderer.PathCommandEnd(); + pRenderer->PathCommandStart(); + pRenderer->BeginCommand(c_nClipType); + pRenderer->PathCommandRect(0, 25.4 * (index * lH1_px) / dDpi, dW_mm, 25.4 * lH1_px / dDpi); + pRenderer->EndCommand(c_nClipType); + pRenderer->PathCommandEnd(); - oRenderer.put_FontStringGID(FALSE); - oRenderer.put_FontCharSpace(0); - oRenderer.put_FontSize(14); + pRenderer->put_FontStringGID(FALSE); + pRenderer->put_FontCharSpace(0); + pRenderer->put_FontSize(14); - oRenderer.CommandDrawText(pPair->second.m_sName, 5, 25.4 * (index * lH1_px + lH1_px) / dDpi - 2, 0, 0); + pRenderer->CommandDrawText(pPair->second.m_sName, 5, 25.4 * (index * lH1_px + lH1_px) / dDpi - 2, 0, 0); - oRenderer.BeginCommand(c_nResetClipType); - oRenderer.EndCommand(c_nResetClipType); + pRenderer->BeginCommand(c_nResetClipType); + pRenderer->EndCommand(c_nResetClipType); - oRenderer.CloseFont(); + pRenderer->CloseFont(); pCache->Clear(); - applicationFonts.GetStreams()->Clear(); + applicationFonts->GetStreams()->Clear(); + + RELEASEOBJECT(pRenderer); } std::wstring strThumbnailPath = strFolderThumbnails + L"/fonts_thumbnail"; @@ -728,7 +717,7 @@ namespace NSCommon mapFontsPriorityStandard.insert(std::pair(L"SimHei", 33)); mapFontsPriorityStandard.insert(std::pair(L"Meiryo", 34)); - CApplicationFontsSymbols oApplicationChecker; + NSFonts::CApplicationFontsSymbols oApplicationChecker; std::vector arrFontsPriority; std::map mapFontsPriority; @@ -942,7 +931,7 @@ namespace NSCommon { BYTE* pData = NULL; LONG lLen = 0; - applicationFonts.GetList()->ToBuffer(&pData, &lLen, L"", false); + applicationFonts->GetList()->ToBuffer(&pData, &lLen, L"", false); char* cData64 = NULL; int nData64Dst = 0; @@ -968,7 +957,7 @@ namespace NSCommon { BYTE* pData = NULL; LONG lLen = 0; - applicationFonts.GetList()->ToBuffer(&pData, &lLen, L"", false); + applicationFonts->GetList()->ToBuffer(&pData, &lLen, L"", false); NSFile::CFileBinary oFile; oFile.CreateFileW(strFontSelectionBin); diff --git a/DesktopEditor/graphics/pro/Fonts.h b/DesktopEditor/graphics/pro/Fonts.h index 215329912e..7a81867231 100644 --- a/DesktopEditor/graphics/pro/Fonts.h +++ b/DesktopEditor/graphics/pro/Fonts.h @@ -460,6 +460,8 @@ namespace NSFonts virtual bool IsItalic() = 0; virtual bool IsBold() = 0; + virtual bool IsSymbolic(bool bIsOS2Check = false) = 0; + virtual int IsUnicodeRangeAvailable(unsigned long ulBit, unsigned int un4ByteIndex) = 0; }; @@ -577,6 +579,7 @@ namespace NSFonts public: virtual std::vector* GetFonts() = 0; virtual CFontInfo* GetByParams(CFontSelectFormat& oSelect, bool bIsDictionaryUse = true) = 0; + virtual void ToBuffer(BYTE** pDstData, LONG* pLen, std::wstring strDirectory = L"", bool bIsOnlyFileName = false) = 0; }; class GRAPHICS_DECL IApplicationFonts