DIRECTORY CIFS USING [dontCheck, Error, GetFC, OpenButDontHandleError, read], File, Inline, Rope, Space, Tfm, TSFontTable, TSTypes; TSFontTableImpl: CEDAR PROGRAM IMPORTS CIFS, File, Inline, Rope, Space, Tfm, TSTypes EXPORTS TSFontTable = BEGIN OPEN TSTypes, TSFontTable; BadTfmFile: SIGNAL = CODE; TwoToTheTenth: INT = 2*2*2*2*2 * 2*2*2*2*2; TwoToTheTwentieth: INT = TwoToTheTenth*TwoToTheTenth; RealTwoToTheTwentieth: REAL = TwoToTheTwentieth; FixedToReal: PROCEDURE [x: Tfm.Fixed] RETURNS [REAL] = TRUSTED BEGIN RETURN[Tfm.Long[x]/RealTwoToTheTwentieth]; END; tfmDir: Rope.ROPE = "/Indigo/Tioga/TFM/"; Load: PUBLIC PROCEDURE [name: Rope.ROPE] RETURNS [f: Ref] = TRUSTED BEGIN ENABLE CIFS.Error => TRUSTED {GOTO FileNotFound}; s: NAT = SIZE[Tfm.Word]; tfmName: Rope.ROPE _ name.Concat[".tfm"]; tfmFile: File.Capability; pages: File.PageCount; size: Space.PageCount; space: Space.Handle; base: LONG POINTER TO UNSPECIFIED; dir: LONG POINTER TO Tfm.Directory; IF Rope.Fetch[tfmName]#'/ THEN tfmName _ Rope.Cat[tfmDir, tfmName]; tfmFile _ CIFS.GetFC[CIFS.OpenButDontHandleError[tfmName, CIFS.read + CIFS.dontCheck]]; pages _ File.GetSize[tfmFile]; size _ IF pages<=16 THEN Inline.LowHalf[pages] ELSE ERROR; space _ Space.Create[size: size, parent: Space.virtualMemory]; Space.Map[space: space, window: [file: tfmFile, base: 1]]; -- first page is 1! base _ Space.LongPointer[space]; dir _ LOOPHOLE[base]; f _ NEW[TSFontTable.Record]; IF Tfm.ValidDirectory[dir^] THEN BEGIN OPEN dir^; hdr: LONG POINTER TO Tfm.Header _ LOOPHOLE[dir + s*6]; pf: LONG POINTER TO Tfm.FInfo _ LOOPHOLE[hdr + s*lh]; pw: LONG POINTER TO Tfm.Width _ LOOPHOLE[pf + s*(ec-bc+1)]; ph: LONG POINTER TO Tfm.Height _ LOOPHOLE[pw + s*nw]; pd: LONG POINTER TO Tfm.Depth _ LOOPHOLE[ph + s*nh]; pi: LONG POINTER TO Tfm.CharIc _ LOOPHOLE[pd + s*nd]; pl: LONG POINTER TO Tfm.LigKern _ LOOPHOLE[pi + s*ni]; pk: LONG POINTER TO Tfm.Kern _ LOOPHOLE[pl + s*nl]; pe: LONG POINTER TO Tfm.Exten _ LOOPHOLE[pk + s*nk]; pp: LONG POINTER TO Tfm.Param _ LOOPHOLE[pe + s*ne]; f.name _ name; f.headerInfo _ ExtractHeaderInfo[hdr]; f.bc _ Inline.LowByte[bc]; f.ec _ Inline.LowByte[ec]; f.fInfoTable _ ExtractFInfoTable[pf,dir]; f.widthTable _ ExtractDimensions[pw,nw]; f.heightTable _ ExtractDimensions[ph,nh]; f.depthTable _ ExtractDimensions[pd,nd]; f.charIcTable _ ExtractDimensions[pi,ni]; f.ligKernProgram _ ExtractLigKernProgram[pl,nl]; f.kernTable _ ExtractDimensions[pk,nk]; f.extTable _ NIL; -- don't need this for Tioga at this time f.parameters _ ExtractParameters[pp,np]; END ELSE {SIGNAL BadTfmFile}; Space.Delete[space]; EXITS FileNotFound => {} END; ExtractHeaderInfo: UNSAFE PROCEDURE [p: LONG POINTER TO Tfm.Header] RETURNS [h: HeaderInfo] = UNCHECKED BEGIN -- h _ NEW[HeaderInfoRec]; BEGIN OPEN h^; checkSum _ p.checkSum; characterCodingScheme _ Rope.FromRefText[Textify[LOOPHOLE[@p^.characterCodingScheme]]]; family _ Rope.FromRefText[Textify[LOOPHOLE[@p^.externalFontIdentifier]]]; designSize _ RealDimn[FixedToReal[p.designSize],pt]; face _ p.extraInfo.parcFaceByte; END END; Textify: UNSAFE PROCEDURE [a: LONG POINTER TO READONLY PACKED ARRAY [0..255] OF CHARACTER] RETURNS [t: REF TEXT] = UNCHECKED BEGIN len:NAT _ LOOPHOLE[a[0],Byte]; -- length is stashed in first byte t _ NEW[TEXT[len]]; t.length _ len; FOR i:NAT IN [0..len) DO t[i] _ a[i+1]; ENDLOOP; END; ExtractFInfoTable: UNSAFE PROCEDURE [p: LONG POINTER TO Tfm.FInfo, dir: LONG POINTER TO Tfm.Directory] RETURNS [FInfoTable] = UNCHECKED BEGIN OPEN dir^; f: FInfoTable _ NEW[FInfoTableRec[ec+1]]; FOR i:NAT IN [0..bc) DO f[i] _ [0,0,0,0,none[[]]] ENDLOOP; FOR i:NAT IN [bc..ec] DO OPEN p[i-bc]; IF widthIndex >= nw OR heightIndex >= nh OR depthIndex >= nd OR charIcIndex >= ni THEN SIGNAL BadTfmFile; f[i] _ p[i-bc] ENDLOOP; RETURN[f] END; ExtractDimensions: UNSAFE PROCEDURE [p: LONG POINTER TO Tfm.FixedArray, n:CARDINAL] RETURNS [d: MetricTable] = UNCHECKED BEGIN d _ NEW[MetricTableRec[n]]; FOR i:NAT IN [0..n) DO d[i] _ FixedToReal[p[i]] ENDLOOP END; ExtractLigKernProgram: UNSAFE PROCEDURE [p: LONG POINTER TO Tfm.LigKern, n:CARDINAL] RETURNS [l: LigKernProgram] = UNCHECKED BEGIN l _ NEW[LigKernProgramRec[n]]; FOR i:NAT IN [0..n) DO l[i] _ p[i] ENDLOOP END; ExtractParameters: UNSAFE PROCEDURE [p: LONG POINTER TO Tfm.Param, n:CARDINAL] RETURNS [t: ParamTable] = UNCHECKED BEGIN i: Tfm.ParamIndex _ FIRST[Tfm.ParamIndex]; t _ NEW[ParamTableRec[n]]; THROUGH [0..n) DO t[i] _ FixedToReal[p[i]]; i _ SUCC[i]; ENDLOOP; t.slantNum _ Tfm.Long[p[slant].ValueTimesTwoToTheTwentieth]; t.slantDenom _ TwoToTheTwentieth; END; END. Michael Plass, September 16, 1982 1:38 pm. Removed !h from CIFS filename. Michael Plass, September 29, 1982 11:08 am. Added TRUSTED to catch phrase in CIFS call. Michael Plass, November 2, 1982 10:11 am. CEDARized. Michael Plass, November 17, 1982 11:33 am. Used ENABLE instead of catch phrase for CIFS. °TSFontTableImpl.mesaRef Font table loader for the Tioga Typesetter Last changed by Michael Plass, November 17, 1982 11:34 am Last Edited by: Beach, May 24, 1983 9:08 am ΚΟ– "cedar" style˜JšΟc™J˜Jš*™*Jš9™9Jš+™+šΟk ˜ Jšžœžœ9˜CJ˜J˜J˜J˜J˜J˜ J˜J˜—šœž ˜Jšžœžœ)˜5Jšžœ˜—Jšžœžœ˜ J˜Jšœ žœžœ˜J˜Jšœžœ˜+Jšœžœ˜5Jšœžœ˜0J˜š Οn œž œžœžœž˜>Jšž˜Jšžœ$˜*Jšžœ˜J˜—Jšœ žœ˜)J˜š Ÿœžœž œ žœžœ ž˜CJšž˜Jšžœžœ žœžœ˜1Jšœžœžœ ˜Jšœžœ˜)J˜J˜J˜J˜Jš œžœžœžœž œ˜"Jšœžœžœžœ˜#J˜Jšžœžœ%˜CJš œ žœžœ!žœžœ ˜WJ˜Jš œžœ žœžœžœ˜:J˜>J˜šœ;˜NJ˜—J˜ J˜Jšœžœ˜J˜Jšœžœ˜J˜šžœž˜ Jšžœžœ˜Jš œžœžœžœžœ ˜6Jš œžœžœžœ žœ ˜5Jš œžœžœžœ žœ˜;Jš œžœžœžœžœ ˜5Jš œžœžœžœ žœ ˜4Jš œžœžœžœžœ ˜5Jš œžœžœžœžœ ˜6Jš œžœžœžœ žœ ˜3Jš œžœžœžœ žœ ˜4Jš œžœžœžœ žœ ˜4J˜J˜J˜&J˜J˜J˜)J˜(J˜)J˜(J˜)J˜0J˜'Jšœ žœ)˜;J˜(Jšž˜—Jšžœžœ ˜J˜Jšžœ˜Jšžœ˜J˜—š Ÿœžœžœžœžœ ˜CJšžœž ˜#Jšžœ˜šœžœ˜Jšžœžœ˜J˜Jšœ1žœ˜WJšœ"žœ˜IJ˜4J˜ Jšž˜—Jšžœ˜J˜—šŸœžœž œžœžœžœžœžœžœ žœž œ˜ZJšžœžœžœž ˜!Jšž˜Jšœžœžœ "˜AJšœžœžœ˜J˜šžœžœžœ ž˜J˜Jšžœ˜—Jšžœ˜J˜—šŸœžœž œžœžœžœžœžœžœ˜fJšžœž ˜ Jšžœžœ˜Jšœžœ˜)Jš žœžœžœ žœžœ˜:šžœžœžœ ž˜Jšžœ ˜ šžœž˜Jšœž˜Jšœž˜Jšœžœžœ ˜)—Jšœžœ˜—Jšžœ˜ Jšžœ˜J˜—šŸœžœž œžœžœžœžœ˜SJšžœž ˜$Jšž˜Jšœžœ˜Jš žœžœžœžœž˜7Jšžœ˜J˜—šŸœžœž œžœžœžœžœ˜TJšžœž ˜'Jšž˜Jšœžœ˜Jš žœžœžœžœ ž˜*Jšžœ˜J˜—šŸœžœž œžœžœžœžœ˜NJšžœž ˜#Jšž˜Jšœžœ˜*Jšœžœ˜šžœž˜J˜Jšœžœ˜ Jšžœ˜—J˜