mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-02-10 18:05:41 +08:00
Fix bug in svg
This commit is contained in:
@ -294,7 +294,7 @@ namespace SVG
|
||||
}
|
||||
else if ("font" == sElementName)
|
||||
{
|
||||
pObject = CObject::Create<CFont>(oReader, pFile);
|
||||
pObject = CObject::Create<CFont>(oReader, pFile, pFile);
|
||||
}
|
||||
|
||||
if (NULL == pObject)
|
||||
|
||||
@ -2,22 +2,23 @@
|
||||
|
||||
namespace SVG
|
||||
{
|
||||
CGlyph::CGlyph(CSvgReader& oReader)
|
||||
CGlyph::CGlyph(CSvgReader& oReader, CSvgFile* pFile)
|
||||
: CPath(oReader)
|
||||
{
|
||||
START_READ_ATTRIBUTES(oReader)
|
||||
{
|
||||
if ("unicode" == sAttributeName)
|
||||
{
|
||||
const std::wstring wsUnicode{oReader.GetText()};
|
||||
{}
|
||||
|
||||
if (!wsUnicode.empty())
|
||||
m_wchUnicode = wsUnicode[0];
|
||||
}
|
||||
else if ("horiz-adv-x" == sAttributeName)
|
||||
m_oHorizAdvX.SetValue(oReader.GetText());
|
||||
void CGlyph::SetAttribute(const std::string& sName, CSvgReader& oReader)
|
||||
{
|
||||
if ("unicode" == sName)
|
||||
{
|
||||
const std::wstring wsUnicode{oReader.GetText()};
|
||||
|
||||
if (!wsUnicode.empty())
|
||||
m_wchUnicode = wsUnicode[0];
|
||||
}
|
||||
END_READ_ATTRIBUTES(oReader)
|
||||
else if ("horiz-adv-x" == sName)
|
||||
m_oHorizAdvX.SetValue(oReader.GetText());
|
||||
else
|
||||
CPath::SetAttribute(sName, oReader);
|
||||
}
|
||||
|
||||
wchar_t CGlyph::GetUnicode() const
|
||||
@ -28,10 +29,10 @@ namespace SVG
|
||||
CFontFace::CFontFace(CSvgReader& oReader)
|
||||
{}
|
||||
|
||||
CFont::CFont(CSvgReader& oReader)
|
||||
CFont::CFont(CSvgReader& oReader, CSvgFile* pFile)
|
||||
: CAppliedObject(oReader), m_pMissingGlyph(NULL)
|
||||
{
|
||||
ParseGlyphs(oReader);
|
||||
ParseGlyphs(oReader, pFile);
|
||||
}
|
||||
|
||||
CFont::~CFont()
|
||||
@ -95,7 +96,7 @@ namespace SVG
|
||||
{ \
|
||||
oMatrix.Scale(1. / dGlyphScale, -1. / dGlyphScale); \
|
||||
pRenderer->SetTransform(oMatrix.sx(), oMatrix.shy(), oMatrix.shx(), oMatrix.sy(), oMatrix.tx(), oMatrix.ty()); \
|
||||
} \
|
||||
}
|
||||
|
||||
for (wchar_t wchGlyph : wsText)
|
||||
{
|
||||
@ -128,13 +129,13 @@ namespace SVG
|
||||
return true;
|
||||
}
|
||||
|
||||
void CFont::ParseGlyphs(CSvgReader& oReader)
|
||||
void CFont::ParseGlyphs(CSvgReader& oReader, CSvgFile* pFile)
|
||||
{
|
||||
WHILE_READ_NEXT_NODE_WITH_NAME(oReader)
|
||||
{
|
||||
if ("glyph" == sNodeName)
|
||||
{
|
||||
CGlyph *pGlyph = new CGlyph(oReader);
|
||||
CGlyph *pGlyph = CObject::Create<CGlyph>(oReader, pFile, pFile);
|
||||
|
||||
if (NULL == pGlyph)
|
||||
continue;
|
||||
|
||||
@ -8,7 +8,9 @@ namespace SVG
|
||||
class CGlyph : public CPath
|
||||
{
|
||||
public:
|
||||
CGlyph(CSvgReader& oReader);
|
||||
CGlyph(CSvgReader& oReader, CSvgFile* pFile = nullptr);
|
||||
|
||||
void SetAttribute(const std::string& sName, CSvgReader& oReader) override;
|
||||
|
||||
wchar_t GetUnicode() const;
|
||||
private:
|
||||
@ -37,7 +39,7 @@ namespace SVG
|
||||
class CFont : public CAppliedObject
|
||||
{
|
||||
friend class CObject;
|
||||
CFont(CSvgReader& oReader);
|
||||
CFont(CSvgReader& oReader, CSvgFile* pFile = nullptr);
|
||||
public:
|
||||
~CFont();
|
||||
|
||||
@ -48,7 +50,7 @@ namespace SVG
|
||||
bool Apply(IRenderer* pRenderer, const CSvgFile *pFile, const TBounds &oObjectBounds) override;
|
||||
bool Draw(const std::wstring& wsText, const double& dX, const double& dY, const double& dFontHeight, IRenderer* pRenderer, const CSvgFile *pFile, CommandeMode oMode = CommandeModeDraw, const TSvgStyles* pStyles = NULL, const CRenderedObject* pContexObject = NULL) const;
|
||||
private:
|
||||
void ParseGlyphs(CSvgReader& oReader);
|
||||
void ParseGlyphs(CSvgReader& oReader, CSvgFile* pFile = nullptr);
|
||||
|
||||
TFontArguments m_oArguments;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user