Remove depends to CSvgFile from HtmlFile2. Add initialize fontsfor svg.

This commit is contained in:
Oleg Korshul
2025-01-02 22:36:18 +03:00
parent 45aa5df267
commit cef8ac9fd9
4 changed files with 48 additions and 19 deletions

View File

@ -448,6 +448,37 @@ namespace MetaFile
return false;
}
bool CMetaFile::LoadFromString(const std::wstring& data)
{
#ifdef METAFILE_SUPPORT_SVG
RELEASEINTERFACE(m_pFontManager);
if (m_pAppFonts)
{
m_pFontManager = m_pAppFonts->GenerateFontManager();
NSFonts::IFontsCache* pMeasurerCache = NSFonts::NSFontCache::Create();
pMeasurerCache->SetStreams(m_pAppFonts->GetStreams());
m_pFontManager->SetOwnerCache(pMeasurerCache);
}
m_oSvgFile.SetFontManager(m_pFontManager);
if (m_oSvgFile.ReadFromWString(data) == true)
{
m_lType = c_lMetaSvg;
return true;
}
#endif
return false;
}
void CMetaFile::SetTempDirectory(const std::wstring& dir)
{
#ifdef METAFILE_SUPPORT_SVG
m_oSvgFile.SetWorkingDirectory(dir);
#endif
}
bool CMetaFile::DrawOnRenderer(IRenderer* pRenderer, double dX, double dY, double dWidth, double dHeight)
{
if (NULL == pRenderer)

View File

@ -64,6 +64,7 @@ namespace MetaFile
bool LoadFromFile(const wchar_t* wsFilePath);
bool LoadFromBuffer(BYTE* pBuffer, unsigned int unSize);
bool LoadFromString(const std::wstring& data);
bool DrawOnRenderer(IRenderer* pRenderer, double dX, double dY, double dWidth, double dHeight);
void Close();
void GetBounds(double* pdX, double* pdY, double* pdW, double* pdH);
@ -75,6 +76,8 @@ namespace MetaFile
//конвертация в Svg
std::wstring ConvertToSvg(unsigned int unWidth = 0, unsigned int unHeight = 0);
void SetTempDirectory(const std::wstring& dir);
//Для тестов
#ifdef METAFILE_SUPPORT_WMF_EMF
void ConvertToXml(const wchar_t *wsFilePath);