diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2015-06-01 03:04:11 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2015-06-01 03:04:11 +0000 |
commit | 3bd28910de6638992c734ba337dc8bdf41816602 (patch) | |
tree | 2ffae4503008a91e65920bc87ff6e26f33980de9 /converter/pbm | |
parent | 4e879f6f72bd8eeea85a7dcaf96d378fe8dec387 (diff) | |
download | netpbm-mirror-3bd28910de6638992c734ba337dc8bdf41816602.tar.gz netpbm-mirror-3bd28910de6638992c734ba337dc8bdf41816602.tar.xz netpbm-mirror-3bd28910de6638992c734ba337dc8bdf41816602.zip |
Add comments
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@2540 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter/pbm')
-rw-r--r-- | converter/pbm/pbmtopk.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/converter/pbm/pbmtopk.c b/converter/pbm/pbmtopk.c index fc94f855..3948ae0d 100644 --- a/converter/pbm/pbmtopk.c +++ b/converter/pbm/pbmtopk.c @@ -1,7 +1,12 @@ /* pbmtopk, adapted from "pxtopk.c by tomas rokicki" by AJCD 1/8/90 - compile with: cc -o pbmtopk pbmtopk.c -lm -lpbm + References (retrieved May 31 2015): + Packed (PK) Font File Format + https://www.tug.org/TUGboat/tb06-3/tb13pk.pdf + + Tex Font Metric Files (TFM) + https://www.tug.org/TUGboat/tb06-1/tb11gf.pdf */ #define _BSD_SOURCE 1 /* Make sure strdup() is in string.h */ @@ -26,6 +31,29 @@ #define MAXPARAMS 30 #define NAMELENGTH 80 +/*----------------------------------------------------------------------- +Macros to handle fixed point numbers + +This program uses uses fixed-point numbers to store data where +normally a floating-point data type (float or double) would be +employed. + +Numbers that contain fractions are stored as signed integers. +The 20 least-significant bits are for the fractional part, the rest +(12 bits assuming that int is 32 bit) are for the integer part. +The technical term for this is "Q20" or "Q12.20" notation. + +Float/double data is converted to Q20 fixed point by multiplying +by 2^20 (= 1048576). The opposite conversion is conducted by +dividing by 2^20. + +The Q20 data must be within the range -16 < r < 16. The reason +behind this restriction is unclear. The program generally writes +Q20 data to the output files in 32 bits. (Exception: in function +shipchar() there is a provision to write Q20 data in 24 bits, +provided that 24 bits is sufficient.) +---------------------------------------------------------------------*/ + #define fixword(d) ((int)((double)(d)*1048576)) #define unfixword(f) ((double)(f) / 1048576) #define fixrange(f) ((f) < 16777216 && (f) > -16777216) |