Guidebook icon indicating copy to clipboard operation
Guidebook copied to clipboard

[Suggestion] Justification

Open Klebestreifen opened this issue 6 years ago • 2 comments

Justify alignments look very neat. Therefore, I would like to have such a feature.

Klebestreifen avatar Sep 06 '19 14:09 Klebestreifen

Justified text is very hard, but I will keep the request in mind.

gigaherz avatar Sep 06 '19 14:09 gigaherz

Let

W be the list of words for a line l(x) be the length in pixels of a word or list of words x c(x) the number of elements in the list x L be the length of the line X be the draw position, starting at 0

  1. Draw W0 at X
  2. Increment X by l(W0)
  3. Remove W0 from W
  4. Calculate S as round((L - X - l(W)) / C(W))
  5. Increment X by S
  6. Draw W0 X
  7. Increment X by l(W0)
  8. Remove W0 from W
  9. repeat from 4 unless W is empty

Yes, this has a certain bias to one side depending on the rounding function used, the alternative is to calculate the word distance once and then keep a record of the rounding error.

HenryLoenwind avatar Sep 06 '19 18:09 HenryLoenwind