home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / LASER / BFONT513.ZIP / HPLAJETN.BFC < prev    next >
Encoding:
Text File  |  1989-05-30  |  12.4 KB  |  354 lines

  1. n,"HP LaserJet Standard/Non-Standard 40"; {for BitFont 5.0 and up}
  2. t:cn="(c) Copyright 1988, 1989 Bruce J. Patin, 12-26-88, 05-30-89";
  3. {This allows for a common non-standard font descriptor format,
  4. if the font descriptor length is 40 bytes}
  5.  
  6. {initialize BitFont specific variables}
  7.   a: aa=1;      {allow adjacent dots. Only necessary to disallow for certain wire matrix printers.}
  8.   x: df=1;      {init data format to 1, Laser/CRT}
  9.   x: xd=1;      {single horizontal density}
  10.   x: yd=1;      {single vertical density}
  11. {you could also initialize the color variables in here, if desired}
  12.  
  13. {declare and initialize the HP Character Descriptor variables:}
  14.   x: zf=4;{byte 0: Descriptor Format, must be 4 for LaserJet}
  15.   x: zx=0;{byte 1: Continuation, not supported by HP or BitFont}
  16.   x: zs=14;{byte 2: Descriptor Size, must be 14 for LaserJet}
  17.   x: cl=1;{byte 3: Class, bit data format, is 1 for LaserJet}
  18.   x: or=0;{byte 4: Orientation, 0 = portrait, 1=landscape}
  19.   {byte 5 is reserved, should be set to 0}
  20.   x: lo=0;{byte 6,7: offset left edge of char to left edge of font cell}
  21.           {landscape fonts will have negative values here}
  22.   x: to=40;{byte 8,9: offset top of character to baseline}
  23.   x: cw=30;{byte 10,11: character width, at 300 dots per inch, 30 is 1/10 inch}
  24.   x: ch=50;{byte 12,13: character height, 50 dots is 6 lines per inch}
  25.   x: ep=120,"Delta-X (quarter dots)"; {byte 14,15: distance from reference point to next character's}
  26.  
  27. {declare and initialize the HP Font Descriptor variables}
  28.   {note that values outside the ranges given here will usually result
  29.    in the HP printer rejecting the downloaded font.}
  30.   a: fd=26,"Font Descriptor size"; {byte 0,1: 26 is the minimum, 64 is max}
  31.                                    {HP printers ignore beyond 26 so far.}
  32.   a:z2=0;   {byte 2 is reserved, should be set to 0}
  33.   a: ft=1,"Font Type";{byte 3: 0 for 7-bit codes, 1 for 8-bit codes}
  34.   a:z4=0; {bytes 4,5 reserved, set to 0}
  35.   a: bl=40;{byte 6,7: distance from top edge of font cell to baseline}
  36.      {baseline position may range from 0 to font cell height minus 1}
  37.   a: fw=30;{byte 8,9: font cell width, must be from 1 to 255}
  38.   a: fh=50;{byte 10,11: font cell height, must be from 1 to 255}
  39.   a: oo=0;{byte 12: font orientation, 0=portrait, 1=landscape}
  40.      {each character orientation must match or character is rejected}
  41.   a: ks=0,"Spacing (0=fixed,1=prop)";{byte 13}
  42.   a: ss=21,"Symbol Set";{byte 14,15: 21 is ANSI US ASCII}
  43.   a: pt=120,"Pitch (quarter dots)";{byte 16,17}
  44.   a: jh=200,"Height (quarter dots)";{byte 18,19}
  45.   a: xh=0;{xHeight (quarter dots) byte 20,21, ignored by LaserJet}
  46.   a: wt=0;{Width Type byte 22, ignored by LaserJet}
  47.   a: st=0,"Style";{byte 23, 0=upright, 1=italics, 2=oblique}
  48.   a: sw=0,"Stroke Weight";{byte 24}
  49.   a: tf=0,"Typeface";{byte 25}
  50.   {variables beyond this are currently ignored by HP printers.}
  51.   {may be safest to ignore them also and set font descriptor size to 26}
  52.   {some font developers have not followed the format beyond this point}
  53.   a: sl=0;{Slant or reserved, byte 26}
  54.   a: sf=0;{Serif Style,  byte 27}
  55.   a:z8=0;{28,29 reserved, set to 0}
  56.   a: ud=-7;{Underline Distance (dots),  byte 30}
  57.   a: uh=3;{Underline Height (dots),  byte 31, LaserJet is always 3}
  58.   a: th=200;{Text Height (quarter dots),  byte 32,33}
  59.   a: tw=120;{Text Width (quarter dots),  byte 34,35}
  60.   a: fc=32;{First Code,  byte 36,37}
  61.   a: lc=255;{Last Code,  byte 38,39}
  62.   a: pe=0;{Pitch Extended (1024ths dot),  byte 40}
  63.   a: he=0;{Height Extended (1024ths dot),  byte 41}
  64.   a:z3=0;{bytes 42,43 reserved, set to 0}
  65.   a:z7=0;{for bytes 44-45, in case they are not 0 in original font}
  66.   a: fm=1;{bytes 44-47 font number, always 1 for LaserJet softfonts}
  67.   t: fn="................";{Font Name (16 chars),  bytes 48-63}
  68. {this is the end of the currently standard font descriptor}
  69.   t:ex="";{any extended area between font descriptor and escape length.}
  70.  
  71. a: d8=0;   {d8=0 during font save to file, d8=1 for downloading}
  72. e; {end initialization section.}
  73. a: zt=0; {will get no font trailer message if not loading entire font}
  74.  
  75. Ki1,"Load entire font."; {start input entire font.}
  76. Ki2,"Load font descriptor only.";
  77.  
  78.  {a little re-initialization first}
  79.   a:z2=0;
  80.   a:z4=0;
  81.   a:z8=0;
  82.   a:z3=0;
  83.   a:z7=0;
  84.   a:fm=1;
  85.   t: fn="................";
  86.   t:ex="";
  87.  
  88. a: zt=1; {used to suppress no font trailer message}
  89. #:**, "Loading Font Descriptor ";
  90.   L 2;
  91.   u: za;
  92.   j 2: za,ne,$1b; {look for esc}
  93.   u: zb;
  94.   j 2: zb,ne,$29; {look for ) }
  95.   u: zc;
  96.   j 2: zc,ne,$73;  {look for s }
  97.   d: zl;      {escape sequence main data length}
  98.   u: zz;      {throw away term char}
  99.   w: fd,"Font Descriptor size";      {font descriptor size}
  100. z 6:fd-2;     {skip to end when length of font descriptor is reached}
  101.   u: z2;      {reserved}
  102.   u: ft,"Font type";
  103.   w: z4;      {reserved}
  104.   w: bl; {Baseline Distance (dots)}
  105.   w: fw; {Cell Width (dots)}
  106.   w: fh; {Cell Height (dots)}
  107.   a:aw=fw; a:ah=fh; a:bw=fw; a:bh=fh; {resize parms, for convenience}
  108.   u: oo; {font overall orientation}
  109.   u: ks,"Spacing (0=fixed,1=prop)";
  110.   w: ss,"Symbol Set";
  111.   w: pt,"Pitch (quarter dots)";
  112.   w: jh,"Height (quarter dots)";
  113.   w: xh;{reserved, was xHeight (quarter dots)}
  114.   s: wt,"Width Type";
  115.   u: st,"Style";
  116.   s: sw,"Stroke Weight";
  117.   u: tf,"Typeface";
  118. {****************} {section for non-standard descriptor if length 40}
  119. j 91,fd,ne,40;
  120.   q: fn,,14,"Font Name"; {note that this is 14 bytes; standard is 16.}
  121. j 6;
  122. L 91; {fd not 40, continue with standard}
  123. {****************}
  124.   u: sl,"Slant";{0 is normal}
  125.   u: sf,"Serif Style";
  126.   w: z8;      {reserved}
  127.   s: ud,"Underline Distance (dots)";
  128.   u: uh,"Underline Height (dots)";
  129.   w: th,"Text Height (quarter dots)";
  130.   w: tw,"Text Width (quarter dots)";
  131.   w: fc,"First Code";
  132.   w: lc,"Last Code";
  133.   u: pe,"Pitch Extended (1024ths dot)";
  134.   u: he,"Height Extended (1024ths dot)";
  135.   w: z3;      {reserved}
  136.   w: z7;      {reserved, or high order of font number}
  137.   w: fm;      {font number, always set to 1 for softfonts}
  138.   q: fn,,16,"Font Name";
  139. L 6;{ end of standard font descriptor}
  140.   r;{reset length limit, just in case there is a bug}
  141. z 7:zl-fd; {set length limit to what's left of escape sequence data length}
  142.   q: ex,,,"Extended area"; {allowed to terminate by next escape}
  143. L 7;{ end of font descriptor load}
  144.   r;{reset length limit}
  145. Ei2; {end of font descriptor}
  146.   L 8;
  147. j 12:fp,ge,fs;
  148.   u: zz;
  149.   j 8: zz,ne,$1b; {look for esc}
  150.   u: zz;
  151.   j 8: zz,ne,$2a; {look for * }
  152.   u: zz;
  153.   j 8: zz,ne,$63;  {look for c }
  154.   d: cc;      {decimal code of character}
  155.   u: zz;      {throw away term char}
  156. L1; {label 1 to indicate start of character.}
  157. $ : cc,"Loading code (hex) ";
  158.   L 11;
  159.   u: zz;
  160.   j 11: zz,ne,$1b; {look for esc}
  161.   u: zz;
  162.   j 11: zz,ne,$28; {look for ( }
  163.   u: zz;
  164.   j 11: zz,ne,$73;  {look for c }
  165.   d: zl;      {length of character descriptor and data}
  166.   u: zz;      {throw away term char}
  167.   u: zf;      {format of descriptor}
  168.   u: zx;      {continuation}
  169.   u: zs;      {descriptor size}
  170. z 19:zs-1;
  171.   u: cl;      {class ( data format)}
  172.   u: or;  {Character Orientation}
  173.   u: zz;  {reserved}
  174.   i: lo;  {left offset}
  175.   i: to;  {top offset}
  176.   w: cw;  {character width}
  177.   w: ch;  {character height}
  178.   i: ep;  {endpoint}
  179. L 19; R;
  180.   a: xl=zl-zs-2; {actual datalength}
  181. j 31: zx,ne,0;
  182.   g:0,xl; {character data}
  183.   a: xc=xl;
  184. L 31;
  185. j 32: zx,ne,1;
  186.   g:xc,xl; {character data}
  187.   a: xc=0;
  188. L 32;
  189. Ei4,1; {end character search, character loaded.}
  190.   j 8;        {go get next char}
  191. L 12;
  192. #:**,"Font loaded.";
  193. Ei1,2,0; {end entire font.}
  194.  
  195. Ki4,"Load current character only."; {start search for an input character.}
  196.   z 10:fs-fp;
  197.   L 9;
  198.   u: zz;
  199.   j 9: zz,ne,$1b; {look for esc}
  200.   u: zz;
  201.   j 9: zz,ne,$2a; {look for * }
  202.   u: zz;
  203.   j 9: zz,ne,$63;  {look for c }
  204.   d: zc;      {decimal code of character}
  205. $: zc,"Encountered code (hex): ";
  206. #: fp,"At file position: ";
  207.   u: zz;      {throw away term char}
  208. j 14: zc,eq,cc;
  209.   L 13;
  210.   u: zz;
  211.   j 13: zz,ne,$1b; {look for esc}
  212.   u: zz;
  213.   j 13: zz,ne,$28; {look for ( }
  214.   u: zz;
  215.   j 13: zz,ne,$73;  {look for c }
  216.   d: zl;      {length of character descriptor and data}
  217.   u: zz;      {throw away term char}
  218.   p: fp + zl - 1; {position file past this character}
  219.   j 9: zc,ne,cc;  {looking for current code}
  220. L 14;
  221. # : cc,"Found code (dec)";
  222.   j 1;           {found, go get it}
  223.   L 10;       {char not found}
  224. #A: zz,"Code not found. Hit return to continue.";
  225. Ei4; {end character search program (unsuccessful search)}
  226.  
  227. Ko1,"Save entire font."; {start output entire font.}
  228. Ko2,"Save font descriptor only.";
  229. L 88; {for download}
  230. #:**, "Sending Font Descriptor ";
  231.   u:$1b;
  232.   u:$29;
  233.   u:$73;
  234.   d:fd+ex;      {escape sequence main data length}
  235.   y:"W";      {term char}
  236. z 46:fd;   {set length limit}
  237. j 97: d8,ne,1;  {skip fd override if not downloading}
  238. j 97: fd,ne,40; {skip fd override if fd<>40}
  239.   w: 26;        {fd override to fix nonstandard downloading problems}
  240.   j 98;
  241. L 97;
  242.   w: fd;      {font descriptor size}
  243. L 98;
  244.   u: z2;      {reserved}
  245.   u: ft;       {font type}
  246.   w: z4;      {reserved}
  247.   w: bl;     {Baseline Distance (dots)}
  248.   w: fw; {Cell Width (dots)}
  249.   w: fh; {Cell Height (dots)}
  250.   u: oo; {Orientation (0=portrt,1=landscp)}
  251.   u: ks; {Spacing (0=fixed,1=prop)}
  252.   w: ss; {Symbol Set for ss esc seq val = 1024, term char = A, ss=32769dec}
  253.   w: pt; {Pitch (quarter dots)}
  254.   w: jh; {Height (quarter dots)}
  255.   w: xh; {xHeight (quarter dots)}
  256.   s: wt; {Width Type}
  257.   u: st; {Style}
  258.   s: sw; {Stroke Weight}
  259.   u: tf; {Typeface}
  260. {****************} {section for non-standard descriptor if length 40}
  261. j 92,fd,ne,40;
  262. j 93:fn,lt,14; {don't do next line if font name is less than 14}
  263.   q: fn,0,14; {Font Name, should be 14 characters, truncated if more}
  264. j 46;
  265. L 93; {routine if fn is less than 14 and needs padding}
  266.   t: ef="                "; {14 blanks, in case part needed for fname}
  267.   a: el=16-fn;{calculate number of trailing blanks needed}
  268.   q: fn;      {font name}
  269.   q: ef,0,el; {add trailing blanks to make 14}
  270. j 46;
  271. L92;
  272. {****************}
  273.   u:sl;  {Slant}
  274.   u: sf; {Serif Style}
  275.   w: z8;      {reserved}
  276.   s: ud; {Underline Distance (dots)}
  277.   u: uh; {Underline Height (dots)}
  278.   w: th; {Text Height (quarter dots)}
  279.   w: tw; {Text Width (quarter dots)}
  280.   w: fc;{First Code,  byte 36,37}
  281.   w: lc;{Last Code,  byte 38,39}
  282.   u: pe;  {Pitch Extended (1024ths dot)}
  283.   u: he;  {Height Extended (1024ths dot)}
  284.   w: z3;      {reserved}
  285.   w: z7;      {high order word of font number}
  286.   w: fm;      {font number, always 1 for laserjet softfonts}
  287. j 61:fn,lt,16; {don't do next line if font name is less than 16}
  288.   q: fn,0,16; {Font Name, should be 16 characters, truncated if more}
  289. j 46;
  290. L 61; {routine if fn is less than 16 and needs padding}
  291.   t: ef="                "; {16 blanks, in case part needed for fname}
  292.   a: el=16-fn;{calculate number of trailing blanks needed}
  293.   q: fn;      {font name}
  294.   q: ef,0,el; {add trailing blanks to make 16}
  295. L 46; {end font descriptor output}
  296.   r; {reset length limit}
  297.   q: ex; {extended area, if any}
  298. Eo2; {end output font descriptor.}
  299. a:cc=0;  {start with first possible code, zero}
  300. c;       {select first valid code}
  301. j 57;        {bypass first code check}
  302. L 55;
  303.   c;  {select first valid code}
  304. j 59:cc,eq,0;  {go to 59 if no more valid codes}
  305. L 57;
  306. Ko4,"Append current character to output file.",A; {start output character}
  307. $ :cc,"Sending code (hex): ";
  308.   u:$1b;
  309.   u:$2a;
  310.   u:$63;
  311.   d: cc;      {decimal code of character}
  312.   u:$45;      {term char}
  313.   u:$1b;
  314.   u:$28;
  315.   u:$73;
  316.   d: dl+16;      {length of character descriptor and data}
  317.   y:"W";      {term char}
  318.   u:zf;     {format of descriptor}
  319.   u:zx;     {continuation}
  320.   u:zs;       {descriptor size}
  321.   u:cl;       {class ( data format)}
  322.   u:or;     {Character Orientation}
  323.   u:0;  {reserved}
  324.   i: lo;  {left offset}
  325.   i: to;  {top offset}
  326.   w: cw;  {character width}
  327.   w: ch;  {character height}
  328.   i: ep;  {endpoint}
  329.   g;   {character data}
  330. Eo4; {end output character.}
  331. a:cc=cc+1;
  332. j 55;
  333. L 59;   {end}
  334. j 89:d8,eq,1; {go finish download if downloading}
  335. Eo1; {end output entire font.}
  336. KP; {start download}
  337.   a:d8=1;  {downloading indicator}
  338. #a:id," Enter a font ID number (0 to 32767): ";
  339.   u:$1b;
  340.   u:$2a;
  341.   u:$63;
  342.   d:id;
  343.   u:$44;
  344. j 88;         {go save font to the printer}
  345. L 89; {now make it primary}
  346.   a:d8=0; {turn off download indicator}
  347.   u:$1b;
  348.   u:$28;
  349. #:id," Font loaded as primary with ID: ";
  350.   d:id;
  351.   u:$58;
  352. EP; {end download}
  353. .
  354.