From 187351500694af94bc10c2b97bbec68a8e196a7c Mon Sep 17 00:00:00 2001 From: Oleg Korshul Date: Thu, 15 Sep 2022 16:33:08 +0300 Subject: [PATCH] Fix bug 58096 --- DesktopEditor/fontengine/FontFile.cpp | 14 ++++++++------ DesktopEditor/fontengine/FontManager.cpp | 11 +++++++++-- DesktopEditor/fontengine/FontManager.h | 4 ++++ DesktopEditor/graphics/GraphicsRenderer.cpp | 2 ++ DesktopEditor/graphics/IRenderer.h | 1 + DesktopEditor/graphics/MetafileToRenderer.cpp | 3 +++ DesktopEditor/graphics/pro/Fonts.h | 2 ++ 7 files changed, 29 insertions(+), 8 deletions(-) diff --git a/DesktopEditor/fontengine/FontFile.cpp b/DesktopEditor/fontengine/FontFile.cpp index b8bead4d9d..0aaae1edc7 100644 --- a/DesktopEditor/fontengine/FontFile.cpp +++ b/DesktopEditor/fontengine/FontFile.cpp @@ -872,8 +872,16 @@ TFontCacheSizes CFontFile::CacheGlyph(const int& code, const bool& isRaster, CVe if ( FT_Get_Glyph( m_pFace->glyph, &pGlyph ) ) return oSizes; + TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(m_pFace, ft_sfnt_os2); + + bool bIsNeedBold = (m_bNeedDoBold == TRUE) ? true : false; + if (bIsNeedBold && pOS2 && pOS2->version != 0xFFFF && pOS2->usWeightClass >= 800) + bIsNeedBold = false; + if (pWorker) { + if (bIsNeedBold) + FT_Outline_EmboldenXY(&((FT_OutlineGlyph)pGlyph)->outline, (m_unHorDpi * 64 / 25.4) / 3, 0); FT_Outline_Decompose( &((FT_OutlineGlyph)pGlyph)->outline, pWorker->func_interface, pWorker->user ); return oSizes; } @@ -883,12 +891,6 @@ TFontCacheSizes CFontFile::CacheGlyph(const int& code, const bool& isRaster, CVe FT_Glyph_Get_CBox(pGlyph, 1, &oBBox); FT_Done_Glyph(pGlyph); - TT_OS2* pOS2 = (TT_OS2*)FT_Get_Sfnt_Table(m_pFace, ft_sfnt_os2); - - bool bIsNeedBold = (m_bNeedDoBold == TRUE) ? true : false; - if (bIsNeedBold && pOS2 && pOS2->version != 0xFFFF && pOS2->usWeightClass >= 800) - bIsNeedBold = false; - FT_GlyphSlot pGlyphSlot = m_pFace->glyph; oSizes.fAdvanceX = (float)(pGlyphSlot->linearHoriAdvance * m_dUnitsKoef / m_pFace->units_per_EM); diff --git a/DesktopEditor/fontengine/FontManager.cpp b/DesktopEditor/fontengine/FontManager.cpp index 3a3c65a4eb..fe487a4862 100644 --- a/DesktopEditor/fontengine/FontManager.cpp +++ b/DesktopEditor/fontengine/FontManager.cpp @@ -340,6 +340,8 @@ CFontManager::CFontManager() : NSFonts::IFontManager() m_lAscender = 0; m_lDescender = 0; m_lLineHeight = 0; + + m_bCorrectFontByName = true; } CFontManager::~CFontManager() @@ -743,7 +745,7 @@ INT CFontManager::LoadFontByName(const std::wstring& sName, const double& dSize, if (lStyle & 0x02) *oFormat.bItalic = TRUE; - NSFonts::CFontInfo* pInfo = m_pApplication->GetList()->GetByParams(oFormat); + NSFonts::CFontInfo* pInfo = m_pApplication->GetList()->GetByParams(oFormat, m_bCorrectFontByName); if (NULL == pInfo) return FALSE; @@ -751,7 +753,7 @@ INT CFontManager::LoadFontByName(const std::wstring& sName, const double& dSize, if (bLoad == TRUE) { - bool bIsNeedBold = false; + bool bIsNeedBold = false; if (NULL != oFormat.bBold && (*oFormat.bBold) == TRUE && pInfo->m_bBold == FALSE) bIsNeedBold = true; bool bIsNeedItalic = false; @@ -896,6 +898,11 @@ void CFontManager::GetLimitsY(double& dMin, double& dMax) } } +void CFontManager::SetUseCorrentFontByName(const bool& use) +{ + m_bCorrectFontByName = use; +} + CFontFile* CFontManager::GetFontFileBySymbol(CFontFile* pFile, int code) { std::wstring sName = m_pApplication->GetFontBySymbol(code); diff --git a/DesktopEditor/fontengine/FontManager.h b/DesktopEditor/fontengine/FontManager.h index f5198aca2e..5a1a61243d 100644 --- a/DesktopEditor/fontengine/FontManager.h +++ b/DesktopEditor/fontengine/FontManager.h @@ -118,6 +118,8 @@ public: int m_nLOAD_MODE; int m_nRENDER_MODE; + bool m_bCorrectFontByName; + CApplicationFonts* m_pApplication; CFontsCache* m_pOwnerCache; @@ -190,6 +192,8 @@ public: virtual void GetFace(double& d0, double& d1, double& d2); virtual void GetLimitsY(double& dMin, double& dMax); + virtual void SetUseCorrentFontByName(const bool& use); + CFontFile* GetFontFileBySymbol(CFontFile* pFile, int code); }; diff --git a/DesktopEditor/graphics/GraphicsRenderer.cpp b/DesktopEditor/graphics/GraphicsRenderer.cpp index e99d47c48d..7e10359002 100644 --- a/DesktopEditor/graphics/GraphicsRenderer.cpp +++ b/DesktopEditor/graphics/GraphicsRenderer.cpp @@ -1156,6 +1156,8 @@ HRESULT CGraphicsRenderer::CommandLong(const LONG& lType, const LONG& lCommand) { if (c_nDarkMode == lType && m_pRenderer) m_pRenderer->m_bIsDarkMode = (1 == lCommand); + if (c_nUseDictionaryFonts == lType && m_pFontManager) + m_pFontManager->SetUseCorrentFontByName((1 == lCommand) ? true : false); return S_OK; } HRESULT CGraphicsRenderer::CommandDouble(const LONG& lType, const double& dCommand) diff --git a/DesktopEditor/graphics/IRenderer.h b/DesktopEditor/graphics/IRenderer.h index 081a654379..49094eb2f0 100644 --- a/DesktopEditor/graphics/IRenderer.h +++ b/DesktopEditor/graphics/IRenderer.h @@ -106,6 +106,7 @@ const long c_nParamFlipX = 0x0001; const long c_nParamFlipY = 0x0002; const long c_nFlipNextRotate = 0x0004; const long c_nDarkMode = 0x0008; +const long c_nUseDictionaryFonts = 0x0010; // типы рендерера const long c_nUnknownRenderer = 0x0000; diff --git a/DesktopEditor/graphics/MetafileToRenderer.cpp b/DesktopEditor/graphics/MetafileToRenderer.cpp index c6d8a18e7e..5c039a6690 100644 --- a/DesktopEditor/graphics/MetafileToRenderer.cpp +++ b/DesktopEditor/graphics/MetafileToRenderer.cpp @@ -475,6 +475,9 @@ namespace NSOnlineOfficeBinToPdf LONG lRendererType = 0; pRenderer->get_Type(&lRendererType); + // из команд js - точные имена + pRenderer->CommandLong(c_nUseDictionaryFonts, 0); + CommandType eCommand = ctError; bool bIsPathOpened = false; diff --git a/DesktopEditor/graphics/pro/Fonts.h b/DesktopEditor/graphics/pro/Fonts.h index a7bf3f4f73..a178d83981 100644 --- a/DesktopEditor/graphics/pro/Fonts.h +++ b/DesktopEditor/graphics/pro/Fonts.h @@ -715,6 +715,8 @@ namespace NSFonts virtual void GetLimitsY(double& dMin, double& dMax) = 0; virtual int GetUnderline(float *pfStartX, float *pfStartY, float *pfEndX, float *pfEndY, float *pfSize) = 0; + + virtual void SetUseCorrentFontByName(const bool& use) = 0; public: static IFontFile* LoadFontFile(CLibrary& library, IFontStream* pStream, int lFaceIndex); };