Developers: Matching Word's line spacing

Request For Enhancement, User feedback candidates for wiki

Developers: Matching Word's line spacing

Postby nbellowe » Thu Aug 25, 2016 12:30 am

Hello there! I'm not sure where developers familiar with the codebase talk, I'm hoping that this forum is the right place, but I'm not sure of which board. You guys likely have a ton of experience in what I'm banging my head against, and we work on totally different products!

I have been running into an issue that I know the developers of openOffice have likely faced before! I was wondering if the developers that have worked on this before would like to talk some about this, I'd really appreciate it

Basically, I have some questions on how to calculate the line spacing between lines in a Docx file.

My requirement is to exactly match Word, not necessarily the OOXML spec, in the spacing between lines in a simple paragraph.

In order to try to do this, I have built a tool to analyze the differences between my layout and Word's layout. To do so it does the following:

- First it generates a (or many) docx files.
- Next it creates pdfs from the docx files. It uses Word to render the docx to PDF, and my program to render the docx to PDF. "word.pdf", and "me.pdf"
- Then it analyzes the resulting PDFs for differences in layout.

So, my tool would say:

- Create a document "template.docx" with 1000 "a" characters in a single run of text with the same properties.
- Make a "word.pdf" and "me.pdf" from this docx
- Calculate info from the pdfs, in particular, calculating the line spacing in terms of the calculated leading between a lines ascent and the previous lines descent (our (Ascent + Descent) are identical-ish, so all that differs is the whitespace between lines). I often think of it as the lines whitespace...

This tool showed me that the leading varies greatly from font to font.

To depict this, I used the tool to make thousands of these comparisons, in particular generating for:

- For each font in system
- For "a", "y", and a mix of letters and spaces.
- For different font sizes.
- For different line spacing types (Single, One and a half, and Double)

I was hoping to find groupings, such as "this type of font has 1.3 times my calculation of leading".

I was able to conclude far less than I had hoped, and was wondering if you could help me further with the issue of calculating line spacing. I'm providing you with a file that is best downloaded and opened in Excel while using the filters in the header row. Note that its not totally complete, there are missing entries, but I doubt they will be a problem for anyone, and I'm going to regenerate it soon but its pretty slow, so I'm finishing up some changes to it first.

Here is a comparison of the layout of our software, vs the layout of Word's for every font installed on my system, etc.

I'm not positive, but I believe the issue could be one of the following:

- Word is using a different process than we are to calculate the "leading" of a font. We don't parse the font files ourselves, instead rely on libraries to get font sizing information, and perhaps in the "world of font files" I am missing something, and word is parsing the fonts directly and differently.
- Word has some sort of lookup table that handles groups of fonts, or an algorithm, that scales a fonts leadings up or down based on some criteria I am unaware of.
- Word is using an additional criteria besides leading, ascent, and descent, to determine line spacing.

Please feel free to email me at

Thank you so much for your time!!
OpenOffice 3.4
Posts: 3
Joined: Thu Aug 25, 2016 12:18 am

Re: Developers: Matching Word's line spacing

Postby RusselB » Thu Aug 25, 2016 1:27 am

I'm sorry to have to tell you that few, if any, of the developers actually visit these forums,
I'm going to recommend that you check/use the Developer's Mailing List
OpenOffice 4.1.7 and LibreOffice on Windows 7 Pro & Ultimate
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
User avatar
Posts: 6104
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: Developers: Matching Word's line spacing

Postby RoryOF » Thu Aug 25, 2016 5:32 am

The best information I know on line spacing in OpenOffice is Bruce Byfield's article at

I have no interest in reinventing Word - if Word suits your needs, use it. When I need an exact match for existing text - I'm currently printing a patch to fit a hole in a book being repaired - it is best done on an ad hoc basis.
Apache OpenOffice 4.1.7 on Xubuntu 20.04.1 (mostly 64 bit version) and very infrequently on Win2K/XP
User avatar
Posts: 31403
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Developers: Matching Word's line spacing

Postby nbellowe » Fri Aug 26, 2016 5:11 am

Thanks so much!

I will definitely contact the developers list you pointed out, and am reading that article.

We actually are not working on emulating Word itself, but we must match how they render it, as our files are created with an add-in for Word.

Thanks so much
OpenOffice 3.4
Posts: 3
Joined: Thu Aug 25, 2016 12:18 am

Return to User Experience (UX)

Who is online

Users browsing this forum: No registered users and 1 guest