michaelk Posted May 2, 2020 Share Posted May 2, 2020 I think I found a bug in TextVerticalAlign. Or I don't understand something. Or both! Can someone double check this for me? When I run the attached script I get 5 text objects in 5 different Text Styles with the following problems: 1. The Vertical Top Baseline text style actually is bottom baseline. 2. Although all of the X coordinates are exactly what you would expect, ONLY the Vertical Bottom Baseline Text Style has the correct Y coordinate. Thanks! Procedure Test; CONST kVTopTextStyle = 'V Top Text Style'; kVTopBaselineTextStyle = 'V Top Baseline Text Style'; kVCenterlineTextStyle = 'V Centerline Text Style'; kVBottomBaselineTextStyle = 'V Bottom Baseline Text Style'; kVBottomTextStyle = 'V Bottom Text Style'; kString = 'This is Text Style: '; VAR h : HANDLE; s : STRING; BEGIN {Create 5 Text Styles. All Left Justified with the same font, font size, and face.} TextFont(GetFontID('Arial')); TextFace([Bold]); TextSize(24); TextJust(1); TextVerticalAlign(1); {Vert Top Aligned TextVerticalAlign(1)} h:=CreateTextStyleRes(kVTopTextStyle); TextFont(GetFontID('Arial')); TextFace([Bold]); TextSize(24); TextJust(1); TextVerticalAlign(2); {Vert Top Baseline Aligned TextVerticalAlign(2)}{I think this one has a bug} h:=CreateTextStyleRes(kVTopBaselineTextStyle); TextFont(GetFontID('Arial')); TextFace([Bold]); TextSize(24); TextJust(1); TextVerticalAlign(3); {Vert Center Aligned TextVerticalAlign(3)} h:=CreateTextStyleRes(kVCenterlineTextStyle); TextFont(GetFontID('Arial')); TextFace([Bold]); TextSize(24); TextJust(1); TextVerticalAlign(4); {Vert Bottom Baseline Aligned TextVerticalAlign(4)} h:=CreateTextStyleRes(kVBottomBaselineTextStyle); TextFont(GetFontID('Arial')); TextFace([Bold]); TextSize(24); TextJust(1); TextVerticalAlign(5); {Vert Bottom Aligned TextVerticalAlign(5)} h:=CreateTextStyleRes(kVBottomTextStyle); {Insert 5 text objects, one in each Text Style. Each with a y coordinate of 0. In my test ONLY the VBottom actually has 0 Y coordinate} MoveTo(0",0"); BeginText; Concat(kString,kVTopTextStyle) EndText; SetTextStyleRef(LNewObj,Name2Index(kVTopTextStyle)); MoveTo(40',0"); BeginText; Concat(kString,kVTopBaselineTextStyle) EndText; SetTextStyleRef(LNewObj,Name2Index(kVTopBaselineTextStyle)); MoveTo(80',0"); BeginText; Concat(kString,kVCenterlineTextStyle) EndText; SetTextStyleRef(LNewObj,Name2Index(kVCenterlineTextStyle)); MoveTo(120',0"); BeginText; Concat(kString,kVBottomBaselineTextStyle) EndText; SetTextStyleRef(LNewObj,Name2Index(kVBottomBaselineTextStyle)); MoveTo(160',0"); BeginText; Concat(kString,kVBottomTextStyle) EndText; SetTextStyleRef(LNewObj,Name2Index(kVBottomTextStyle)); END; RUN(Test); Possible Text Vert Align Bug.vwx Quote Link to comment
SCParker Posted May 2, 2020 Share Posted May 2, 2020 While I have very limited experience with scripting, when I create a Top Baseline line type manually, the loci appears at the same spot as the one your script creates. So, I'd say it's an issue with the Top Baseline rather than your script. This is assuming one expects the loco to align somewhere near the top of the letters. Best, Scott Quote Link to comment
michaelk Posted May 2, 2020 Author Share Posted May 2, 2020 Hi Scott I think you're right about Top Baseline. I think that's a bug and it doesn't matter if you set the baseline with a script or in the OIP. I think the insertion points of text objects honoring the X coordinate and not the Y is either (i) a bug in the TextVerticalAlign function or (ii) a gap in my understanding of how the function works. 50/50 chance. Quote Link to comment
MullinRJ Posted May 2, 2020 Share Posted May 2, 2020 (edited) Michael, You are seeing the effects of SetTextVerticalAlign() vs SetTextVertAlignN(). My guess is you want SetTextStyleRef() to use the former and SetTextStyleRef() is using the latter, so the text does not move when you apply a TextStyle, but the text insertion point does move, as it is supposed to. You would be better off not using Text Styles and forcing the attributes you want manually. Raymond Edited May 2, 2020 by MullinRJ Quote Link to comment
michaelk Posted May 2, 2020 Author Share Posted May 2, 2020 My understanding - dangerous territory here - is that SetTextVerticalAlign() and SetTextVertAlignN() set the alignment of text objects already created. I'm using TextVerticalAlign to set the default alignment, then create a Text Style. I was assuming that the text alignment would control the insertion point. Maybe not. Maybe MoveTo(x,y); BeginText 'Hello World' EndText; will always insert the text with the bottom left corner of the text object at x,y. I'll have to test for that. If I were the only one who was going to use this little plug-in, you're correct - I would make it graphically perfect and leave it alone. But that's not what's happening. My hope was to make a tool with 4 text objects. Each text object could have different settings. My plan was to use text styles to manage the fonts, styles, size, etc. That seems to be working. It's just when I go to place the objects I'm getting surprising Y values. I'm pretty certain that the top baseline showing as bottom baseline is a bug. And the fact that the X values are correct but not the Y values makes me suspect something weird is happening. But it could just be that's how it works. Makes more sense now that I think about it. I'm creating the text and then applying the text style justification. So I either need to set the default justification before creating the text or move it after creation. Quote Link to comment
michaelk Posted May 2, 2020 Author Share Posted May 2, 2020 And just when I convinced myself I knew what was happening. I just modified the above script. Change all the TextJust(1) to TextJust(3). All the text objects inserted with the MoveTo(x,y) X values correct on the right side of the text object but with the Y values incorrect. Back to being confused. Quote Link to comment
michaelk Posted May 2, 2020 Author Share Posted May 2, 2020 I should have a 5 minute delay on posts when I'm trying to write VS. All the text objects are inserting using the default text justification. That's clear now. The only bug is the top baseline showing up as the bottom baseline. Quote Link to comment
michaelk Posted May 2, 2020 Author Share Posted May 2, 2020 Just to stick a fork in this one. I think this script demonstrates (i) that it takes me a few hours of banging my head against a script longer than it seems like it should and (ii) there is a bug in the top baseline vertical alignment actually appearing to be bottom baseline. I don't think that it's the TextVerticalAlign function. It misbehaves when just changing the vertical alignment in the OIP of a text object. Final score: There is a bug AND I didn't understand what was happening. Procedure Test; CONST kVTopTextStyle = 'V Top Text Style'; kVTopBaselineTextStyle = 'V Top Baseline Text Style'; kVCenterlineTextStyle = 'V Centerline Text Style'; kVBottomBaselineTextStyle = 'V Bottom Baseline Text Style'; kVBottomTextStyle = 'V Bottom Text Style'; kString = 'This is Text Style: '; VAR h : HANDLE; s : STRING; BEGIN {Create 5 Text Styles. All Left Justified with the same font, font size, and face.} TextFont(GetFontID('Arial')); TextFace([Bold]); TextSize(24); TextJust(1); TextVerticalAlign(1); {Vert Top Aligned TextVerticalAlign(1)} h:=CreateTextStyleRes(kVTopTextStyle); MoveTo(0",0"); BeginText; Concat(kString,kVTopTextStyle) EndText; SetTextStyleRef(LNewObj,Name2Index(kVTopTextStyle)); {********************} TextFont(GetFontID('Arial')); TextFace([Bold]); TextSize(24); TextJust(2); TextVerticalAlign(2); {Vert Top Baseline Aligned TextVerticalAlign(2)}{I think this one has a bug} h:=CreateTextStyleRes(kVTopBaselineTextStyle); MoveTo(40',0"); BeginText; Concat(kString,kVTopBaselineTextStyle) EndText; SetTextStyleRef(LNewObj,Name2Index(kVTopBaselineTextStyle)); {********************} TextFont(GetFontID('Arial')); TextFace([Bold]); TextSize(24); TextJust(3); TextVerticalAlign(3); {Vert Center Aligned TextVerticalAlign(3)} h:=CreateTextStyleRes(kVCenterlineTextStyle); MoveTo(80',0"); BeginText; Concat(kString,kVCenterlineTextStyle) EndText; SetTextStyleRef(LNewObj,Name2Index(kVCenterlineTextStyle)); {********************} TextFont(GetFontID('Arial')); TextFace([Bold]); TextSize(24); TextJust(1); TextVerticalAlign(4); {Vert Bottom Baseline Aligned TextVerticalAlign(4)} h:=CreateTextStyleRes(kVBottomBaselineTextStyle); MoveTo(120',0"); BeginText; Concat(kString,kVBottomBaselineTextStyle) EndText; SetTextStyleRef(LNewObj,Name2Index(kVBottomBaselineTextStyle)); {********************} TextFont(GetFontID('Arial')); TextFace([Bold]); TextSize(24); TextJust(2); TextVerticalAlign(5); {Vert Bottom Aligned TextVerticalAlign(5)} h:=CreateTextStyleRes(kVBottomTextStyle); MoveTo(160',0"); BeginText; Concat(kString,kVBottomTextStyle) EndText; SetTextStyleRef(LNewObj,Name2Index(kVBottomTextStyle)); END; RUN(Test); Quote Link to comment
MullinRJ Posted May 3, 2020 Share Posted May 3, 2020 Michael, 6 hours ago, michaelk said: My understanding - dangerous territory here - is that SetTextVerticalAlign() and SetTextVertAlignN() set the alignment of text objects already created. You are right, but the point I was trying to make is that when you apply a TextStyle, there are two ways to do it – 1) keep the insertion point fixed and move the text block relative to the insertion point (as is done with SetTextVerticalAlign), or 2) keep the text block fixed and move the insertion point relative to the text block (as is done with SetTextVertAlignN). VW uses the latter method of adjusting the Vertical Alignment when a TextStyle is applied. You were probably expecting it to use the first method. I believe your confusion exists because your example does not show enough detail to see what is really happening with the vertical alignment settings. SetTextVerticalAlign() and SetTextVertAlignN() both work perfectly, but you need more than one line of text to show the difference between "Top Baseline" and "Bottom Baseline" settings. When there is only one line of text, the TOP and BOTTOM Baselines (of the text block) are the same, since the ONE line of text is both the TOP LINE, and the BOTTOM LINE. With two or more lines in a text block, the TOP and BOTTOM Baselines are different. The following example should show the difference. I modified your second code example to create multiple (2) lines of text, not one. Now when the Vertical Alignment is set you should see a difference for all five vertical alignment values. Forgive me if I removed too many blank lines. Procedure Test; CONST kVTopTextStyle = 'V Top Text Style'; kVTopBaselineTextStyle = 'V Top Baseline Text Style'; kVCenterlineTextStyle = 'V Centerline Text Style'; kVBottomBaselineTextStyle = 'V Bottom Baseline Text Style'; kVBottomTextStyle = 'V Bottom Text Style'; kString = 'Text Style: '; CR = chr(13); VAR h : HANDLE; s : STRING; BEGIN { Create 5 Text Styles. All Left Justified with the same font, font size, and face. } TextFont(GetFontID('Arial')); TextFace([Bold]); TextSize(24); TextJust(1); TextVerticalAlign(1); { Vert Top Aligned TextVerticalAlign(1) } h := CreateTextStyleRes(kVTopTextStyle); MoveTo(0, 0); BeginText; Concat(kString, CR, kVTopTextStyle) EndText; SetTextStyleRef(LNewObj, Name2Index(kVTopTextStyle)); { ******************** } TextFont(GetFontID('Arial')); TextFace([Bold]); TextSize(24); TextJust(2); TextVerticalAlign(2); { Vert Top Baseline Aligned TextVerticalAlign(2) }{ I think this one has a bug } h := CreateTextStyleRes(kVTopBaselineTextStyle); MoveTo(40', 0"); BeginText; Concat(kString, CR, kVTopBaselineTextStyle) EndText; SetTextStyleRef(LNewObj, Name2Index(kVTopBaselineTextStyle)); { ******************** } TextFont(GetFontID('Arial')); TextFace([Bold]); TextSize(24); TextJust(3); TextVerticalAlign(3); { Vert Center Aligned TextVerticalAlign(3) } h := CreateTextStyleRes(kVCenterlineTextStyle); MoveTo(80', 0"); BeginText; Concat(kString, CR, kVCenterlineTextStyle) EndText; SetTextStyleRef(LNewObj, Name2Index(kVCenterlineTextStyle)); { ******************** } TextFont(GetFontID('Arial')); TextFace([Bold]); TextSize(24); TextJust(1); TextVerticalAlign(4); { Vert Bottom Baseline Aligned TextVerticalAlign(4) } h := CreateTextStyleRes(kVBottomBaselineTextStyle); MoveTo(120', 0"); BeginText; Concat(kString, CR, kVBottomBaselineTextStyle) EndText; SetTextStyleRef(LNewObj, Name2Index(kVBottomBaselineTextStyle)); { ******************** } TextFont(GetFontID('Arial')); TextFace([Bold]); TextSize(24); TextJust(2); TextVerticalAlign(5); { Vert Bottom Aligned TextVerticalAlign(5) } h := CreateTextStyleRes(kVBottomTextStyle); MoveTo(160', 0"); BeginText; Concat(kString, CR, kVBottomTextStyle) EndText; SetTextStyleRef(LNewObj, Name2Index(kVBottomTextStyle)); END; RUN(Test); HTH, Raymond Quote Link to comment
michaelk Posted May 3, 2020 Author Share Posted May 3, 2020 I'm slow, but eventually I get it :-). In your example the bug still exists. The second text object using SetTextJust(2); - which should have the insertion point at the top of the top line - instead has the insertion point at the bottom of the first line. I get now why the text objects were inserting where they were. It was using the last document alignment settings before the BeginText function. Seems obvious now. Meanwhile, I've found two methods of wrangling wayward path objects. Neither one satisfactory. Fun day! Quote Link to comment
MullinRJ Posted May 3, 2020 Share Posted May 3, 2020 10 hours ago, michaelk said: In your example the bug still exists. The second text object using SetTextJust(2); - which should have the insertion point at the top of the top line - instead has the insertion point at the bottom of the first line. Hi Michael, In the second text object of my example, which is derived from your example, I/you use: TextJust(2); TextVerticalAlign(2); { Vert Top Baseline Aligned TextVerticalAlign(2) }{ I think this one has a bug } which translates to CENTERED, and TOP BASELINE. That is exactly where the text is getting inserted. Are you not seeing this? The line in the picture is at Y=0. Raymond Quote Link to comment
michaelk Posted May 4, 2020 Author Share Posted May 4, 2020 Wow. It's amazing. Take a break for a couple hours. Get a good night's sleep. Take a walk on the beach. Eat a nice breakfast. Have good strong cup of tea… … and suddenly you can see clearly! You are correct! Thanks, Raymond. Quote Link to comment
MullinRJ Posted May 4, 2020 Share Posted May 4, 2020 Wow. I didn't really sleep all that well, or walk on the beach, or have breakfast (nice or otherwise). And what cup of tea? Glad your vision is clearing. 8-) All the best, Raymond 1 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.