This commit is contained in:
Kirill Polyakov
2025-11-07 14:18:04 +03:00
parent 76b5bd594d
commit 5de19652f2
2 changed files with 17 additions and 9 deletions

View File

@ -163,9 +163,9 @@ namespace SVG
else if (eNodeType == XmlUtils::XmlNodeType_Element && "tspan" == oReader.GetName()) else if (eNodeType == XmlUtils::XmlNodeType_Element && "tspan" == oReader.GetName())
{ {
const TBounds oBounds{GetBounds()}; const TBounds oBounds{GetBounds()};
const Point oPoint{oBounds.m_dRight, oBounds.m_dTop}; const Point oPoint{oBounds.m_dRight, oBounds.m_dBottom};
AddObject(CRenderedObject::Create<CTSpan>(oReader, pSvgFile, this, m_pFontManager, oPoint)); AddObject(CObject::Create<CTSpan>(oReader, pSvgFile, this, m_pFontManager, oPoint));
} }
} }
} }
@ -187,8 +187,14 @@ namespace SVG
{ {
if (!m_wsText.empty()) if (!m_wsText.empty())
{ {
ApplyFont(pRenderer, dX, dY); Aggplus::CMatrix oCurrentMatrix;
ApplyFont(pRenderer, dX, dY, oCurrentMatrix);
pRenderer->CommandDrawText(m_wsText, dX, dY, 0, 0); pRenderer->CommandDrawText(m_wsText, dX, dY, 0, 0);
pRenderer->SetTransform(oCurrentMatrix.sx(), oCurrentMatrix.shy(),
oCurrentMatrix.shx(), oCurrentMatrix.sy(),
oCurrentMatrix.tx(), oCurrentMatrix.ty());
} }
} }
@ -230,12 +236,12 @@ namespace SVG
nTypePath += c_nWindingFillMode; nTypePath += c_nWindingFillMode;
} }
void CTSpan::ApplyFont(IRenderer* pRenderer, double& dX, double& dY) const void CTSpan::ApplyFont(IRenderer* pRenderer, double& dX, double& dY, Aggplus::CMatrix& oOldMatrix) const
{ {
std::wstring wsFontFamily = DefaultFontFamily; std::wstring wsFontFamily = DefaultFontFamily;
double dFontSize = ((!m_oFont.GetSize().Empty()) ? m_oFont.GetSize().ToDouble(NSCSS::Pixel) : DEFAULT_FONT_SIZE) * 72. / 25.4; double dFontSize = ((!m_oFont.GetSize().Empty()) ? m_oFont.GetSize().ToDouble(NSCSS::Pixel) : DEFAULT_FONT_SIZE) * 72. / 25.4;
Normalize(pRenderer, dX, dY, dFontSize); Normalize(pRenderer, dX, dY, dFontSize, oOldMatrix);
if (!m_oFont.GetFamily().Empty()) if (!m_oFont.GetFamily().Empty())
{ {
@ -340,7 +346,7 @@ namespace SVG
if (NULL != pParentTSpan) if (NULL != pParentTSpan)
{ {
m_oFont.UpdateSize((!pParentTSpan->m_oFont.GetSize().Empty()) ? pParentTSpan->m_oFont.GetSize().ToDouble(NSCSS::Pixel) : DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE); m_oFont.UpdateSize((!pParentTSpan->m_oFont.GetSize().Empty()) ? pParentTSpan->m_oFont.GetSize().ToDouble(NSCSS::Point) : DEFAULT_FONT_SIZE, DEFAULT_FONT_SIZE);
return; return;
} }
} }
@ -478,7 +484,7 @@ namespace SVG
dY = m_oY.ToDouble(NSCSS::Pixel, oBounds.m_dBottom - oBounds.m_dTop); dY = m_oY.ToDouble(NSCSS::Pixel, oBounds.m_dBottom - oBounds.m_dTop);
} }
void CTSpan::Normalize(IRenderer *pRenderer, double &dX, double &dY, double &dFontHeight) const void CTSpan::Normalize(IRenderer *pRenderer, double &dX, double &dY, double &dFontHeight, Aggplus::CMatrix& oOldMatrix) const
{ {
if (NULL == pRenderer) if (NULL == pRenderer)
return; return;
@ -521,6 +527,8 @@ namespace SVG
pRenderer->GetTransform(&dM11, &dM12, &dM21, &dM22, &dDx, &dDy); pRenderer->GetTransform(&dM11, &dM12, &dM21, &dM22, &dDx, &dDy);
oOldMatrix.SetElements(dM11, dM12, dM21, dM22, dDx, dDy);
Aggplus::CMatrix oMatrix(dM11, dM12, dM21, dM22, dDx, dDy); Aggplus::CMatrix oMatrix(dM11, dM12, dM21, dM22, dDx, dDy);
oMatrix.Scale(dXScale, dYScale); oMatrix.Scale(dXScale, dYScale);

View File

@ -32,7 +32,7 @@ namespace SVG
void InheritStyles(const CTSpan* pTSpan); void InheritStyles(const CTSpan* pTSpan);
private: private:
void ApplyStyle(IRenderer* pRenderer, const TSvgStyles* pStyles, const CSvgFile* pFile, int& nTypePath, const CRenderedObject* pContexObject = NULL) const override; void ApplyStyle(IRenderer* pRenderer, const TSvgStyles* pStyles, const CSvgFile* pFile, int& nTypePath, const CRenderedObject* pContexObject = NULL) const override;
void ApplyFont(IRenderer* pRenderer, double& dX, double& dY) const; void ApplyFont(IRenderer* pRenderer, double& dX, double& dY, Aggplus::CMatrix& oOldMatrix) const;
void UpdateFontSize(); void UpdateFontSize();
bool UseExternalFont(const CSvgFile* pFile, double dX, double dY, IRenderer* pRenderer, CommandeMode oMode = CommandeModeDraw, const TSvgStyles* pOtherStyles = NULL, const CRenderedObject* pContexObject = NULL) const; bool UseExternalFont(const CSvgFile* pFile, double dX, double dY, IRenderer* pRenderer, CommandeMode oMode = CommandeModeDraw, const TSvgStyles* pOtherStyles = NULL, const CRenderedObject* pContexObject = NULL) const;
@ -44,7 +44,7 @@ namespace SVG
void CalculatePosition(double& dX, double& dY) const; void CalculatePosition(double& dX, double& dY) const;
void Normalize(IRenderer* pRenderer, double& dX, double& dY, double& dFontHeight) const; void Normalize(IRenderer* pRenderer, double& dX, double& dY, double& dFontHeight, Aggplus::CMatrix& oOldMatrix) const;
void SetPosition(const Point& oPosition); void SetPosition(const Point& oPosition);
void SetPositionFromParent(CRenderedObject* pParent); void SetPositionFromParent(CRenderedObject* pParent);