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)
|
else if ("font" == sElementName)
|
||||||
{
|
{
|
||||||
pObject = CObject::Create<CFont>(oReader, pFile);
|
pObject = CObject::Create<CFont>(oReader, pFile, pFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL == pObject)
|
if (NULL == pObject)
|
||||||
|
|||||||
@ -2,22 +2,23 @@
|
|||||||
|
|
||||||
namespace SVG
|
namespace SVG
|
||||||
{
|
{
|
||||||
CGlyph::CGlyph(CSvgReader& oReader)
|
CGlyph::CGlyph(CSvgReader& oReader, CSvgFile* pFile)
|
||||||
: CPath(oReader)
|
: CPath(oReader)
|
||||||
{
|
{}
|
||||||
START_READ_ATTRIBUTES(oReader)
|
|
||||||
{
|
|
||||||
if ("unicode" == sAttributeName)
|
|
||||||
{
|
|
||||||
const std::wstring wsUnicode{oReader.GetText()};
|
|
||||||
|
|
||||||
if (!wsUnicode.empty())
|
void CGlyph::SetAttribute(const std::string& sName, CSvgReader& oReader)
|
||||||
m_wchUnicode = wsUnicode[0];
|
{
|
||||||
}
|
if ("unicode" == sName)
|
||||||
else if ("horiz-adv-x" == sAttributeName)
|
{
|
||||||
m_oHorizAdvX.SetValue(oReader.GetText());
|
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
|
wchar_t CGlyph::GetUnicode() const
|
||||||
@ -28,10 +29,10 @@ namespace SVG
|
|||||||
CFontFace::CFontFace(CSvgReader& oReader)
|
CFontFace::CFontFace(CSvgReader& oReader)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CFont::CFont(CSvgReader& oReader)
|
CFont::CFont(CSvgReader& oReader, CSvgFile* pFile)
|
||||||
: CAppliedObject(oReader), m_pMissingGlyph(NULL)
|
: CAppliedObject(oReader), m_pMissingGlyph(NULL)
|
||||||
{
|
{
|
||||||
ParseGlyphs(oReader);
|
ParseGlyphs(oReader, pFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
CFont::~CFont()
|
CFont::~CFont()
|
||||||
@ -95,7 +96,7 @@ namespace SVG
|
|||||||
{ \
|
{ \
|
||||||
oMatrix.Scale(1. / dGlyphScale, -1. / dGlyphScale); \
|
oMatrix.Scale(1. / dGlyphScale, -1. / dGlyphScale); \
|
||||||
pRenderer->SetTransform(oMatrix.sx(), oMatrix.shy(), oMatrix.shx(), oMatrix.sy(), oMatrix.tx(), oMatrix.ty()); \
|
pRenderer->SetTransform(oMatrix.sx(), oMatrix.shy(), oMatrix.shx(), oMatrix.sy(), oMatrix.tx(), oMatrix.ty()); \
|
||||||
} \
|
}
|
||||||
|
|
||||||
for (wchar_t wchGlyph : wsText)
|
for (wchar_t wchGlyph : wsText)
|
||||||
{
|
{
|
||||||
@ -128,13 +129,13 @@ namespace SVG
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CFont::ParseGlyphs(CSvgReader& oReader)
|
void CFont::ParseGlyphs(CSvgReader& oReader, CSvgFile* pFile)
|
||||||
{
|
{
|
||||||
WHILE_READ_NEXT_NODE_WITH_NAME(oReader)
|
WHILE_READ_NEXT_NODE_WITH_NAME(oReader)
|
||||||
{
|
{
|
||||||
if ("glyph" == sNodeName)
|
if ("glyph" == sNodeName)
|
||||||
{
|
{
|
||||||
CGlyph *pGlyph = new CGlyph(oReader);
|
CGlyph *pGlyph = CObject::Create<CGlyph>(oReader, pFile, pFile);
|
||||||
|
|
||||||
if (NULL == pGlyph)
|
if (NULL == pGlyph)
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@ -8,7 +8,9 @@ namespace SVG
|
|||||||
class CGlyph : public CPath
|
class CGlyph : public CPath
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CGlyph(CSvgReader& oReader);
|
CGlyph(CSvgReader& oReader, CSvgFile* pFile = nullptr);
|
||||||
|
|
||||||
|
void SetAttribute(const std::string& sName, CSvgReader& oReader) override;
|
||||||
|
|
||||||
wchar_t GetUnicode() const;
|
wchar_t GetUnicode() const;
|
||||||
private:
|
private:
|
||||||
@ -37,7 +39,7 @@ namespace SVG
|
|||||||
class CFont : public CAppliedObject
|
class CFont : public CAppliedObject
|
||||||
{
|
{
|
||||||
friend class CObject;
|
friend class CObject;
|
||||||
CFont(CSvgReader& oReader);
|
CFont(CSvgReader& oReader, CSvgFile* pFile = nullptr);
|
||||||
public:
|
public:
|
||||||
~CFont();
|
~CFont();
|
||||||
|
|
||||||
@ -48,7 +50,7 @@ namespace SVG
|
|||||||
bool Apply(IRenderer* pRenderer, const CSvgFile *pFile, const TBounds &oObjectBounds) override;
|
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;
|
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:
|
private:
|
||||||
void ParseGlyphs(CSvgReader& oReader);
|
void ParseGlyphs(CSvgReader& oReader, CSvgFile* pFile = nullptr);
|
||||||
|
|
||||||
TFontArguments m_oArguments;
|
TFontArguments m_oArguments;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user