From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- fonts/utilities/pkbbox/README | 41 +++++++++ fonts/utilities/pkbbox/pkbbox.mak | 43 ++++++++++ fonts/utilities/pkbbox/pkbbox.pas | 170 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 254 insertions(+) create mode 100644 fonts/utilities/pkbbox/README create mode 100644 fonts/utilities/pkbbox/pkbbox.mak create mode 100644 fonts/utilities/pkbbox/pkbbox.pas (limited to 'fonts/utilities/pkbbox') diff --git a/fonts/utilities/pkbbox/README b/fonts/utilities/pkbbox/README new file mode 100644 index 0000000000..62fa3bbee0 --- /dev/null +++ b/fonts/utilities/pkbbox/README @@ -0,0 +1,41 @@ +PKBBOX is a hack that exists only because some Type1 fonts on the +net do not include AFM files. I was determined to use these fonts +(I don't remember why anymore ;-) so I discovered that the following +sequence would produce a legal, if imperfect, AFM file: + + 1) Use PFM2AFM to generate an initial AFM file. This file is insufficient + for generating a TFM file because it does not contain the bounding + boxes for the characters. + + 2) Use PS2PK to produce a PK file from the Type 1 font. This works because + PS2PK doesn't care about the bounding boxes. + + 3) Use PKBBOX to build a (more) valid AFM file. PKBBOX reads the original + AFM file and the PK file and constructs reasonable (but *not* perfect) + bounding boxes. It produces a new AFM file with this information. + + 4) Use the new AFM file to generate a TFM file. + + 5) That's it, use the font. + +The bounding boxes are going to be wrong if the font has letters which have +large descenders or other "bumps" that extend out of the real bounding box, +but it was the best I could do. + + Cheers, + norm + +P.S. Feel free to drop me a note if you have any difficulties, although I +can't promise that I'll be able to help very much. + +--- +Norman Walsh | Unable to locate coffee---operator halted. +Production Tools Specialist | +O'Reilly & Associates, Inc. | +90 Sherman Street | +Cambridge, MA 02140 |------------------------------------------------ +(617) 354-5800/661-1116 FAX | URL: http://jasper.ora.com/norm.html + + + + diff --git a/fonts/utilities/pkbbox/pkbbox.mak b/fonts/utilities/pkbbox/pkbbox.mak new file mode 100644 index 0000000000..ffa14b0651 --- /dev/null +++ b/fonts/utilities/pkbbox/pkbbox.mak @@ -0,0 +1,43 @@ +# +# MakeFile created by Dep 3.42 for pkbbox.pas +# on 01/07/93 at 07:34 pm +# +# This makefile is for ndMake vers 4.51 +# +VPATH = .;d:\tp\source\tex\units;d:\tp\unit;d:\tp\bgi;d:\opro;d:\tp\inc;d:\opro; +# +# Compilation macros ############################################### +# +pas_compiler = d:\tp\tpc.exe +pas_options = /l +pun_compiler = d:\tp\tpc.exe +pun_options = /l +# +# Implicit rules ################################################### +# +.SUFFIXES : .exe .tpu .pas .pun .l + +.pas.exe:; $(pas_compiler) $(pas_options) $< + +.pun.tpu:; $(pun_compiler) $(pun_options) $< + +.l.pas:; $(l_compiler) $(l_options) $< + +.pas.tpu:; $(pun_compiler) $(pun_options) $< + +# +# Explicit rules ################################################### +# +pkbbox.exe : pkbbox.pas opcrt.tpu clock.tpu files.tpu \ + moredos.tpu moresys.tpu strings.tpu opstring.tpu \ + tp_msgs.tpu sps_cpyr.tpu pkdcl.tpu texdcl.tpu \ + tfmdcl.tpu + +pkdcl.tpu : d:\tp\source\tex\units\pkdcl.pun buffers.tpu \ + files.tpu bytevec.tpu + +texdcl.tpu : d:\tp\source\tex\units\texdcl.pun strings.tpu + +tfmdcl.tpu : d:\tp\source\tex\units\tfmdcl.pun files.tpu \ + moresys.tpu + diff --git a/fonts/utilities/pkbbox/pkbbox.pas b/fonts/utilities/pkbbox/pkbbox.pas new file mode 100644 index 0000000000..a9ea1d3c95 --- /dev/null +++ b/fonts/utilities/pkbbox/pkbbox.pas @@ -0,0 +1,170 @@ +Program PKtoSFP; + +uses OpCrt, + Clock, + Files, + MoreDos, + MoreSys, + Strings, + OpString, + Tp_Msgs, + Sps_Cpyr, + PkDcl, + TexDcl, + TfmDcl; + +const + Vers = '0.2'; + BannerStr = 'This is PKbbox vers '+Vers; + ProgName = 'PKbbox'; + +var + DesignSize : Real; + DesignRatio : Real; + +type + CharRec = Record + CC : Byte; + llx,lly,urx,ury : Integer; + end; + +var + RC : Integer; + PkFont : PkFontObj; + PkChar : PkCharObj; + PkFn : FileSpecStr; + AfmFn : FileSpecStr; + Count : Word; + WorkReal : Real; + WorkString : String; + Chars : Array[0..255] of CharRec; + T : Text; + StdErr : Text; + Line,s : String; + I,err : Integer; + + lc_Width : Real; + lc_Count : Word; + + MaxDescender: LongInt; + MaxAscender : LongInt; + + CharName : String[12]; + HorizDpi : Integer; + VertDpi : Integer; + ScaleAdj : Real; + RemapSuccess: Boolean; + Multiplier : Real; + llx,lly,urx,ury : Integer; + +begin + AssignCrt(StdErr); + Rewrite(StdErr); + + Assign(Output,''); + Rewrite(Output); + + If ParamCount < 2 then + begin + Writeln(StdErr,'Usage: PKBBOX pkfile afmfile > newafmfile'); + Halt(0); + end; + + Writeln(StdErr,BannerStr); + + PkFn := ParamStr(1); + AfmFn := ParamStr(2); + + PkFont.Init; + PkFont.OpenPkFile(RC,PkFn); + If RC <> 0 then + begin + Write(StdErr,ProgName,': cannot read PK file: '); + If RC > 0 then + Write(StdErr,TpErrMsg(RC)) + Else + Write(StdErr,PkErrMsg(RC)); + Halt(1); + end; + + DesignSize := 1.0*PkFont.DesignSize/1048576.0; + DesignRatio := 300.0/72.27*DesignSize; + + HorizDpi := Round(1.0*PkFont.Hppp/65536.0*72.27); + VertDpi := Round(1.0*PkFont.Vppp/65536.0*72.27); + ScaleAdj := 1.0*HorizDpi/300.0; + + Multiplier := 1000.0 / DesignRatio; + + FillChar(Chars,SizeOf(Chars),$00); + + MaxAscender := 0; + MaxDescender := 0; + lc_Width := 0.0; + lc_Count := 0; + PkChar.Init; + PkChar.ReadPkChar(RC,PkFont); + While RC = 0 do + begin + CharName := Pad(TexChar(Char(PkChar.CharacterCode)),6); + + MaxAscender := Max(MaxAscender,PkChar.VOff); + MaxDescender := Max(MaxDescender,PkChar.Height-PkChar.VOff); + + llx := 0; + lly := Trunc((PkChar.Voff-PkChar.Height)*Multiplier); + urx := Trunc(PkChar.Width*Multiplier); + ury := Trunc(PkChar.Height*Multiplier) + lly; + + Chars[PkChar.CharacterCode].llx := llx; + Chars[PkChar.CharacterCode].lly := lly; + Chars[PkChar.CharacterCode].urx := urx; + Chars[PkChar.CharacterCode].ury := ury; + + PkChar.Done; + PkChar.Init; + PkChar.ReadPkChar(RC,PkFont); + end; + + If RC <> Err_PkNoMore then + begin + Write(StdErr,ProgName,': Error scanning PK file: '); + If RC > 0 then + Write(StdErr,TpErrMsg(RC)) + Else + Write(StdErr,PkErrMsg(RC)); + Halt(1); + end; + + PkFont.Done; + + Assign(T,ParamStr(2)); + {$I-} Reset(T); {$I+} + RC := IoResult; + + If RC <> 0 then + begin + Write(StdErr,ProgName,': cannot read AFM file: ',TpErrMsg(RC)); + Halt(1); + end; + + While Not Eof(T) do + begin + Readln(T,Line); + S := WordN(Line,2,' '); + Val(S,I,err); + If (WordN(Line,1,' ') = 'C') and (err = 0) and (I >= -1) and (I <= 255) then + begin + If I = -1 then + Writeln(Line,' B 0 0 0 0 ;') + Else + Writeln(Line,' B ',Chars[I].llx,' ',Chars[I].lly,' ',Chars[I].urx,' ',Chars[I].ury,' ;'); + end + Else + Writeln(Line); + end; + + Close(T); + + Writeln('Done.'); +end. -- cgit v1.2.3