home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / unixtex-6.1b-src.tgz / tar.out / contrib / unixtex / xdvik / font-open.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-28  |  1.5 KB  |  56 lines

  1. /* font-open.c: find font filenames.  This bears no relation (but the
  2.    interface) to the original font_open.c, so I renamed it.  */
  3.  
  4. #include "config.h"
  5.  
  6. #include <kpathsea/c-fopen.h>
  7. #include <kpathsea/tex-glyph.h>
  8.  
  9.  
  10. /* We try for a VF first because that's what dvips does.  Also, it's
  11.    easier to avoid running MakeTeXPK if we have a VF this way.  */
  12.  
  13. FILE *
  14. font_open (font, font_ret, dpi, dpi_ret, dummy, filename_ret)
  15.     _Xconst char *font;
  16.     char **font_ret;
  17.     double dpi;
  18.     int *dpi_ret;
  19.     int dummy;
  20.     char **filename_ret;
  21. {
  22.   FILE *ret;
  23.   char *name = kpse_find_vf (font);
  24.   
  25.   if (name)
  26.     {
  27.       /* VF fonts don't have a resolution, but loadfont will complain if
  28.          we don't return what it asked for.  */
  29.       *dpi_ret = dpi;
  30.       *font_ret = NULL;
  31.     }
  32.   else
  33.     {
  34.       kpse_glyph_file_type file_ret;
  35.       name = kpse_find_glyph (font, (unsigned) (dpi + .5),
  36.                               kpse_any_glyph_format, &file_ret);
  37.       if (name)
  38.         {
  39.           /* If we got it normally, from an alias, or from MakeTeXPK,
  40.              don't fill in FONT_RET.  That tells load_font to complain.  */
  41.           *font_ret
  42.              = file_ret.source == kpse_glyph_source_fallback ? file_ret.name
  43.                : NULL; /* tell load_font we found something good */
  44.           
  45.           *dpi_ret = file_ret.dpi;
  46.         }
  47.       /* If no VF and no PK, FONT_RET is irrelevant? */
  48.     }
  49.   
  50.   /* If we found a name, return the stream.  */
  51.   ret = name ? xfopen (name, FOPEN_R_MODE) : NULL;
  52.   *filename_ret = name;
  53.  
  54.   return ret;
  55. }
  56.