PSFontFromImager:
PUBLIC
PROC [imagerName:
ROPE]
RETURNS [psFont: PSFont] ~ {
Break:
IO.BreakProc ~ {
RETURN[
SELECT char
FROM
IN [Ascii.NUL..Ascii.SP], '., ',, ':, ';, '[, '], '(, '), '{, '}, '", '+, '-, '*, '/, '@, '← => sepr,
ENDCASE => other];
};
CheckForInlineScale:
PROC ~ {
skipTo: INT ¬ Rope.SkipTo[imagerName,, "0123456789"];
skipOver: INT ¬ Rope.SkipOver[imagerName, skipTo, "0123456789"];
psFont.scale ¬
IF skipTo < Rope.Length[imagerName]
THEN Convert.RealFromRope[Rope.Substr[imagerName, skipTo, skipOver-skipTo]]
ELSE 1.0;
};
out: IO.STREAM ¬ NARROW[Atom.GetProp[$IPtoPSDebug, $Out]];
root: ROPE ¬ NIL;
italicExt: ROPE ¬ "Oblique";
bold, italic: BOOL ¬ FALSE;
s: IO.STREAM ¬ IO.RIS[imagerName];
CheckForInlineScale[];
DO
Find: PROC [key: ROPE] RETURNS [b: BOOL] ~ {b ← Rope.Find[token, key,, FALSE] # -1};
token: ROPE ¬ IO.GetTokenRope[s, Break ! IO.EndOfStream => EXIT].token;
SELECT
TRUE
FROM
Find["helvetica"],
Find["modern"] => {psFont.type ¬ $Helvetica; root ¬ "Helvetica"}; -- or Frutiger
Find["symbol"] => {psFont.type ¬ $Unknown; root ¬ "Symbol"};
Find["math"] => {psFont.type ¬ $Math; root ¬ "Symbol"};
Find["hippo"] => {psFont.type ¬ $Greek; root ¬ "Symbol"};
Find["gacha"],
Find["courier"] => {psFont.type ¬ $Courier; root ¬ "Courier"};
Find["times"],
Find["laurel"],
Find["classic"] => {psFont.type ¬ $Times; root ¬ "Times-Roman"; italicExt ¬ "Italic"};
ENDCASE => {
IF Find["BRR"] OR Find["BIR"] OR Find["bold"] THEN bold ¬ TRUE;
IF Find["MIR"] OR Find["BIR"] OR Find["italic"] OR Find["oblique"] THEN italic ¬ TRUE;
};
ENDLOOP;
IF root =
NIL
THEN {
IPtoPS.Warn[Rope.Cat["unknown font: ", imagerName, ", substituting Helvetica"]];
psFont.type ¬ $Helvetica;
root ¬ "Helvetica";
};
IF Rope.Equal[root, "Times-Roman", FALSE] AND (bold OR italic) THEN root ¬ "Times";
psFont.name ¬
SELECT
TRUE
FROM
bold AND NOT italic => Rope.Concat[root, "-Bold"],
italic AND NOT bold => Rope.Cat[root, "-", italicExt],
bold AND italic => Rope.Cat[root, "-Bold", italicExt],
ENDCASE => root;
};