home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume13 / lj2ps / part11 < prev    next >
Encoding:
Text File  |  1990-07-02  |  18.9 KB  |  524 lines

  1. Newsgroups: comp.sources.misc
  2. subject: v13i096: lj2ps (11 of 12), a LaserJet to PostScript Translator
  3. From: lishka@uwslh.slh.wisc.edu (Chris Lishka (relaxing in the Mad-City) )
  4. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  5.  
  6. Posting-number: Volume 13, Issue 96
  7. Submitted-by: lishka@uwslh.slh.wisc.edu (Chris Lishka (relaxing in the Mad-City) )
  8. Archive-name: lj2ps/part11
  9.  
  10. ---- Cut Here and unpack ----
  11. #!/bin/sh
  12. # This is part 11 of a multipart archive
  13. if touch 2>&1 | fgrep '[-amc]' > /dev/null
  14.  then TOUCH=touch
  15.  else TOUCH=true
  16. fi
  17. # ============= ljfonts.c ==============
  18. if test X"$1" != X"-c" -a -f 'ljfonts.c'; then
  19.     echo "File already exists: skipping 'ljfonts.c'"
  20. else
  21. echo "x - extracting ljfonts.c (Text)"
  22. sed 's/^X//' << 'SHAR_EOF' > ljfonts.c &&
  23. X/* Project:        lj2ps
  24. X** File:        ljfonts.c
  25. X**
  26. X** Author:        Christopher Lishka
  27. X** Organization:    Wisconsin State Laboratory of Hygiene
  28. X**            Data Processing Dept.
  29. X**
  30. X** Copyright (C) 1990 by Christopher Lishka.
  31. X**
  32. X** This program is free software; you can redistribute it and/or modify
  33. X** it under the terms of the GNU General Public License as published by
  34. X** the Free Software Foundation; either version 1, or (at your option)
  35. X** any later version.
  36. X**
  37. X** This program is distributed in the hope that it will be useful,
  38. X** but WITHOUT ANY WARRANTY; without even the implied warranty of
  39. X** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  40. X** GNU General Public License for more details.
  41. X**
  42. X** You should have received a copy of the GNU General Public License
  43. X** along with this program; if not, write to the Free Software
  44. X** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  45. X*/
  46. X
  47. Xstatic char * ModuleID = "Module ljfonts: v1.0, production";
  48. X
  49. X  /* Include files
  50. X  */
  51. X#include <strings.h>
  52. X#include "ljfonts.h"
  53. X#include "lj.h"
  54. X
  55. X  /* External definitions
  56. X  */
  57. X
  58. X  /* Global variables
  59. X  */
  60. X
  61. X  /* Global function list
  62. X  */
  63. Xextern void  lj_match_font();    /* Get a font (closest match) */
  64. Xextern int   lj_find_font();    /* Find font based on the name */
  65. X
  66. X  /* Local constants
  67. X  */
  68. X#define MAX_BUFFER  2048
  69. X  /* LJ_FONT_ERROR is used to determine if real number attributes (e.g. pitch)
  70. X  ** are the same.  0.1 is currently used because otherwise 16.6 does not match
  71. X  ** with 16.66.  I have no idea how the LaserJet resolves this problem. - C.L.
  72. X  */
  73. X#define LJ_FONT_ERROR 0.1 
  74. X  /* Font attribute priority values */
  75. X#define FAP_ORIENTATION   1024    /* Orientation: landscape/portrait */
  76. X#define FAP_SYM_SET        512    /* Symbol set */
  77. X#define FAP_SPACING        256    /* Spacing: proportional/fixed */
  78. X#define FAP_PITCH          128    /* Pitch (in chars per inch) */
  79. X#define FAP_HEIGHT          64    /* Font height (in points) */
  80. X#define FAP_STYLE           32    /* Style: normal/italic */
  81. X#define FAP_STROKE          16    /* Stroke: -3(light) to 0(normal) to 3(bold) */
  82. X#define FAP_TYPEFACE         8    /* Typeface */
  83. X#define FAP_SOURCE_SOFT      4    /* Source: downloadable "soft" font */
  84. X#define FAP_SOURCE_CART      2    /* Source: cartridge font */
  85. X#define FAP_SOURCE_INT       1    /* Source: internal font */
  86. X
  87. X  /* Local structures and types
  88. X  */
  89. Xtypedef struct {
  90. X    /* Identifier fields */
  91. X  int     source;        /* Font source: where the font is located */
  92. X  int     number;        /* Font number */
  93. X     /* Scaling fields */
  94. X  int     scale;        /* True if scaling should be performed */
  95. X  double  scale_x;        /* % to scale in x direction */
  96. X  double  scale_y;        /* % to scale in y direction */
  97. X    /* LaserJet font ID fields */
  98. X  int     symbol_set;        /* The symbol set of the font */
  99. X  int     spacing;        /* Proportional/fixed */
  100. X  double  pitch;        /* Pitch of fixed or space character */
  101. X  double  point_size;        /* Height of the character */
  102. X  int     style;        /* Upright/italic */
  103. X  int     weight;        /* Stroke weight: -3 to +3 */
  104. X  int     typeface;        /* Which typeface to use */
  105. X  char   *ps_name;        /* The postscript font used for emulation */
  106. X} font_node;
  107. X
  108. X  /* Local variables
  109. X  */
  110. X  /* The table of LaserJet fonts, and the LaserWriter equivalents.
  111. X  **
  112. X  ** Note: the fonts must be listed in priority order, from most important
  113. X  ** to least important.
  114. X  **
  115. X  ** Note: the pitch value for proportional fonts is the width of the space
  116. X  ** character.
  117. X  */
  118. X/*DBX: static */ font_node lj_fonts[] = {
  119. X
  120. X    /*
  121. X    ** Left slot: HP F Font Cartridge
  122. X    */
  123. X    /* L00 (TMS-10): Times-Roman 8U prop. 10pt. upright normal */
  124. X  { LJ_FS_LEFT, 0,        0, 1.20, 1.00, /* Note: scaling is OFF */
  125. X    LJ_SS_8U, LJ_SP_PROPORTIONAL, 17.7, 10.0, LJ_ST_UPRIGHT, 0, LJ_TF_TIMES,
  126. X    "Times-Roman" },
  127. X
  128. X    /* L01 (TMS-10): Times-Roman 0U prop. 10pt. upright normal */
  129. X  { LJ_FS_LEFT, 1,        0, 1.20, 1.00, /* Note: scaling is OFF */
  130. X    LJ_SS_0U, LJ_SP_PROPORTIONAL, 17.7, 10.0, LJ_ST_UPRIGHT, 0, LJ_TF_TIMES,
  131. X    "Times-Roman" },
  132. X
  133. X    /* L02 (TMS-B-10): Times-Roman 0U prop. 10pt. upright bold */
  134. X  { LJ_FS_LEFT, 2,        0, 1.20, 1.00, /* Note: scaling is OFF */
  135. X    LJ_SS_0U, LJ_SP_PROPORTIONAL, 17.7, 10.0, LJ_ST_UPRIGHT, 3, LJ_TF_TIMES,
  136. X    "Times-Bold" },
  137. X
  138. X    /* L03 (TMS-B-10): Times-Roman 8U prop. 10pt. upright bold */
  139. X  { LJ_FS_LEFT, 3,        0, 1.20, 1.00, /* Note: scaling is OFF */
  140. X    LJ_SS_8U, LJ_SP_PROPORTIONAL, 17.7, 10.0, LJ_ST_UPRIGHT, 3, LJ_TF_TIMES,
  141. X    "Times-Bold" },
  142. X
  143. X    /* L04 (TMS-I-10): Times-Roman 0U prop. 10pt. italic normal */
  144. X  { LJ_FS_LEFT, 4,        0, 1.20, 1.00, /* Note: scaling is OFF */
  145. X    LJ_SS_0U, LJ_SP_PROPORTIONAL, 17.7, 10.0, LJ_ST_ITALIC, 0, LJ_TF_TIMES,
  146. X    "Times-Italic" },
  147. X
  148. X    /* L05 (TMS-I-10): Times-Roman 8U prop. 10pt. italic normal */
  149. X  { LJ_FS_LEFT, 5,        0, 1.20, 1.00, /* Note: scaling is OFF */
  150. X    LJ_SS_8U, LJ_SP_PROPORTIONAL, 17.7, 10.0, LJ_ST_ITALIC, 0, LJ_TF_TIMES,
  151. X    "Times-Italic" },
  152. X
  153. X    /* L06 (HELV-B-14.4): Helvetica 0U prop. 14.4pt. upright bold */
  154. X  { LJ_FS_LEFT, 6,        0, 0.00, 0.00, /* Note: scaling is OFF */
  155. X    LJ_SS_0U, LJ_SP_PROPORTIONAL, 15.0, 14.4, LJ_ST_UPRIGHT, 3, LJ_TF_HELV,
  156. X    "Helvetica-Bold" },
  157. X
  158. X    /* L07 (HELV-B-14.4): Helvetica 8U prop. 14.4pt. upright bold */
  159. X  { LJ_FS_LEFT, 7,        0, 0.00, 0.00, /* Note: scaling is OFF */
  160. X    LJ_SS_8U, LJ_SP_PROPORTIONAL, 15.0, 14.4, LJ_ST_UPRIGHT, 3, LJ_TF_HELV,
  161. X    "Helvetica-Bold" },
  162. X
  163. X    /* L08 (TMS-8): Times-Roman 0U prop. 8pt. upright normal */
  164. X  { LJ_FS_LEFT, 8,        0, 1.20, 1.00, /* Note: scaling is OFF */
  165. X    LJ_SS_0U, LJ_SP_PROPORTIONAL, 27.4,  8.0, LJ_ST_UPRIGHT, 0, LJ_TF_TIMES,
  166. X    "Times-Roman" },
  167. X
  168. X    /* L09 (TMS-8): Times-Roman 8U prop. 8pt. upright normal */
  169. X  { LJ_FS_LEFT, 9,        0, 1.20, 1.00, /* Note: scaling is OFF */
  170. X    LJ_SS_8U, LJ_SP_PROPORTIONAL, 27.4,  8.0, LJ_ST_UPRIGHT, 0, LJ_TF_TIMES,
  171. X    "Times-Roman" },
  172. X
  173. X    /* L10 (LP-8.5): Line-Printer 0U 16.6pitch 8.5pt upright normal */
  174. X  { LJ_FS_LEFT, 10,       1, 0.845, 1.00, /* Scaling *****ON***** */
  175. X    LJ_SS_0N, LJ_SP_FIXED,        16.67,  8.5, LJ_ST_UPRIGHT, 0, LJ_TF_LP,
  176. X    "Courier" },
  177. X
  178. X    /* L11 (LP-8.5): Line-Printer 8U 16.6pitch 8.5pt upright normal */
  179. X  { LJ_FS_LEFT, 11,       1, 0.845, 1.00, /* Scaling *****ON***** */
  180. X    LJ_SS_8U, LJ_SP_FIXED,        16.67,  8.5, LJ_ST_UPRIGHT, 0, LJ_TF_LP,
  181. X    "Courier" },
  182. X
  183. X    /*
  184. X    ** Right slot: HP G Font Cartridge
  185. X    */
  186. X
  187. X    /* R00 (PRES-10): Prestige 0U 12pitch 10pt. upright normal */
  188. X  { LJ_FS_RIGHT, 0,       0, 0.00, 0.00, /* Note: scaling is OFF */
  189. X    LJ_SS_0U, LJ_SP_FIXED,        12.0, 10.0, LJ_ST_UPRIGHT, 0, LJ_TF_PRES,
  190. X    "Courier" },
  191. X
  192. X    /* R01 (PRES-10): Prestige 1U 12pitch 10pt. upright normal */
  193. X  { LJ_FS_RIGHT, 1,       0, 0.00, 0.00, /* Note: scaling is OFF */
  194. X    LJ_SS_1U, LJ_SP_FIXED,        12.0, 10.0, LJ_ST_UPRIGHT, 0, LJ_TF_PRES,
  195. X    "Courier" },
  196. X
  197. X    /* R02 (PRES-B-10): Prestige 1U 12pitch 10pt. upright bold */
  198. X  { LJ_FS_RIGHT, 2,       0, 0.00, 0.00, /* Note: scaling is OFF */
  199. X    LJ_SS_1U, LJ_SP_FIXED,        12.0, 10.0, LJ_ST_UPRIGHT, 3, LJ_TF_PRES,
  200. X    "Courier-Bold" },
  201. X
  202. X    /* R03 (PRES-B-10): Prestige 0U 12pitch 10pt. upright bold */
  203. X  { LJ_FS_RIGHT, 3,       0, 0.00, 0.00, /* Note: scaling is OFF */
  204. X    LJ_SS_0U, LJ_SP_FIXED,        12.0, 10.0, LJ_ST_UPRIGHT, 3, LJ_TF_PRES,
  205. X    "Courier-Bold" },
  206. X
  207. X    /* R04 (PRES-I-10): Prestige 1U 12pitch 10pt. italic normal */
  208. X  { LJ_FS_RIGHT, 4,       0, 0.00, 0.00, /* Note: scaling is OFF */
  209. X    LJ_SS_1U, LJ_SP_FIXED,        12.0, 10.0, LJ_ST_ITALIC, 0, LJ_TF_PRES,
  210. X    "Courier-Oblique" },
  211. X
  212. X    /* R05 (PRES-I-10): Prestige 0U 12pitch 10pt. italic normal */
  213. X  { LJ_FS_RIGHT, 5,       0, 0.00, 0.00, /* Note: scaling is OFF */
  214. X    LJ_SS_0U, LJ_SP_FIXED,        12.0, 10.0, LJ_ST_ITALIC, 0, LJ_TF_PRES,
  215. X    "Courier-Oblique" },
  216. X
  217. X    /* R06 (PRES-7): Prestige 1U 16.6pitch 7pt. upright normal */
  218. X  { LJ_FS_RIGHT, 6,       1, 1.03, 1.00, /* Note: scaling is OFF */
  219. X    LJ_SS_1U, LJ_SP_FIXED,        16.67,  7.0, LJ_ST_UPRIGHT, 0, LJ_TF_PRES,
  220. X    "Courier" },
  221. X
  222. X    /* R07 (PRES-7): Prestige 0U 16.6pitch 7pt. upright normal */
  223. X  { LJ_FS_RIGHT, 7,       1, 1.03, 1.00, /* Note: scaling is OFF */
  224. X    LJ_SS_0U, LJ_SP_FIXED,        16.67,  7.0, LJ_ST_UPRIGHT, 0, LJ_TF_PRES,
  225. X    "Courier" },
  226. X
  227. X    /* R08: Line Draw is NOT AVAILABLE */
  228. X/*  "DRAW-12",         "Line-Draw              12    point     12    pitch",*/
  229. X/*  Line draw is not supported! */
  230. X
  231. X    /*
  232. X    ** LaserJet II Internal Fonts
  233. X    */
  234. X
  235. X    /* I00 (COUR-12): Courier 8U 10pitch 12pt. upright normal */
  236. X  { LJ_FS_INTERNAL, 0,    0, 0.00, 0.00, /* Note: scaling is OFF */
  237. X    LJ_SS_8U, LJ_SP_FIXED,        10.0, 12.0, LJ_ST_UPRIGHT, 0, LJ_TF_COUR,
  238. X    "Courier" },
  239. X
  240. X    /* I01 (COUR-12): Courier 10U 10pitch 12pt. upright normal */
  241. X  { LJ_FS_INTERNAL, 1,    0, 0.00, 0.00, /* Note: scaling is OFF */
  242. X    LJ_SS_10U, LJ_SP_FIXED,        10.0, 12.0, LJ_ST_UPRIGHT, 0, LJ_TF_COUR,
  243. X    "Courier" },
  244. X
  245. X    /* I02 (COUR-12): Courier 11U 10pitch 12pt. upright normal */
  246. X  { LJ_FS_INTERNAL, 2,    0, 0.00, 0.00, /* Note: scaling is OFF */
  247. X    LJ_SS_11U, LJ_SP_FIXED,        10.0, 12.0, LJ_ST_UPRIGHT, 0, LJ_TF_COUR,
  248. X    "Courier" },
  249. X
  250. X    /* I03 (COUR-12): Courier 0N 10pitch 12pt. upright normal */
  251. X  { LJ_FS_INTERNAL, 3,    0, 0.00, 0.00, /* Note: scaling is OFF */
  252. X    LJ_SS_0N, LJ_SP_FIXED,        10.0, 12.0, LJ_ST_UPRIGHT, 0, LJ_TF_COUR,
  253. X    "Courier" },
  254. X
  255. X    /* I04 (COUR-B-12): Courier 8U 10pitch 12pt. upright bold */
  256. X  { LJ_FS_INTERNAL, 4,    0, 0.00, 0.00, /* Note: scaling is OFF */
  257. X    LJ_SS_8U, LJ_SP_FIXED,        10.0, 12.0, LJ_ST_UPRIGHT, 3, LJ_TF_COUR,
  258. X    "Courier-Bold" },
  259. X
  260. X    /* I05 (COUR-B-12): Courier 10U 10pitch 12pt. upright bold */
  261. X  { LJ_FS_INTERNAL, 5,    0, 0.00, 0.00, /* Note: scaling is OFF */
  262. X    LJ_SS_10U, LJ_SP_FIXED,        10.0, 12.0, LJ_ST_UPRIGHT, 3, LJ_TF_COUR,
  263. X    "Courier-Bold" },
  264. X
  265. X    /* I06 (COUR-B-12): Courier 11U 10pitch 12pt. upright bold */
  266. X  { LJ_FS_INTERNAL, 6,    0, 0.00, 0.00, /* Note: scaling is OFF */
  267. X    LJ_SS_11U, LJ_SP_FIXED,        10.0, 12.0, LJ_ST_UPRIGHT, 3, LJ_TF_COUR,
  268. X    "Courier-Bold" },
  269. X
  270. X    /* I07 (COUR-B-12): Courier 0N 10pitch 12pt. upright bold */
  271. X  { LJ_FS_INTERNAL, 7,    0, 0.00, 0.00, /* Note: scaling is OFF */
  272. X    LJ_SS_0N, LJ_SP_FIXED,        10.0, 12.0, LJ_ST_UPRIGHT, 3, LJ_TF_COUR,
  273. X    "Courier-Bold" },
  274. X
  275. X    /* I08 (LP-8.5): Line-Printer 8U 16.6pitch 8.5pt. upright normal */
  276. X  { LJ_FS_INTERNAL, 8,    1, 0.845, 1.00, /* Scaling *****ON***** */
  277. X    LJ_SS_8U, LJ_SP_FIXED,        16.67,  8.5, LJ_ST_UPRIGHT, 0, LJ_TF_LP,
  278. X    "Courier" },
  279. X
  280. X    /* I09 (LP-8.5): Line-Printer 10U 16.6pitch 8.5pt. upright normal */
  281. X  { LJ_FS_INTERNAL, 9,    1, 0.845, 1.00, /* Scaling *****ON***** */
  282. X    LJ_SS_10U, LJ_SP_FIXED,        16.67,  8.5, LJ_ST_UPRIGHT, 0, LJ_TF_LP,
  283. X    "Courier" },
  284. X
  285. X    /* Last entry must be nulled out! */
  286. X  { 0, 0,                 0, 0.00, 0.00,
  287. X    0,         0,                    0.0,  0.0, 0,             0, 0,
  288. X    "" }
  289. X};
  290. X
  291. X  /* Local macro definitions
  292. X  */
  293. X
  294. X  /* Local function list
  295. X  */
  296. X
  297. X  /* Function bodies
  298. X  */
  299. X
  300. X  /* lj_get_font() returns in the argument font the closest match to the
  301. X  ** requested font.  The match *never* fails.
  302. X  **
  303. X  ** "Closest match" is defined as the first font in the
  304. X  ** list for which the attributes match.  The attributes are in the
  305. X  ** following priority order:
  306. X  **
  307. X  **        (1) Orientation (always correct because PS has arbitrary rotation)
  308. X  **        (2) Symbol set  (once again, ignored here!)
  309. X  **        (3) Spacing
  310. X  **        (4) Pitch       (ignored if the font is proportional)
  311. X  **        (5) Height
  312. X  **        (6) Style
  313. X  **        (7) Stroke weight
  314. X  **        (8) Typeface
  315. X  **        (9) Soft font        (ignored)
  316. X  **       (10) Cartridge font   (ignored)
  317. X  **       (11) Internal font    (ignored)
  318. X  **
  319. X  ** Priority schemes based on the source of the font (i.e. soft fonts,
  320. X  ** cartridge fonts, or internal fonts) are ignored.  These can be
  321. X  ** duplicated through careful ordering of the list.
  322. X  */
  323. Xvoid
  324. Xlj_match_font(font)
  325. X     ljfont *font;
  326. X{
  327. X  int    match_font;        /* Highest matched font so far */
  328. X  int    match_value;        /* Highest matched value so far */
  329. X  int    curr_value;        /* The current font being tested */
  330. X  int    curr_font;        /* The match value for the current font */
  331. X  double tmp_double;        /* Temporary value */
  332. X
  333. X  curr_font   = 0;
  334. X  match_font  = curr_font;
  335. X  match_value = 0;
  336. X  do{
  337. X    curr_value = 0;
  338. X
  339. X      /* Match the attributes */
  340. X      /* Orientation: *always* matches, because PS allows arbitrary rotation */
  341. X    curr_value += FAP_ORIENTATION;
  342. X      /* Symbol set */
  343. X    if( font->symbol_set == lj_fonts[curr_font].symbol_set ){
  344. X      curr_value += FAP_SYM_SET;
  345. X    }
  346. X      /* Spacing: match to two decimal places */
  347. X    if( font->spacing == lj_fonts[curr_font].spacing ){
  348. X      curr_value += FAP_SPACING;
  349. X    }
  350. X      /* Pitch: ignore if proportional spacing */
  351. X    if( font->spacing == LJ_SP_FIXED ){
  352. X      tmp_double = font->pitch - lj_fonts[curr_font].pitch;
  353. X      if( (-(LJ_FONT_ERROR) <= tmp_double) && (tmp_double <= LJ_FONT_ERROR) ){
  354. X    curr_value += FAP_PITCH;
  355. X      }
  356. X    }
  357. X      /* Height */
  358. X    tmp_double = font->point_size - lj_fonts[curr_font].point_size;
  359. X    if(   (-(LJ_FONT_ERROR) <= tmp_double) && (tmp_double <= LJ_FONT_ERROR) ){
  360. X      curr_value += FAP_HEIGHT;
  361. X    }
  362. X      /* Style: exact match needed */
  363. X    if( font->style == lj_fonts[curr_font].style ){
  364. X      curr_value += FAP_STYLE;
  365. X    }
  366. X      /* Stroke weight: exact match needed */
  367. X    if( font->weight == lj_fonts[curr_font].weight ){
  368. X      curr_value += FAP_STROKE;
  369. X    }
  370. X      /* Typeface: exact match needed */
  371. X    if( font->typeface == lj_fonts[curr_font].typeface ){
  372. X      curr_value += FAP_TYPEFACE;
  373. X    }
  374. X      /* Source soft font: ignored */
  375. X      /* Source cartridge font: ignored */
  376. X      /* Source internal font: ignored */
  377. X
  378. X      /* Check to see if we currently have a better match */
  379. X    if( curr_value > match_value ){
  380. X      match_value = curr_value;
  381. X      match_font  = curr_font;
  382. X    }
  383. X
  384. X    curr_font++;
  385. X  } while( (lj_fonts[curr_font].ps_name[0] != '\0') );
  386. X
  387. X    /* There had *better* be a matched font in match_font by this point.
  388. X    ** If none of the attributes matched, match_font should at least hold
  389. X    ** the default.
  390. X    */
  391. X
  392. X    /* OK. Now copy over *everything* */
  393. X  font->scale      = lj_fonts[match_font].scale;
  394. X  font->scale_x    = lj_fonts[match_font].scale_x;
  395. X  font->scale_y    = lj_fonts[match_font].scale_y;
  396. X  font->symbol_set = lj_fonts[match_font].symbol_set;
  397. X  font->spacing    = lj_fonts[match_font].spacing;
  398. X  if( font->spacing == LJ_SP_FIXED ){
  399. X    font->pitch      = lj_fonts[match_font].pitch;
  400. X  }
  401. X  font->point_size = lj_fonts[match_font].point_size;
  402. X  font->style      = lj_fonts[match_font].style;
  403. X  font->weight     = lj_fonts[match_font].weight;
  404. X  font->typeface   = lj_fonts[match_font].typeface;
  405. X  (void) strcpy(font->ps_name, lj_fonts[match_font].ps_name);
  406. X  font->width      = 1/(lj_fonts[match_font].pitch);
  407. X
  408. X} /* lj_match_font() */
  409. X
  410. X
  411. X
  412. X  /* lj_find_font() finds a font based on the name.  A 0 is returned
  413. X  ** if the search is successful, 1 otherwise.
  414. X  */
  415. Xint
  416. Xlj_find_font(source, number, font)
  417. X     int source, number;  ljfont *font;
  418. X{
  419. X  int found;
  420. X  int counter;
  421. X
  422. X  found = 0;
  423. X  for( counter = 0;
  424. X       !found && !(lj_fonts[counter].source == 0);
  425. X       counter++ ){
  426. X    if(   (source == lj_fonts[counter].source)
  427. X       && (number == lj_fonts[counter].number) ){
  428. X      found = 1;
  429. X      font->scale      = lj_fonts[counter].scale;
  430. X      font->scale_x    = lj_fonts[counter].scale_x;
  431. X      font->scale_y    = lj_fonts[counter].scale_y;
  432. X      font->symbol_set = lj_fonts[counter].symbol_set;
  433. X      font->spacing    = lj_fonts[counter].spacing;
  434. X      if( font->spacing == LJ_SP_FIXED ){
  435. X    font->pitch    = lj_fonts[counter].pitch;
  436. X      }
  437. X      font->point_size = lj_fonts[counter].point_size;
  438. X      font->style      = lj_fonts[counter].style;
  439. X      font->weight     = lj_fonts[counter].weight;
  440. X      font->typeface   = lj_fonts[counter].typeface;
  441. X      (void) strcpy(font->ps_name, lj_fonts[counter].ps_name);
  442. X      font->width      = 1/(lj_fonts[counter].pitch);
  443. X    } /* if */
  444. X  } /* for */
  445. X
  446. X  return( !found );
  447. X} /* lj_find_font() */
  448. SHAR_EOF
  449. $TOUCH -am 0630160790 ljfonts.c &&
  450. chmod 0644 ljfonts.c ||
  451. echo "restore of ljfonts.c failed"
  452. set `wc -c ljfonts.c`;Wc_c=$1
  453. if test "$Wc_c" != "16148"; then
  454.     echo original size 16148, current size $Wc_c
  455. fi
  456. fi
  457. # ============= ljfonts.h ==============
  458. if test X"$1" != X"-c" -a -f 'ljfonts.h'; then
  459.     echo "File already exists: skipping 'ljfonts.h'"
  460. else
  461. echo "x - extracting ljfonts.h (Text)"
  462. sed 's/^X//' << 'SHAR_EOF' > ljfonts.h &&
  463. X/*
  464. X** Project:        lj2ps
  465. X** File:        ljfonts.h
  466. X**
  467. X** Author:        Christopher Lishka
  468. X** Organization:    Wisconsin State Laboratory of Hygiene
  469. X**            Data Processing Dept.
  470. X**
  471. X** Copyright (C) 1990 by Christopher Lishka.
  472. X**
  473. X** This program is free software; you can redistribute it and/or modify
  474. X** it under the terms of the GNU General Public License as published by
  475. X** the Free Software Foundation; either version 1, or (at your option)
  476. X** any later version.
  477. X**
  478. X** This program is distributed in the hope that it will be useful,
  479. X** but WITHOUT ANY WARRANTY; without even the implied warranty of
  480. X** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  481. X** GNU General Public License for more details.
  482. X**
  483. X** You should have received a copy of the GNU General Public License
  484. X** along with this program; if not, write to the Free Software
  485. X** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  486. X*/
  487. X
  488. X#ifndef LJFONTS_H
  489. X#define LJFONTS_H
  490. X
  491. X#include "lj.h"
  492. X
  493. X  /* Global constants
  494. X  */
  495. X
  496. X  /* Global structure and type definitions
  497. X  */
  498. X
  499. X  /* Global variables
  500. X  */
  501. X
  502. X  /* Global macro definitions
  503. X  */
  504. X
  505. X  /* Global functions
  506. X  */
  507. Xextern void  lj_match_font();    /* Get closest match for a laserjet font */
  508. Xextern int   lj_find_font();    /* Find font based on name */
  509. X
  510. X#endif
  511. SHAR_EOF
  512. $TOUCH -am 0630160790 ljfonts.h &&
  513. chmod 0644 ljfonts.h ||
  514. echo "restore of ljfonts.h failed"
  515. set `wc -c ljfonts.h`;Wc_c=$1
  516. if test "$Wc_c" != "1258"; then
  517.     echo original size 1258, current size $Wc_c
  518. fi
  519. fi
  520. echo "End of part 11, continue with part 12"
  521. exit 0
  522.  
  523.