Index ¦ Archives ¦ RSS

Writer line heights: removing a 16bit limit

Estimated read time: 2 minutes

Line heights in Writer are typically defined in points on the UI (e.g. 12pt), though they are measured in twips internally (1 point is 20 twips). This height was stored in a 16bit unsigned integer, so the maximum allowed height was 65536 twips, around 116 cm.

Now we track line heights with 32 bits ints, so this limitation is practically removed.

First, thanks Vector who made this work by Collabora possible.


Once you insert an image to a Writer document, you can customize its anchor type. The as-char anchor type is handy if you don’t want text to flow around the image. This has the side effect that a large image significantly increases the nominal height of a line. The problematic document had an image height of 118.9 cm (46.81 inch), so the unsigned integer used to represent its height wrapped around, leading to an incorrect layout.

Results so far

Now it looks like the way you would expect it:
Figure 1. Writer as-char image with height that is larger than 65k twips

How is this implemented?

If you would like to know a bit more about how this works, continue reading… :-)

As usual, the end goal was reached via a set of incremental commits:

Want to start using this?

Collabora intends to continue supporting and contributing to LibreOffice, the code is merged so we expect all of this work will be available in TDF’s next release (7.2).

© Miklos Vajna. Built using Pelican. Theme by Giulio Fidente on github.