go-text / typesetting

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

Support setting tabs width #174

Open benoitkugler opened 3 hours ago

benoitkugler commented 3 hours ago

I would like to support setting the width of tabs in a run, following the CSS 'tab-size' property.

That could be exposed with the method

// SetTabsWidth alters the run, replacing the width of every tab character (U+0009).
//
// [text] is the input slice used to create the run.
func (*Output) SetTabsWidth(text []rune, spacing fixed.Int26_6)

(At a first glance, the implementation would be somewhat similar to Output.AddWordSpacing)

What do you think ?

andydotxyz commented 3 hours ago

A great idea, however I don't think it is quite that straight forward - I think you also need to have a starting position, because tab alignment is actually relative to the page and not to the first character of a run...