/contrib/groff/src/include/font.h

https://bitbucket.org/freebsd/freebsd-head/ · C++ Header · 124 lines · 93 code · 11 blank · 20 comment · 0 complexity · fa4a110bc8fd7fe1c9e94295699227e0 MD5 · raw file

  1. // -*- C++ -*-
  2. /* Copyright (C) 1989, 1990, 1991, 1992, 2002, 2004
  3. Free Software Foundation, Inc.
  4. Written by James Clark (jjc@jclark.com)
  5. This file is part of groff.
  6. groff is free software; you can redistribute it and/or modify it under
  7. the terms of the GNU General Public License as published by the Free
  8. Software Foundation; either version 2, or (at your option) any later
  9. version.
  10. groff is distributed in the hope that it will be useful, but WITHOUT ANY
  11. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  13. for more details.
  14. You should have received a copy of the GNU General Public License along
  15. with groff; see the file COPYING. If not, write to the Free Software
  16. Foundation, 51 Franklin St - Fifth Floor, Boston, MA 02110-1301, USA. */
  17. typedef void (*FONT_COMMAND_HANDLER)(const char *, const char *,
  18. const char *, int);
  19. struct font_kern_list;
  20. struct font_char_metric;
  21. struct font_widths_cache;
  22. class font {
  23. public:
  24. enum {
  25. LIG_ff = 1,
  26. LIG_fi = 2,
  27. LIG_fl = 4,
  28. LIG_ffi = 8,
  29. LIG_ffl = 16
  30. };
  31. virtual ~font();
  32. int contains(int index);
  33. int is_special();
  34. int get_width(int index, int point_size);
  35. int get_height(int index, int point_size);
  36. int get_depth(int index, int point_size);
  37. int get_space_width(int point_size);
  38. int get_character_type(int index);
  39. int get_kern(int index1, int index2, int point_size);
  40. int get_skew(int index, int point_size, int slant);
  41. int has_ligature(int);
  42. int get_italic_correction(int index, int point_size);
  43. int get_left_italic_correction(int index, int point_size);
  44. int get_subscript_correction(int index, int point_size);
  45. int get_code(int i);
  46. const char *get_special_device_encoding(int index);
  47. const char *get_name();
  48. const char *get_internal_name();
  49. const char *get_image_generator();
  50. static int scan_papersize(const char *, const char **, double *, double *);
  51. static font *load_font(const char *, int * = 0, int = 0);
  52. static void command_line_font_dir(const char *path);
  53. static FILE *open_file(const char *name, char **pathp);
  54. static int load_desc();
  55. static int name_to_index(const char *);
  56. static int number_to_index(int);
  57. static FONT_COMMAND_HANDLER
  58. set_unknown_desc_command_handler(FONT_COMMAND_HANDLER);
  59. static int res;
  60. static int hor;
  61. static int vert;
  62. static int unitwidth;
  63. static int paperwidth;
  64. static int paperlength;
  65. static const char *papersize;
  66. static int biggestfont;
  67. static int spare2;
  68. static int sizescale;
  69. static int tcommand;
  70. static int unscaled_charwidths;
  71. static int pass_filenames;
  72. static int use_charnames_in_special;
  73. static const char *image_generator;
  74. static const char **font_name_table;
  75. static const char **style_table;
  76. static const char *family;
  77. static int *sizes;
  78. private:
  79. unsigned ligatures;
  80. font_kern_list **kern_hash_table;
  81. int space_width;
  82. int *ch_index;
  83. int nindices;
  84. font_char_metric *ch;
  85. int ch_used;
  86. int ch_size;
  87. int special;
  88. char *name;
  89. char *internalname;
  90. double slant;
  91. font_widths_cache *widths_cache;
  92. static FONT_COMMAND_HANDLER unknown_desc_command_handler;
  93. enum { KERN_HASH_TABLE_SIZE = 503 };
  94. void add_entry(int index, const font_char_metric &);
  95. void copy_entry(int new_index, int old_index);
  96. void add_kern(int index1, int index2, int amount);
  97. static int hash_kern(int i1, int i2);
  98. void alloc_ch_index(int);
  99. void extend_ch();
  100. void compact();
  101. static int scale(int w, int pointsize);
  102. static int unit_scale(double *value, char unit);
  103. virtual void handle_unknown_font_command(const char *command,
  104. const char *arg,
  105. const char *file, int lineno);
  106. protected:
  107. font(const char *);
  108. int load(int * = 0, int = 0);
  109. };