johnwhitington / camlpdf

OCaml library for reading, writing and modifying PDF files
Other
200 stars 29 forks source link

Why simple fonts does not load widths #61

Closed RudolfVonKrugstein closed 1 year ago

RudolfVonKrugstein commented 1 year ago

I am trying to get to the character widths for a SimpleFont.

Looking at the code here: https://github.com/johnwhitington/camlpdf/blob/master/pdftext.ml#L432 When loading a simple font, firstchar, lastchar and widths are all initilized to 0 (or empty list).

What is the reason for that? What is the point of having the firstchar, lastchar and widths members of the simple font if they are not read anyway?

johnwhitington commented 1 year ago

It looks like the widths can be read directly from the fontmetrics entry.

The firstchar, lastchar and widths entries are used when writing a font.

This part of the code was written about fifteen years ago, and I couldn't tell you why now.

RudolfVonKrugstein commented 1 year ago

Ah, ok, fair enough :).

Thank you for the information and thank you for camlpdf!