Hey Miyako, Further info from previous post...
The more I experiment the more I think the width of the text is not correct. If I include these lines: SVG_SET_ATTRIBUTES ($text_svgRef;"text-align";"center") SVG_SET_ATTRIBUTES ($text_svgRef;"display-align";"center”) In a text string of “19˚” the 9 shows up approx. centered. If I exclude these two lines then. In a text string of “19˚” the 1 shows up approx. right aligned. So I am baffled and there’s little 4D example sir using the TextArea and modifying attributes. Of course I am reviewing the SVG spec and trying properties from there. But… So there’s something I don’t understand I think. Appreciate, John... > Hi Miyako, > > So if I understand how to replace “text” with “TextArea”… > > Here’s an existing code fragment with various height/width adjustments > > $fontAlign_D:=Align center > > $pnt_X:=$ctr_X+(($ctr_X*$radius)*Cos($Angle)) > $pnt_Y:=$ctr_Y-(($ctr_Y*$radius)*Sin($Angle)) > > $display_t:=$Degree+”˚” ` example: 16˚ > > In this example the X and Y of the point are: > > inX_D=577 > inY_D=276 > > SVG_String_WidthHeight_Get (display_t; ->$width; > ->$height; $fontName; $fontSize_D; $fontStyle_D; $fontAlign_D) > > ` set new Y coord based upon returned height dimensions > $inY_D:=$inY_D-($height/2) > > $text_svgRef:=SVG_New_text > ($domSvg_ptr->;$cuspDegree+"˚";$inX_D;$inY_D;$fontName;$fontSize_D;$fontStyle_D;$fontAlign_D) > > The XML looks like: > > <text fill="#000000" font-family="Tahoma" font-size="14" font-style="normal" > font-weight="normal" stroke="#000000" text-anchor="middle" > text-decoration="none" x="577" y="282">16˚</text> > > Notice the Y value is changed to 282. This works pretty good! > > ---------------------------------------------- > > When switched from SVG_New_text to SVG_New_textArea: > > $display_t:=$Degree+”˚” ` example: 22˚ > > In this example the X and Y of the point are: > > inX_D=577 > inY_D=276 > > $text_svgRef:=SVG_New_textArea > ($domSvg_ptr->;$display_t;$inX_D;$inY_D;$width;$height;$fontName;$fontSize_D;$fontStyle_D;$fontAlign_D) > SVG_SET_ATTRIBUTES ($text_svgRef;"display-align";"center") > SVG_SET_ATTRIBUTES ($text_svgRef;"text-align";"center”) > > First issue I noticed was the degree symbol (˚) {ctrl+k} is missing. > Although the correct string is in the xml. > > <textArea display-align="center" fill="#000000" font-family="Tahoma" > font-size="14" font-style="normal" font-weight="normal" height="-13" > stroke="#000000" text-align="center" text-decoration="none" width="-28" > x="577" y="276">16˚</textAre> > > First notice that the Y value remains at 276??? > > I thought it must be an encoding issue. So I tried different characters and > none of them are being displayed. > > Then I thought what if the width or height is not large enough to allow it to > display? By playing with the width I could see all the characters are there. > BUT I cannot reliably get the text centered on the point. > > So then I removed the following two lines: > > SVG_SET_ATTRIBUTES ($text_svgRef;"display-align";"center") > SVG_SET_ATTRIBUTES ($text_svgRef;"text-align";"center”) > > And the values are exactly the same. So this code has not affect therefore I > must not be setting the attributes correctly. > > Any idea as to what I am doing wrong? > > Appreciate, > John... > >> HI Miyako, >> >> Thanks for the info. >> >>> Ref: have you considered using <TextArea> instead of <text>? >> >> I haven’t but I will now. <grin> >> >> I’ll see if there’s a difference. >> >> Thanks for tips. >> >> John… >> >> >>> in general, it is best to instruct the rendering engine to decide how to >>> align objects, >>> rather than to compute the exact coordinates yourself. >>> >>> "text-anchor" (start, middle, end) should take care of horizontal align in >>> <text>, >>> but vertical align is going to be difficult since 4D does not support >>> "dominant-baseline" or "alignment-baseline". >>> if you decide to go down the "y" or "dy" route, well, I guess it's going to >>> be an uphill struggle. >>> >>> have you considered using <TextArea> instead of <text>? >>> >>> you have "display-align" (before, center, after) for vertical align and >>> "text-align" (start, center, end) for horizontal align. >>> >>> p.s. >>> >>> I love how they say start/end, before/after instead of left/right (because >>> of right to left scripts) >>> and decisively use middle instead of center with respect to the subject >>> (align or anchor)... >> > ********************************************************************** 4D Internet Users Group (4D iNUG) FAQ: http://lists.4d.com/faqnug.html Archive: http://lists.4d.com/archives.html Options: http://lists.4d.com/mailman/options/4d_tech Unsub: mailto:4d_tech-unsubscr...@lists.4d.com **********************************************************************