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

No clear centroid available #2

Open
BenjaminDRichards opened this issue Dec 21, 2015 · 0 comments
Open

No clear centroid available #2

BenjaminDRichards opened this issue Dec 21, 2015 · 0 comments
Assignees

Comments

@BenjaminDRichards
Copy link
Contributor

Text objects can be horizontally aligned via alignment="center", but vertical alignment turns out to be a lot trickier.

Measuring the height property gives some information, but this already contains several assumptions. An extra line may have been inserted during height calculations, to give room for descending text elements. The size of this line is in turn computed from current font size and line separation settings. To get an accurate compensation for these factors basically requires rewriting a whole chunk of renderText out in user code.

That's not optimal. I'd rather have that information available on the text object itself, where it can be computed once.

I can see three ways of exposing this information:

  • Implement a vertical alignment similar to the extant alignment property, so the object will automatically line itself up as desired. Issue: We already have an alignment property, so some semantic contortions may be required.
  • Push alignment information into the anchorPoint data. Issue: This data is user-accessible, so it might be overwritten and become irretrievable. Issue: If the user configures their own anchorPoint data, calling renderText (or changing text properties, which invokes the method) will overwrite that data.
  • Provide vertical centroid data as a unique property on the object. Issue: This is not standard, and might not be immediately recognised by users. Issue: This still requires users to implement their own positioning solutions.

The vertical alignment solution does sound most optimal at this stage.

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

1 participant