go-text / typesetting

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

Proposal: Direction attribute for text progression #14

Closed whereswaldon closed 2 years ago

whereswaldon commented 2 years ago

The four Directions defined in di have two attributes:

There are many times when it would be convenient to define an operation based on this second property, as it would allow LTR and TTB to share an implementation of an algorithm, and would likewise allow sharing between RTL and BTT.

I'd like to add something like the Axis method to di.Direction to return this attribute, but I honestly have no idea what to call this property.

Do you think this makes sense and is a good idea? Is there already a typographical name for this aspect of text direction?

benoitkugler commented 2 years ago

Harbuzz uses the HB_DIRECTION_IS_BACKWARD (right to left, bottom to top) and HB_DIRECTION_IS_FORWARD macros.

whereswaldon commented 2 years ago

I thought about terms like "Backward" and "Forward", but they carry connotations in English that I don't like. In particular, saying something is "backwards" generally means it is bad, old, incorrect, and/or outdated. It doesn't quite sit right with me to apply that word to all RTL and BTT writing systems. Perhaps I'm being overly pedantic.

What would you think about Progression as the name for this concept, with possible values TowardOrigin and FromOrigin? We can document that in this case, the "origin" is referring to the upper-left corner of the content. Or we could call them TowardUpperLeft and FromUpperLeft?

benoitkugler commented 2 years ago

I like the world Progression, and I prefer {Toward, From}Origin over {Toward, From}UpperLeft (with the documentation)

andydotxyz commented 2 years ago

I commented on the PR instead of here, sorry. Is the origin fixed (top left)? I would understand the origin of a RTL doc to be top right - so when the text matches the default for the document it is always "from origin" so the revised naming seems to change interpretation.

whereswaldon commented 2 years ago

When using the term "origin", I was thinking of the origin of the window canvas. However, I see the argument that it's ambiguous (other than the fact that it's documented to be the upper left). Do you have an alternative naming scheme that you prefer?

benoitkugler commented 2 years ago

So maybe {Toward, From}UpperLeft are better names after all ?

andydotxyz commented 2 years ago

That is clearer, or we could use CanvasOrigin?

whereswaldon commented 2 years ago

I worry that (without my knowledge) it may be conventional to start the origin of canvases in RTL applications in the upper right. I'm now thinking that we should just be explicit with UpperLeft.

andydotxyz commented 2 years ago

Good point, I agree. Though maybe TopLeft matches better with LTR and TTB naming?