From d9e210c0de2b0f11b695eef509e4294530491d88 Mon Sep 17 00:00:00 2001 From: Kevin Stricker Date: Sat, 1 Oct 2022 19:08:37 -0600 Subject: [PATCH] Less limited text-anchor attribute handling. --- .../impl/TSpanNodeRendererIntegrationTest.cs | 6 + .../cmp_textspan-textAnchor-transform.pdf | Bin 0 -> 7158 bytes .../textspan-textAnchor-transform.svg | 144 ++++++++++++++++++ .../renderers/impl/TextSvgBranchRenderer.cs | 8 +- 4 files changed, 152 insertions(+), 6 deletions(-) create mode 100644 itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-textAnchor-transform.pdf create mode 100644 itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/TSpanNodeRendererIntegrationTest/textspan-textAnchor-transform.svg diff --git a/itext.tests/itext.svg.tests/itext/svg/renderers/impl/TSpanNodeRendererIntegrationTest.cs b/itext.tests/itext.svg.tests/itext/svg/renderers/impl/TSpanNodeRendererIntegrationTest.cs index d3382693c2..91eb1c836c 100644 --- a/itext.tests/itext.svg.tests/itext/svg/renderers/impl/TSpanNodeRendererIntegrationTest.cs +++ b/itext.tests/itext.svg.tests/itext/svg/renderers/impl/TSpanNodeRendererIntegrationTest.cs @@ -179,6 +179,12 @@ public virtual void TSpanTextAnchorFunctionalTest() { ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "textspan-textAnchor"); } + //Text-anchor test using transform attribute for X position + [NUnit.Framework.Test] + public virtual void TSpanTextAnchorTransformFunctionalTest() { + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "textspan-textAnchor-transform"); + } + [NUnit.Framework.Test] //TODO: update after DEVSIX-2507 and DEVSIX-3005 fix [LogMessage(iText.StyledXmlParser.Logs.StyledXmlParserLogMessageConstant.UNKNOWN_ABSOLUTE_METRIC_LENGTH_PARSED diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-textAnchor-transform.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-textAnchor-transform.pdf new file mode 100644 index 0000000000000000000000000000000000000000..8f9b14570b17aa6e750b66c413b6105d6b37aec5 GIT binary patch literal 7158 zcmeHM&2rl|5We#%aPh=GNc<5YN}Y^nVmnSV&5tWp(3Qi{1UOz+y>k9UUC@!hYgy{rlhF|9DyjsyzMRJ$~%J z$cppky$Yk<-MXo=bm@Ka{KI9a4odH5&&!IrVS}O}aXWOsESjunYDMZM{>yBhr+ek) z+W<{H)@l?-C;m}dK}JO^GRf-lqMBtj4FCH2^g}jlK#{eC`gig3r&YdO(=z@2V+K{{ z+3qg6M2>_QVK7ifZA`G_e%hpq^1Kxuw8HxU+2mz$kT%)&!4FXoMPU$x;YbhSuony; z1;L{o|7AJ9Ti~cF=NGfA+RmrhW%HNXFRM%?{iq-Jj$b`FI{xwXRK44N^6cn^`kYlY z48Ge@e?~zN^vI;*Vd_~`UVK!qe%WbV9k#CSrFC|QN%p7tGOK%&a+wzX(_&W6^Wxlp zlNV2lI(O~ki_?atiDn?=r%!`h%@hMOWBcU=f)e^a<@5S2g>-TvBX}y?AruxfWX}dA zinNM#aAKE^9{RV(bws*3uGYQ7vRaBQvjW`0qlgBoM}N?-W=n5N)t}E*RhA7_rF6>^ zeRnNVvbxdjaWuZ>I87F<#!yiRx;jlRn;B76=DqO>=j!B{7xWXYeglpQOWj+MJ;nxW zVMS4&_7RYgSfHwNbbjJSs904fsup>Xc|F$54-6nH!dZBtl{DNsOhnB%9=u@~XSj;(-5=5Xd4}% zSO=>XHX9USCP~Mg6LSS2rnxIXi1M_+MyUId1qgaz5DIA_x(;~h1~Ba~hH*c!AVCie zN+B&w*FlEu0CwUYIC=KEB4uHV6%7|m&@jy1LRze@Ln7h=%AzbJ9WJEk5RN8wAT3(g zA%!75VUaxZR0AW#p*iXwHv^+i)%D);|kiwRY-@_b`VlK05trO z^}CiZXp13beDe0DCP8xk4AhkJ$h1P5qz$Ll^o&!Efvv+w;D6wM~penK%Epc0%DZB118%x~^Gubh1Bgnj(HYYQ;Q7Lh|26B_z zwX)lw4g}o0vI*U;rBr4&DtYJ{1k(_o0&(X;SEMwryx=-u<#U#W zfz>t$D<7|p!wMNKSmcuxC10(m(Bvgp(hyO3+HUD&Au%K!G^y8hcf=cOrKv93j5g*o zmxY&}YrqN6n0j=;2~o#bV?H(wo6lL$ByMT)&^3V44FDw30|FveJ+tY2fF2TW{b^G- z)nuHXdAXXr@wIZdQ*O6I*ThF@i*nxG$-7nW)?ily_sQPQj17HfBVU-l!;lsjtUToJ zhq9ZuuB)y!71yZL>@np!kU<{GZY~&U)7^+Cqwh6~<2dW|VL|E!{;*(4s$Zncknabq ziYg5*Q1G?DusK)BX9X!-Xa$)XM$(nkFp|bdi^*08wxw^b=!_6LH)k`^3Q=2$ zg5hH5I)$(?G;A9K5;wF%DA?Q+2NO()ltpOA5JDr!btnY8#&FmrUyHX8wFrm&f&(@j z2TkU+AuK|}W>iMp&<>%Nph#)XuUOCmCZEBgTv}q^h%-X?($?AbQ}OM2+Vy;+?3aPt>9We`qtw{LrHJ{dq1FSf z&XnavA)KS1DjZLTxRzMqMH(ONS9n2!uQ{tc#AKBhN9+3Z5O)YGV-tPFm!?YdMOM)j z+VcbT_OZ@}qxn3Jf;1h(gV9;4&qi?&Cxh{LoXn%s-OUmw{`2CjRCHH0@h7YVu6FM9P+S}TC`ufoOA8{rX>i_@% literal 0 HcmV?d00001 diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/TSpanNodeRendererIntegrationTest/textspan-textAnchor-transform.svg b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/TSpanNodeRendererIntegrationTest/textspan-textAnchor-transform.svg new file mode 100644 index 0000000000..31dcbc59f5 --- /dev/null +++ b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/TSpanNodeRendererIntegrationTest/textspan-textAnchor-transform.svg @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + no text anchor + + start text anchor + + middle text anchor + + end text anchor + + + + + + no text anchor + + start text anchor + + middle text anchor + + end text anchor + + + + + + no text anchor + + start text anchor + + middle text anchor + + end text anchor + + + + + + no text anchor + + start text anchor + + middle text anchor + + end text anchor + + + diff --git a/itext/itext.svg/itext/svg/renderers/impl/TextSvgBranchRenderer.cs b/itext/itext.svg/itext/svg/renderers/impl/TextSvgBranchRenderer.cs index 920d62b0d1..7e58ec672c 100644 --- a/itext/itext.svg/itext/svg/renderers/impl/TextSvgBranchRenderer.cs +++ b/itext/itext.svg/itext/svg/renderers/impl/TextSvgBranchRenderer.cs @@ -411,15 +411,11 @@ internal virtual float GetTextAnchorAlignmentCorrection(float childContentLength String textAnchorValue = this.GetAttribute(SvgConstants.Attributes.TEXT_ANCHOR); // Middle if (SvgConstants.Values.TEXT_ANCHOR_MIDDLE.Equals(textAnchorValue)) { - if (xPos != null && xPos.Length > 0) { - textAnchorXCorrection -= childContentLength / 2; - } + textAnchorXCorrection -= childContentLength / 2; } // End if (SvgConstants.Values.TEXT_ANCHOR_END.Equals(textAnchorValue)) { - if (xPos != null && xPos.Length > 0) { - textAnchorXCorrection -= childContentLength; - } + textAnchorXCorrection -= childContentLength; } } return textAnchorXCorrection;