From 7a1a59a88334b6498cb2dae32a08c1de82b2a4cb Mon Sep 17 00:00:00 2001 From: Oleg Korshul Date: Sun, 2 Jun 2024 10:20:52 +0300 Subject: [PATCH] For bug 68028 --- DesktopEditor/fontengine/js/libfont.json | 4 ++- .../EmfInterpretator/CEmfInterpretatorSvg.cpp | 2 ++ .../CInterpretatorSvgBase.cpp | 2 ++ .../Metafile/test/MetafileToSvg/main.cpp | 34 +++++++++---------- 4 files changed, 23 insertions(+), 19 deletions(-) diff --git a/DesktopEditor/fontengine/js/libfont.json b/DesktopEditor/fontengine/js/libfont.json index d720f09f4c..3d4028e04b 100644 --- a/DesktopEditor/fontengine/js/libfont.json +++ b/DesktopEditor/fontengine/js/libfont.json @@ -110,7 +110,9 @@ "_getcwd=getcwd", "NO_CONSOLE_IO", "BUILD_ZLIB_AS_SOURCES", - "IMAGE_CHECKER_DISABLE_XML" + "IMAGE_CHECKER_DISABLE_XML", + + "BUILDING_WASM_MODULE" ], "compile_files_array": [ { diff --git a/DesktopEditor/raster/Metafile/Emf/EmfInterpretator/CEmfInterpretatorSvg.cpp b/DesktopEditor/raster/Metafile/Emf/EmfInterpretator/CEmfInterpretatorSvg.cpp index dc66cba25d..e3d1d13433 100644 --- a/DesktopEditor/raster/Metafile/Emf/EmfInterpretator/CEmfInterpretatorSvg.cpp +++ b/DesktopEditor/raster/Metafile/Emf/EmfInterpretator/CEmfInterpretatorSvg.cpp @@ -1169,6 +1169,7 @@ namespace MetaFile std::wstring wsFontName = pFont->GetFaceName(); +#ifndef BUILDING_WASM_MODULE if (!wsFontName.empty()) { NSFonts::CFontSelectFormat oFormat; @@ -1179,6 +1180,7 @@ namespace MetaFile if (NULL != pFontInfo && !StringEquals(wsFontName, pFontInfo->m_wsFontName)) wsFontName = L"'" + wsFontName + L"', '" + pFontInfo->m_wsFontName + L"'"; } +#endif if (!wsFontName.empty()) arNodeAttributes.push_back({L"font-family", wsFontName}); diff --git a/DesktopEditor/raster/Metafile/Wmf/WmfInterpretator/CInterpretatorSvgBase.cpp b/DesktopEditor/raster/Metafile/Wmf/WmfInterpretator/CInterpretatorSvgBase.cpp index 57a4d1e134..1c860b7517 100644 --- a/DesktopEditor/raster/Metafile/Wmf/WmfInterpretator/CInterpretatorSvgBase.cpp +++ b/DesktopEditor/raster/Metafile/Wmf/WmfInterpretator/CInterpretatorSvgBase.cpp @@ -283,6 +283,7 @@ namespace MetaFile std::wstring wsFontName = pFont->GetFaceName(); +#ifndef BUILDING_WASM_MODULE if (!wsFontName.empty()) { NSFonts::CFontSelectFormat oFormat; @@ -293,6 +294,7 @@ namespace MetaFile if (NULL != pFontInfo && !StringEquals(wsFontName, pFontInfo->m_wsFontName)) wsFontName = L"'" + wsFontName + L"', '" + pFontInfo->m_wsFontName + L"'"; } +#endif if (!wsFontName.empty()) arNodeAttributes.push_back({L"font-family", wsFontName}); diff --git a/DesktopEditor/raster/Metafile/test/MetafileToSvg/main.cpp b/DesktopEditor/raster/Metafile/test/MetafileToSvg/main.cpp index 05c54979c3..ca3c658d0e 100644 --- a/DesktopEditor/raster/Metafile/test/MetafileToSvg/main.cpp +++ b/DesktopEditor/raster/Metafile/test/MetafileToSvg/main.cpp @@ -29,35 +29,33 @@ * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode * */ -//#include +// #include +#include "../../../../fontengine/ApplicationFontsWorker.h" #include "../../../../graphics/pro/Fonts.h" #include "../../../../graphics/pro/Graphics.h" -#include "../../../../fontengine/ApplicationFontsWorker.h" -#include "../../../../raster/BgraFrame.h" #include "../../../../common/Directory.h" +#include "../../../../raster/BgraFrame.h" -int main(int argc, char *argv[]) +int main(int argc, char* argv[]) { - // Check system fonts - CApplicationFontsWorker oWorker; - oWorker.m_sDirectory = NSFile::GetProcessDirectory() + L"/fonts_cache"; - oWorker.m_bIsNeedThumbnails = false; + // Check system fonts + CApplicationFontsWorker oWorker; + oWorker.m_sDirectory = NSFile::GetProcessDirectory() + L"/fonts_cache"; + oWorker.m_bIsNeedThumbnails = false; - if (!NSDirectory::Exists(oWorker.m_sDirectory)) - NSDirectory::CreateDirectory(oWorker.m_sDirectory); + if (!NSDirectory::Exists(oWorker.m_sDirectory)) + NSDirectory::CreateDirectory(oWorker.m_sDirectory); - NSFonts::IApplicationFonts* pFonts = oWorker.Check(); + NSFonts::IApplicationFonts* pFonts = oWorker.Check(); - MetaFile::IMetaFile* pMetafile = MetaFile::Create(pFonts); - pMetafile->LoadFromFile(L"PATH_TO_METAFILE"); + MetaFile::IMetaFile* pMetafile = MetaFile::Create(pFonts); + pMetafile->LoadFromFile(L"D:/image1.wmf"); - std::wstring wsData; - - pMetafile->ConvertToSvg(wsData); + std::wstring wsData = pMetafile->ConvertToSvg(); pMetafile->Release(); - pFonts->Release(); - return 0; + pFonts->Release(); + return 0; }