Burro

Bug fixes & layout bug

Weekly progress update since 2023-08-31 • 2023-09-07Michael Rees


Bug fixes

This week has seen fixes for two long-standing bugs:

  • #21: Letter spacing can push words into margin when ragged left
  • #30: Tab numbers can be repeated in tab lists

Fixing the outstanding bugs on the tracker is an important part of the polish for the 0.1 release, so getting these crossed off was a good first step!

Layout bug

Unfortunately, while testing the fix for #21, I found a major bug in the layout algorithm. It's a little tricky to explain, but here's a demonstration:

.start
.align[right]
Here we will change .letter_space[+3pt] the letter spacing .letter_space[-] mid-line.

I've chosen .letter_space here to show the problem, but many other mid-line style changes would cause the same problem.

This currently does not compile but causes a crash. However, even with that crash fixed, the output is not as expected. This is because of the way the layout algorithm works. Burro moves word by word and assigns a position for each word. When it encounters the .letter_space command, it "emits" the words it's already seen onto the page, fixing them in place with the original settings before changing the letter spacing.

When we're starting from the left margin, this works as intended. However, when right aligned, emitting those words causes them to be too far to the right, because the cursor was moving further to the left with every word emitted. The internal representation of the word positions at the time of the .letter_space command looks something like this (the ASCII art depicts the page margins):

    _______________________________________
    |                                     |
    |                                     |
    |                 Here we will change |
    |                                     |
    |                                     |

But if we emit these words as soon as we hit the .letter_space command, then those words are clearly too far to the right. Instead, we'd expect the words to be further to the left while the text continues along the same line.

Fixing this will be a pretty major undertaking, but it does need to be done before the 0.1 release. The solution will be to wait until a line is completely finished before cementing any words, while finding a different way to track the style settings for each word so that their complete context can be used to calculate their positions when putting them on the page.

Have a comment or want to start a discussion? Please email it to the Burro discussion list!