Skip to content
Dave Curylo edited this page Feb 7, 2019 · 2 revisions

Welcome to the FsPdf wiki!

For now, just some general notes while working through things.

First off, don't want to create a dependency on GDI or anything else, really. This means that to measure the width of text and lay it out appropriately, we need to read the font metrics. The Adobe Font Metrics for the standard 14 Adobe fonts are freely available, and published in .afm files.

Font Technical Notes: https://www.adobe.com/devnet/font.html Spec: https://www.adobe.com/content/dam/acom/en/devnet/font/pdfs/5004.AFM_Spec.pdf AFM files can be downloaded from the font technical notes.

Amongst other information, an afm file contains the font character width and bounding box. As noted in the spec,

3.2 Units of Measurement All measurements in AFM, AMFM, and ACFM files are given in terms of units equal to 1/1000 of the scale factor (point size) of the font being used. To compute actual sizes in a document (in points; with 72 points = 1 inch), these amounts should be multiplied by (scale factor of font) / 1000.

This means that we can take each character, look it up by character code, find the WX value, multiply by the point size, divide by 1000, and we have the width in points of the printed character. A capital 'A' has WX 667, so at a font size of 12 point, it would be 667 * 12 / 1000 = 8.004 points wide. If we have specified any character spacing, (Tc) then we need to add that many points for each letter. If there is word spacing, then for each word we have to add that as well.

C 59 ; WX 278 ; N semicolon ; B 87 -147 191 516 ;
C 60 ; WX 584 ; N less ; B 48 11 536 495 ;
C 61 ; WX 584 ; N equal ; B 39 115 545 390 ;
C 62 ; WX 584 ; N greater ; B 48 11 536 495 ;
C 63 ; WX 556 ; N question ; B 56 0 492 727 ;
C 64 ; WX 1015 ; N at ; B 147 -19 868 737 ;
C 65 ; WX 667 ; N A ; B 14 0 654 718 ;
C 66 ; WX 667 ; N B ; B 74 0 627 718 ;
C 67 ; WX 722 ; N C ; B 44 -19 681 737 ;
C 68 ; WX 722 ; N D ; B 81 0 674 718 ;
C 69 ; WX 667 ; N E ; B 86 0 616 718 ;
C 70 ; WX 611 ; N F ; B 86 0 583 718 ;

Text leading is the height of a line, from baseline to baseline. By default it is 120% of the point size, as explained here: https://helpx.adobe.com/incopy/using/leading.html

Clone this wiki locally