Report Manager
ENES

← All articles

Why does the report come out misaligned when a Linux server generates it?

· Toni Martir, arquitecto de software

Every night a server turns the month's invoice listing into a PDF and emails it to each sales rep. On the Windows PC where it was designed, the report is perfect: one customer per line, the amounts lined up. From a Linux server it arrives with names cut off, amounts split over two lines and an extra page. Nobody has touched the report or the database.

What has changed is the font: the report asks for Arial or Calibri, the server lacks it and writes with a wider one. It can be fixed without redesigning anything, though the obvious fix, copying the Windows font onto the server, is forbidden.

The server swaps the font without telling you

Arial, Calibri and Times New Roman are Microsoft fonts. Arial's page says it is «exclusively included» with Microsoft products and services. A Linux server does not come with it.

When a Linux program asks for a missing font, fontconfig, the part of Linux that chooses fonts, picks a replacement. Its documentation says it takes the closest match among those installed: «a font will always be returned», with no guarantee that «it is anything like» the one requested. The PDF still comes out, with no error and no warning.

I tried it with only the DejaVu family installed, the first that Debian's fontconfig package asks for: Arial and Calibri turn into DejaVu Sans, and Times New Roman into DejaVu Serif.

A few millimetres per line

A report puts each item in a box of fixed size, measured for its font. At 9 points, «Thames Valley Office Supplies Limited» takes up 54 millimetres in Arial and 61 in DejaVu Sans: in a 55-millimetre column it no longer fits. Depending on the box, the text is cut off, runs into the next column, or wraps onto a second line and pushes everything below it down, until the listing needs another page.

The font the report asks for, and the one the server uses

Arial With no replacement installed, the server uses DejaVu Sans
DejaVu Sans: 11–14% wider Liberation Sans: same width
Calibri With no replacement installed, the server uses DejaVu Sans
DejaVu Sans: 23–26% wider Carlito: same width
Times New Roman With no replacement installed, the server uses DejaVu Serif
DejaVu Serif: 25–27% wider Liberation Serif: same width
Courier New With no replacement installed, the server uses DejaVu Sans Mono
DejaVu Sans Mono: 0.3% wider Liberation Mono: same width

Measured on Ubuntu 26.04 with five pieces of invoice text: two customer names, an amount, a delivery note number and a label. The Microsoft fonts were measured through their replacements, which take up the same space. Courier New barely changes because in both fonts every letter has the same width.

Copying the Windows font is not allowed

Microsoft's font redistribution FAQ is clear: apart from embedding them in a document, you may not copy the Windows fonts «to other computers or servers». The right to install the original on a server is sold separately; for many of them, Microsoft points to Monotype.

The practical route is a replacement with the same widths, letter by letter. The Liberation fonts are made to measure the same as Arial, Times New Roman and Courier New, and Carlito the same as Calibri. The letters look slightly different; their widths stay the same. Both families come under the SIL Open Font License, which lets you use them, embed them in a PDF and redistribute them without paying, with conditions such as not selling them on their own.

The report stays as it is: fontconfig already lists those pairs in its table of equivalent families and picks the replacement by itself once it is installed. If the program generating the PDFs relies on fontconfig, fc-match Arial tells you which font the server will use. If it answers DejaVu Sans, expect a misaligned report.

So why does it come out misaligned?

Because the server lacks the font the report was designed with, and quietly writes with another that does not measure the same. The fix is to give the server a font with the same widths: the original, by buying the right to install it on a server, or an openly licensed replacement such as Liberation or Carlito.


Reportman Server, Report Manager's server in Docker, already carries replacements with the same widths as Arial, Times New Roman, Courier New, Arial Narrow, Calibri and Cambria, takes your own fonts in its fuentes/ folder and shows which fonts the engine sees under Server → Diagnostics → Fonts. With printreptopdf, the web report server or your own application built on the engine, you install the replacements on the server and the engine picks them through fontconfig.

Sources

Toni Martir, arquitecto de software · · sources checked on