xps fix nCurrentFont

This commit is contained in:
Kulikova Svetlana
2021-10-27 18:58:11 +03:00
parent ada8f8beb8
commit 3c6096967b
2 changed files with 19 additions and 16 deletions

View File

@ -32,9 +32,11 @@
#ifndef _XPS_XPSLIB_FONTLIST_H
#define _XPS_XPSLIB_FONTLIST_H
#include <map>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <iterator>
#include "../../DesktopEditor/graphics/TemporaryCS.h"
#include "../../DesktopEditor/common/File.h"
@ -113,19 +115,23 @@ namespace XPS
}
m_oCS.Leave();
}
int GetFontId(const std::wstring& wsName)
{
std::vector<std::wstring>::iterator oIter = std::find(m_mList.begin(), m_mList.end(), wsName);
if (oIter != m_mList.end())
return std::distance(m_mList.begin(), oIter);
return -1;
}
private:
bool Find(const std::wstring& wsName)
{
std::map<std::wstring, bool>::iterator oIter = m_mList.find(wsName);
if (oIter != m_mList.end())
return oIter->second;
return false;
std::vector<std::wstring>::iterator oIter = std::find(m_mList.begin(), m_mList.end(), wsName);
return oIter != m_mList.end();
}
void Add(const std::wstring& wsName)
{
m_mList.insert(std::pair<std::wstring, bool>(wsName, true));
m_mList.push_back(wsName);
}
void GetFontKey(const std::wstring& wsName, unsigned char* sKey)
{
@ -155,7 +161,7 @@ namespace XPS
private:
NSCriticalSection::CRITICAL_SECTION m_oCS;
std::map<std::wstring, bool> m_mList;
std::vector<std::wstring> m_mList;
};
}

View File

@ -191,13 +191,6 @@ namespace XPS
oRes.ClearWithoutAttack();
return res;
}
int GetCurrentFont(const std::wstring& sFont)
{
size_t nLast = sFont.rfind(L'_');
if (nLast == std::wstring::npos)
return -1;
return std::stoi(sFont.substr(nLast + 1)) - 1;
}
void Page::GetGlyphs(IRenderer* m_pRenderer, const std::wstring& bsUnicodeText, const unsigned int* pGids, const unsigned int nGidsCount, const double& x, const double& y, const double& w, const double& h)
{
// m_pInternal->GetUnicodes(bsUnicodeText);
@ -236,7 +229,11 @@ namespace XPS
std::wstring sCurrentFontName; double dFontSize;
m_pRenderer->get_FontPath(&sCurrentFontName);
m_pRenderer->get_FontSize(&dFontSize);
int nCurrentFont = GetCurrentFont(sCurrentFontName);
std::wstring wsFontName = sCurrentFontName;
NSStringExt::Replace(wsFontName, L"\\", L"/");
wsFontName = GetFileName(wsFontName);
NSStringExt::ToLower(wsFontName);
int nCurrentFont = m_pFontList->GetFontId(wsFontName);
if ((nCurrentFont != m_lCurrentFont) || (dFontSize != m_dCurrentFontSize))
{
m_lCurrentFont = nCurrentFont;