caitlinsalt / simple-timetable-editor

An editor for creating timetables for simple railway networks
MIT License
0 stars 1 forks source link

Unicorn font spacing #240

Closed caitlinsalt closed 4 years ago

caitlinsalt commented 4 years ago

The font spacing of a timetable export using Unicorn.Writer is noticably tighter than using PdfSharp. Noticeably, the text of some location rows appears to hit lines above them.

caitlinsalt commented 4 years ago

This is likely because the PdfSharp implementation included a scaling factor to adjust the ascent and descent of the font, so that IFontDescriptor.Ascent and IFontDescriptor.Descent became "effective" figures which measured the distance from the baseline to the top and bottom of the "line matrix". This was arrived at more by luck than judgement, because at that time I didn't understand the precise definitions of some of the font metrics fields.

To solve this, IFontDescriptor could include a "zero leading spacing" property which gives the difference between the total height of a character cell (ie Ascent - Descent) and the vertical pitch of the font with zero leading (which should be equal to the point size). Consumers can then decide to base their padding off this figure. Once this has been done, remove the hackish scaling of the ascent and descent in the PdfSharp version of Unicorn.