BEGIN
argv: CommandTool.ArgumentVector;
gfStream: IO.STREAM;
font: RasterFontIO.InternalFont;
gfName, acName: Rope.ROPE;
fontName, fullName: Rope.ROPE ← NIL;
cp: FS.ComponentPositions;
cr: FS.ComponentRopes;
interpressMode: BOOLEAN ← FALSE;
deviceResolution: INTEGER ← 0;
i: INTEGER;
CommandTool.StarExpansion[cmd];
argv ← CommandTool.Parse[cmd];
IF argv.argc <= 1 THEN GO TO Usage;
i ← 1;
WHILE i < argv.argc
DO
IF Rope.Fetch[argv.s[i], 0] = '-
THEN
SELECT Rope.Fetch[argv.s[i], 1]
FROM
'i => interpressMode ← TRUE;
'r => {
i ← i + 1;
deviceResolution ← Convert.IntFromRope[argv.s[i] !
Convert.Error => GOTO Usage
]
};
ENDCASE => GOTO Usage
ELSE
IF fontName =
NIL
THEN
fontName ← argv.s[i]
i ← i + 1;
ENDLOOP;
IF fontName.IsEmpty THEN GO TO Usage;
[fullName, cp] ← FS.ExpandName[fontName];
cr.server ← fullName.Substr[cp.server.start, cp.server.length];
cr.dir ← fullName.Substr[cp.dir.start, cp.dir.length];
cr.subDirs ← fullName.Substr[cp.subDirs.start, cp.subDirs.length];
cr.base ← fullName.Substr[cp.base.start, cp.base.length];
cr.ext ← fullName.Substr[cp.ext.start, cp.ext.length];
fontName ← cr.base;
IF cp.ext.length = 0
THEN {
cr.ext ← "gf";
gfName ← FS.ConstructFName[cr];
}
{
res: INT ← 0;
res ← IO.GetInt[IO.RIS[cr.ext] ! IO.Error => CONTINUE];
IF res # 0 THEN cr.base ← IO.PutFR["%g-%g", IO.rope[cr.base], IO.int[res]];
};
acName ← FS.ExpandName[Rope.Cat[cr.base, ".ac"]].fullFName;
gfStream ← FS.StreamOpen[gfName
!
FS.Error =>
IF error.group = user
THEN {
cmd.err.PutF["Cannot open %g: %g\n",
IO.rope[gfName], IO.rope[error.explanation]];
GOTO Abort;
};
];
font ← LoadGF[gfStream, deviceResolution
! FormatError => {
cmd.err.PutF[Rope.Cat["GF file has bad format: ", explanation, "\n"], v1, v2];
GOTO Abort;
};
];
gfStream.Close[];
IF interpressMode
THEN {
MyUpper: Rope.TranslatorType = { new ← Ascii.Upper[old] };
font.family ← Rope.Translate[base: fontName, translator: MyUpper];
font.face ← 0;
};
RasterFontIO.WriteAC[font, acName];
cmd.out.PutF["AC Font written on %g\n", IO.rope[acName]];