go-text / typesetting

High quality text shaping in pure Go.
Other
88 stars 11 forks source link

di: add text progression types and method #15

Closed whereswaldon closed 2 years ago

whereswaldon commented 2 years ago

This commit introduces a type that represents how a piece of text is read relative to the origin as well as a method to get the progression from any direction.

This information makes it easy to write algorithms that operate on text of only one progression, but across any axis.

Closes #14

Signed-off-by: Chris Waldon christopher.waldon.dev@gmail.com

andydotxyz commented 2 years ago

I'm a little confused here, I am not sure if it relates to naming or purpose. It looks like RTL is always defined as "toward origin" - but in a RTL document the origin is in a different place, so it will be "from origin". So I guess the question is, does this need to take the context of the overall document, or does it need naming change where origin is more specifically top left?

benoitkugler commented 2 years ago

I'm a little confused here, I am not sure if it relates to naming or purpose. It looks like RTL is always defined as "toward origin" - but in a RTL document the origin is in a different place, so it will be "from origin".

Well, following the context of #14, the origin of the (drawing) pen would change, but not the origin of the document.

I think the documentation of the constants FromOrigin and TowardOrigin are rather explicit in this regard.

whereswaldon commented 2 years ago

@benoitkugler @andydotxyz Does this naming work for everyone?

benoitkugler commented 2 years ago

@benoitkugler @andydotxyz Does this naming work for everyone?

I'm happy with it, thanks !

andydotxyz commented 2 years ago

Sorry I missed this, was swamped with other things leading to the holiday. This is much clearer, though reading through it I wondered - should it be "Top" instead of "Upper"? That way it matches the TTB and LTR naming...

whereswaldon commented 2 years ago

I think we have enough consensus on this to merge this version.

andydotxyz commented 2 years ago

I think we have enough consensus on this to merge this version.

Personally I would have waited for @benoitkugler, though I was going to approve the current state anyhow.

whereswaldon commented 2 years ago

I figured that the difference between "Upper" and "Top" was very slim, and an approval for "Upper" probably translated. If @benoitkugler prefers something else, I'm happy to have another PR change it.