Guidebook

Guidebook

6M Downloads

[Suggestion] Justification

Klebestreifen opened this issue ยท 2 comments

commented

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

commented

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

commented

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.