home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 3 / Meeting_Pearls_III.iso / Pearls / texmf / source / driver / util / new_font.h < prev    next >
C/C++ Source or Header  |  1991-08-12  |  11KB  |  375 lines

  1. /*
  2.  ************************************************************************
  3.  *                                    *
  4.  *    new_font.h                    04. Dez. 89    *
  5.  *                                    *
  6.  *    A replacement for the old fontstructure-handling.    (hes)    *
  7.  *                                    *
  8.  ************************************************************************
  9.  */
  10.  
  11. #define NPXLCHARS        256
  12. #define PATH_SIZE        128
  13. #define FONT_NAME_SIZE        60
  14. #define FLIB_NAME_SIZE        60
  15. #define PK_NAME_SIZE        60
  16. /* #define FMT_STRING_SIZE        48 unused */
  17.  
  18. /** **  name of the environment-vars ** **/
  19. #define ENV_PK_DIRS        "PKDIR"
  20. #define ENV_FLIB_DIRS        "FLIBDIR"
  21.  
  22. /** **  default search directories ** **/
  23. #ifdef AMIGA
  24. #define PK_AREA            "TeX:pk"
  25. #define FLIB_AREA        "TeX:FontLib"
  26. #else
  27. #define PK_AREA            "d:\\lib\\fonts\\tex\\fonts"
  28. #define FLIB_AREA        "d:\\lib\\fonts\\tex\\libs"
  29. #endif
  30.  
  31. /** **  default format-strings of the file-names ** **/
  32. #ifdef AMIGA
  33. # define FLIB_STRING        "PK%04d"
  34. # define PK_STRING        "%d/%s.%dpk"
  35. # define BASE_PK_STRING        "%d/%s.%dpk"
  36. # define PKDIR_STRING        "%s.pk"
  37. # define FLIB_FNT_STRING    "%s"
  38. #else
  39. # define FLIB_STRING        "PK%04d"
  40. # define PK_STRING        "%d\\%s"
  41. # define BASE_PK_STRING        "%d\\%s"
  42. # define PKDIR_STRING        "%s.pk"
  43. # define FLIB_FNT_STRING    "%s"
  44. #endif
  45.  
  46. /** **  filenames of the configfiles for the font-definitions ** **/
  47. #define SFONT_DEF_FILE        "showdvi.fnt"
  48. #define DFONT_DEF_FILE        "dviprint.fnt"
  49.  
  50. /** **  begin of a pk-file ** **/
  51. #define PK_MAGIC        (unsigned short)0xF759    /* PK_PRE | ID-Byte (89) */
  52.  
  53.  
  54. /** **  size of copy-buffer for copying font to font-cache (only AMIGA) ** **/
  55. #define CPBUFSIZE        10240    /* damit bekommt man die meisten Fonts auf einmal */
  56.  
  57.  
  58. typedef unsigned short ushort;
  59. typedef unsigned long  ulong;
  60.  
  61.  
  62. /*
  63.  ************************************************************************
  64.  *    definition of the magsteps    0 h 1 1h 2 2h 3 4 5 6 7 8 9    *
  65.  ************************************************************************
  66.  */
  67.  
  68. #define NRMAGS        13
  69.  
  70.  
  71.  
  72. /*
  73.  ************************************************************************
  74.  *    definition of one character                    *
  75.  ************************************************************************
  76.  */
  77.  
  78. struct Char {
  79.         ushort    width;            /* moeglicherweise unnoetig    */
  80.         ushort    height;
  81.         long    xOffset;
  82.         long    yOffset;
  83.         /* long    bytes; */            /* size in bytes of the char    */
  84.         /* die Bitmap des Chars kommt direckt im Anschluss nach sizeof    */
  85.     };
  86.  
  87. #define CHAR_BITMAP(x)    ((char *)(x+1))        /* x must be (struct Char *)    */
  88.  
  89. struct Chars {
  90.         short    pixelwidth;        /* width of the character (h escapement)*/
  91.         long    packed_data;        /* pointer to the pk-data of the char    */
  92.                         /* offset in internal memory        */
  93.     struct    Char    *unpacked;        /* pointer to the unpacked info        */
  94.     };
  95.  
  96.  
  97. /*
  98.  ************************************************************************
  99.  *    definition of a font-library                    *
  100.  ************************************************************************
  101.  */
  102.  
  103. struct Fnt_Lib {
  104.         long    resolution;        /* dpi            */
  105.         long    lru_count;        /* LRU-counter        */
  106.         FILE    *file_ptr;        /* file pointer        */
  107.     struct    dir    directory;        /* directory of the lib */
  108.         char    *format_str;        /* format-string    */
  109.         char    lib_status;        /* look LIB_xxx defines    */
  110.         char    path[PATH_SIZE];    /* directory of the lib    */
  111.     };
  112.  
  113.         /* if format_str == NULL => use the default format str    */
  114.  
  115.  
  116. /*
  117.  ************************************************************************
  118.  *    current states of a font-library                *
  119.  ************************************************************************
  120.  */
  121.  
  122. #define LIB_NONE        (char)0        /* init            */
  123. #define LIB_PATH_DEFINED    (char)1        /* path defined by user    */
  124. #define LIB_READ_CLOSED        (char)2        /* lib dir read, closed    */
  125. #define LIB_OPEND        (char)3        /* library opend    */
  126. #define LIB_NOT_EXISTS        (char)4        /* library dosn't exist    */
  127.  
  128.  
  129. /*
  130.  ************************************************************************
  131.  *    definition of a PK-directory                    *
  132.  ************************************************************************
  133.  */
  134.  
  135. struct PK_Dir {
  136.         char    *format_str;        /* format-string    */
  137.         char    path[PATH_SIZE];    /* pk-directory        */
  138.     };
  139.  
  140. /*
  141.  ************************************************************************
  142.  *    where can a font be found                    *
  143.  ************************************************************************
  144.  */
  145.  
  146. union Fnt_Loc {
  147.     struct    Fnt_Lib    *fnt_library;        /* ptr to library    */
  148.     struct    PK_Dir    *pk_directory;        /* ptr to directory str */
  149.     };
  150.  
  151.  
  152. /*
  153.  ************************************************************************
  154.  *    common elements of a fontGROUP                    *
  155.  ************************************************************************
  156.  */
  157.  
  158. struct CommonFontGroups {
  159.         long    tfmw[NPXLCHARS];  /* tfmw of font-group    */
  160.         char    fnt_name[1];      /* e.g. cmr10        */
  161.  
  162.     };
  163.  
  164. /*
  165.  ************************************************************************
  166.  *    common elements of a font                    *
  167.  ************************************************************************
  168.  */
  169.  
  170. struct CommonFontElems {
  171.     struct CommonFontGroups    *fnt_group;        /* def. of font-group    */
  172.         long        where_in_lib;        /* offset in lib    */
  173.         long        fnt_length;        /* length of PK-File    */
  174.         long        resolution;        /* dpi            */
  175.         long        resolution5;        /* dpi * 5        */
  176.         long        lru_count;        /* LRU-counter        */
  177.         long        *ch_start_bm;        /* start char-bitmap    */
  178.         ulong        ch_len;            /* length char-bitmap    */
  179.     union    Fnt_Loc        location;        /* define font location */
  180.     struct    Chars        ch[NPXLCHARS];        /* char definitions    */
  181.         short        maxchars;        /* nr of chars in the font     */
  182.         char        fnt_status;        /* look FNT_xxx defines    */
  183.         char        copied;            /* needed during font removing    */
  184.         char        where_is_font;        /* is in lib        */
  185.         char        was_loadet;        /* set to true at the first load*/
  186.         };
  187.  
  188. /*
  189.  ************************************************************************
  190.  *    defines for where_is_font                    *
  191.  ************************************************************************
  192.  */
  193. #define WHERE_NONE        0
  194. #define WHERE_LIB        1
  195. #define WHERE_PK        2
  196. #define WHERE_PKDIR        3
  197.  
  198. /*
  199.  ************************************************************************
  200.  *    definition of a font                        *
  201.  ************************************************************************
  202.  */
  203.  
  204. struct Font {
  205.         long        fnt_number;        /* depends on DVI-File    */
  206.         long        orig_dpi;        /* original resolution  */
  207.         long        space_faktor;        /* space faktor        */
  208.         long        design_faktor;        /* design faktor    */
  209.         long        chksum;            /* font checksum    */
  210.         long        ctfmw[NPXLCHARS];    /* this is faster       */
  211.     struct    CommonFontElems *common;        /* common elems    for font sharing */
  212.         char        ctfmw_valid;        /* are ctfm's valid ?   */
  213.     };
  214.  
  215.  
  216. /*
  217.  ************************************************************************
  218.  *    current states of a font                    *
  219.  ************************************************************************
  220.  */
  221.  
  222. #define FNT_NONE        (char)0        /* init            */
  223. #define FNT_PATH_DEFINED    (char)1        /* path defined by user */
  224. #define FNT_FOUND        (char)2        /* path correct        */
  225. #define FNT_DEFINED        (char)3        /* font defined     */
  226. #define FNT_LOADED        (char)4        /* font in memory    */
  227. #define FNT_DEFINED_OLOADED    (char)5        /* defined and old lo.    */
  228. #define FNT_OLD_LOADED        (char)6        /* old font in memory    */
  229. #define FNT_NOT_EXISTS        (char)7        /* font doesn't exists    */
  230.  
  231.  
  232. #ifdef OLD_NOFONT
  233. /* Not needed, because of  FNT_NOT_EXISTS for `fnt_status' */
  234.  
  235. /*
  236.  ************************************************************************
  237.  *    list of all fonts which can't be found                *
  238.  ************************************************************************
  239.  */
  240.  
  241. struct noFont {
  242.     struct    noFont    *next;
  243.         int    resolution;    /* dpi            */
  244.         char    fnt_name[1];    /* name of the font    */
  245.     };
  246. #endif
  247.  
  248.  
  249. /*
  250.  ************************************************************************
  251.  *    search element for the fontlibs/pk-directories    (Env-Vars)    *
  252.  ************************************************************************
  253.  */
  254.  
  255. struct SeaEle {
  256.     struct    SeaEle    *next_ele;
  257.         char    *path;
  258.     };
  259.  
  260.  
  261. /*
  262.  ************************************************************************
  263.  *    searchlist for the fontlibs/pk-directories  (Env-Vars)        *
  264.  ************************************************************************
  265.  */
  266.  
  267. struct SeaLst {
  268.     struct    SeaEle    *first_ele;
  269.         long    number;
  270.     };
  271.  
  272.  
  273.  
  274.  
  275. /*
  276.  ************************************************************************
  277.  *    search element for the pk-directories with dpi  (Def-File)    *
  278.  ************************************************************************
  279.  */
  280.  
  281. struct SeaEleDpi {
  282.     struct    SeaEleDpi    *next_ele;
  283.         long        hdpi;            /* dpi of the pk-dir    */
  284.         long        vdpi;            /* vert-dpi        */
  285.         char        *path;            /* path of the pk-dir    */
  286.         char        *format_str;        /* format-string    */
  287.     };
  288.  
  289.  
  290. /*
  291.  ************************************************************************
  292.  *    searchlist for the pk-directories with dpi  (Def-File)        *
  293.  ************************************************************************
  294.  */
  295.  
  296. struct SeaLstDpi {
  297.     struct    SeaEleDpi    *first_ele;
  298.         long        number;
  299.     };
  300.  
  301.  
  302. /*
  303.  ************************************************************************
  304.  *    list of all defined/loaded/... font libraries            *
  305.  ************************************************************************
  306.  */
  307.  
  308. struct LibLst {
  309.     struct    LibLst    *next_lib;
  310.     struct    Fnt_Lib    flib;
  311.     };
  312.  
  313.  
  314. /*
  315.  ************************************************************************
  316.  *    list of all defined/loaded/... fonts                *
  317.  ************************************************************************
  318.  */
  319.  
  320. struct FontLst {
  321.     struct    FontLst    *next_font;
  322.     struct    Font    font;
  323.     };
  324.  
  325.  
  326. /*
  327.  ************************************************************************
  328.  *    list of all font-groups                        *
  329.  ************************************************************************
  330.  */
  331.  
  332. struct GroupLst {
  333.     struct    GroupLst        *next_group;
  334.     struct    CommonFontGroups    fnt_group;
  335.     };
  336.  
  337.  
  338. /*
  339.  ************************************************************************
  340.  *    what driver types exists                    *
  341.  ************************************************************************
  342.  */
  343.  
  344. #define DRIVER_TYPE_SHOWDVI    0
  345. #define DRIVER_TYPE_DVIPRINT    1
  346.  
  347.  
  348. /*
  349.  ************************************************************************
  350.  *    global font management                        *
  351.  ************************************************************************
  352.  */
  353.  
  354. struct FontMan {
  355. #ifdef OLD_NOFONT
  356.     struct    noFont      *noFontList;            /* fonts can't be found */
  357. #endif
  358.     struct    SeaLst        s_list_flib;        /* pathes for fontlibs    */
  359.     struct    SeaLst        s_list_pkdirs;        /* pathes for pk-dirs    */
  360.     struct    SeaLstDpi   s_list_pkdpi;         /* pathes for pk + dpi    */
  361.     struct    SeaLstDpi   s_list_base_pkdpi;         /* pathes for pk + Bdpi    */
  362.     struct    FontLst       *font_list;            /* all fonts        */
  363.     struct    LibLst       *flib_list;            /* all font-libraries    */
  364.     struct    GroupLst   *group_list;            /* all font-groups    */
  365.     long            unpacked_mem;        /* mem used from chars    */
  366.     short            files_left;            /* files to open    */
  367.     char           *flib_fmt;            /* format-string     */
  368.     char           *pk_fmt;            /* format-string     */
  369.     char           *pkdir_fmt;            /* format-string     */
  370.     char           *basepkdir_fmt;        /* format-string     */
  371.     char           *flib_fnt_fmt;        /* format string    */
  372.     char            driver_type;        /* driver-type        */
  373.     };
  374.  
  375.