Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several x.text angle and size problems problems #1077

Closed
jypeter opened this issue Feb 25, 2015 · 9 comments
Closed

Several x.text angle and size problems problems #1077

jypeter opened this issue Feb 25, 2015 · 9 comments
Milestone

Comments

@jypeter
Copy link
Member

jypeter commented Feb 25, 2015

I have found several serious problems when experimenting with x.text, that can be reproduced with the following simple script

import vcs
x = vcs.init()

x.text('String plotted with "y.text(''This string'',.05,.5,color=241,angle=0)"',.05,.5,color=241,angle=0)

x.text('Testing the text angle with +45.....',.5,.5,color=242,angle=45)

x.text('Testing the text angle with -45.....',.5,.5,color=243,angle=-45)

x.png('text_angle_sign_pb')
x.pdf('text_angle_sign_pb')

Note: @chaosphere2112 can add this example or a variation of it to the Gallery, once the angles are OK (http://uvcdat.llnl.gov/gallery.php?primitive=text)

@alliepiper
Copy link
Contributor

Several of the PDF issues are due to limitation is the PDF specification (believe it or not, PDF doesn't support text alignment flags, etc). This has been addressed in master by exporting all text as a set of bezier curves rather than text tags, as this will ensure equivalent output on-screen, in png, and in the vector backends.

Rotation direction is a matter of convention and differs across toolkits and domains. VTK uses the "positive = CCW" (as the trigonometry is more straightforward), but vcs appears to do the opposite when constructing the VTK text properties: p.SetOrientation(-to.angle). The VCS manual doesn't seem to specify their convention -- it specifies that "angel" (a typo?) is just an int between 0 and 360, though it seems to also accept negative angles as well from your example code.

The text size is a mystery to me. The manual specifies that text "height" is an integer between 1 and 100. I have no idea what units. @doutriaux1 wrote the bit that converts the VCS height to a fontsize in vcs2vtk.prepTextProperty -- perhaps a scale factor or similar needs tweaking?

In short -- The PDF issues are (hopefully) fixed once and for all in master. Vector exported text should be identical to what is shown on screen, as it is now explicitly drawn in the exported image (rather than leaving the glyph loading/placement up to the viewer). The absolute text height units and text rotation conventions are documentation concerns for vcs -- @doutriaux1, can you find out what these conventions are supposed to be?

@jypeter Thanks for the very thorough testing and report!

@jypeter
Copy link
Member Author

jypeter commented Feb 25, 2015

  • wow, no text alignment in pdf? I would have supposed that it was a basic requirement... Text as curves seems like an awful overkill. And then forget importing vcs pdf in Illustrator to make some easy text changes
  • The positive = CCW convention is what any sane person who has followed trigo classes will expect, so vcs should not break that. Maybe it's an old vcs bug (since it was already in 1.5.1). Can this be fixed without breaking too many things? I'm happy with not being backward compatible with old scripts if we fix that
  • There is a good chance that the text size is proportional to the canvas size. We have been dealing with canvas coordinates between 0 and 1 since last century and we are probably stuck with this. But I think it's a good thing if the text changes size when the vcs canvas is resized

@chaosphere2112
Copy link
Contributor

Yup, text size is proportional to the height of the window; the ratio currently is text.height * window height / 800, rounded down to an integer.

@durack1
Copy link
Member

durack1 commented Feb 25, 2015

@jypeter @dlonie @chaosphere2112 @doutriaux1 again another related to #503

@alliepiper
Copy link
Contributor

Yes, as complex as the PDF specification is, text support lacks some basic options ;) It's indeed a shame to lose the ability to edit the text directly, though it's simple enough to just replace the path with a new text object in an editor if needed. The path approach also has the advantage of ensuring consistent output across platforms/viewers, which often load different fonts for various face types and can cause some real headaches with alignment.

@jypeter
Copy link
Member Author

jypeter commented Feb 25, 2015

Well, as long as it works and indeed everything is clean and look the same...

Devil is in the details and my end users can sometimes be very picky about some details (change the color, move this over there, align the longitudes differently, etc...). So if I get something right on screen, it's better if I get the same in the output

@doutriaux1 doutriaux1 added the VCS label Feb 25, 2015
@doutriaux1 doutriaux1 added this to the 2.3 milestone Feb 25, 2015
@doutriaux1
Copy link
Contributor

@jypeter the sign of the angle is following XGKS specification I agree it's not ideal but it is to preserve backward compatibilty. We can discuss "breaking" this but I really don't like the idea.

@durack1
Copy link
Member

durack1 commented Feb 25, 2015

@doutriaux1 as the last update to XGKS was in 2000, not sure this is a valid reason this decade, let alone century..

Right now is also an opportune time to break some backward compatibility, as with a significant rewrite comes change no matter how you like it, and it hurts less if it's all in one hit..

@alliepiper
Copy link
Contributor

Closing this, as the issues have been resolved as follows:

  • Angle sign conventions AIUI, these are consistent with previous versions of VCS.
  • Angle/size issues in PDF exports Fixed by exporting all text as bezier paths to work with the PDF feature palette and prevent platform-dependent text issues.

If there are any unresolved problems from this thread, let's create new issues for them so we can more easily keep track of the individual tasks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants