g_her_metr.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /* This file is part of the GNU plotutils package. Copyright (C) 1995,
  2. 1996, 1997, 1998, 1999, 2000, 2005, 2008, Free Software Foundation, Inc.
  3. The GNU plotutils package is free software. You may redistribute it
  4. and/or modify it under the terms of the GNU General Public License as
  5. published by the Free Software foundation; either version 2, or (at your
  6. option) any later version.
  7. The GNU plotutils package is distributed in the hope that it will be
  8. useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. General Public License for more details.
  11. You should have received a copy of the GNU General Public License along
  12. with the GNU plotutils package; see the file COPYING. If not, write to
  13. the Free Software Foundation, Inc., 51 Franklin St., Fifth Floor,
  14. Boston, MA 02110-1301, USA. */
  15. /* This header file gives the metrics for the vector fonts. */
  16. /* Our choice for stroke width, in terms of virtual pixels. This number is
  17. magic: just slightly greater than sqrt(2), so that adjacent strokes that
  18. are inclined at a 45 degree angle will overlap as they should.
  19. (According to ``Calligraphy for Computers'', the Hershey fonts were
  20. designed to be drawn by an electron beam the intensity of which fell to
  21. 50% at a transverse displacement of one unit.) */
  22. #define HERSHEY_STROKE_WIDTH 1.42
  23. /* This value gives good results for the Japanese characters (Kana and
  24. Kanji). */
  25. #define HERSHEY_ORIENTAL_STROKE_WIDTH 1.175
  26. /* According to Allen Hershey, 1 em = 32 virtual pixels for his alphabets
  27. of principal size. But taking into account the width of the strokes
  28. (nominally 1 virtual pixel), if the characters are thought of as resting
  29. on a baseline, the baseline (and the capline, etc.) should be located at
  30. half-integer values of the vertical coordinate. That changes things
  31. slightly (an em should be 33 virtual pixels, not 32).
  32. Incidentally his recommended spacing between lines is 40 pixels (24 for
  33. indexical size), i.e., 1.2 em or so (1 em is the minimum possible
  34. spacing).
  35. */
  36. /* Dimensions for characters in principal [large] size. The `centerline'
  37. is located at y=0, in the original coordinate system. The `topline' and
  38. `bottomline' are determined by the tallest characters, which are
  39. parentheses, brackets, and braces. */
  40. #define HERSHEY_LARGE_BASELINE (-9.5) /* relative to centerline */
  41. #define HERSHEY_LARGE_CAPLINE 12.5 /* relative to centerline */
  42. #define HERSHEY_LARGE_TOPLINE 16.5 /* relative to centerline */
  43. #define HERSHEY_LARGE_BOTTOMLINE -16.5 /* relative to centerline */
  44. #define HERSHEY_LARGE_CAPHEIGHT 22 /* i.e. capline - baseline */
  45. #define HERSHEY_LARGE_ASCENT 26 /* i.e. topline - baseline */
  46. #define HERSHEY_LARGE_DESCENT 7 /* i.e. baseline - bottomline */
  47. #define HERSHEY_LARGE_HEIGHT (HERSHEY_LARGE_ASCENT + HERSHEY_LARGE_DESCENT)
  48. #define HERSHEY_LARGE_EM 33
  49. /* Dimensions for characters in indexical [medium] size. The `centerline'
  50. is located at y=0, in the original coordinate system. The `topline' and
  51. `bottomline' are determined by the tallest characters, which are
  52. parentheses, brackets, and braces. */
  53. #define HERSHEY_MEDIUM_BASELINE (-6.5) /* relative to centerline */
  54. #define HERSHEY_MEDIUM_CAPLINE 7.5 /* relative to centerline */
  55. #define HERSHEY_MEDIUM_TOPLINE 10.5 /* relative to centerline */
  56. #define HERSHEY_MEDIUM_BOTTOMLINE -10.5 /* relative to centerline */
  57. #define HERSHEY_MEDIUM_CAPHEIGHT 14 /* i.e. capline - baseline */
  58. #define HERSHEY_MEDIUM_ASCENT 17 /* i.e. topline - baseline */
  59. #define HERSHEY_MEDIUM_DESCENT 4 /* i.e. baseline - bottomline */
  60. #define HERSHEY_MEDIUM_HEIGHT (HERSHEY_MEDIUM_ASCENT + HERSHEY_MEDIUM_DESCENT)
  61. #define HERSHEY_MEDIUM_EM 21
  62. /* Dimensions for characters in cartographic [small] size. The
  63. `centerline' is located at y=0, in the original coordinate system. The
  64. `topline' and `bottomline' are determined by the tallest characters,
  65. which are parentheses, brackets, and braces. In the cartographic size
  66. there are only parentheses, and unlike the other two sizes they are not
  67. symmetric about y=0 (since they will surround only upper-case letters;
  68. there are no lower-case letters in cartographic). */
  69. #define HERSHEY_SMALL_BASELINE (-4.5) /* relative to centerline */
  70. #define HERSHEY_SMALL_CAPLINE 5.5 /* relative to centerline */
  71. #define HERSHEY_SMALL_TOPLINE 6.5 /* relative to centerline */
  72. #define HERSHEY_SMALL_BOTTOMLINE -5.5 /* relative to centerline */
  73. #define HERSHEY_SMALL_CAPHEIGHT 10 /* i.e. capline - baseline */
  74. #define HERSHEY_SMALL_ASCENT 11 /* i.e. topline - baseline */
  75. #define HERSHEY_SMALL_DESCENT 1 /* i.e. baseline - bottomline */
  76. #define HERSHEY_SMALL_HEIGHT (HERSHEY_SMALL_ASCENT + HERSHEY_SMALL_DESCENT)
  77. #define HERSHEY_SMALL_EM 12
  78. /* Vertical positionings (in alabel_str.c) are now based on the assumption
  79. that all characters we are dealing with are of principal [large] size.
  80. I see no graceful way to handle positionings relative to the baseline
  81. for the other two sizes. Of course, centered positioning will work
  82. perfectly, since the Hershey glyphs were designed for that. */
  83. #define HERSHEY_BASELINE HERSHEY_LARGE_BASELINE
  84. #define HERSHEY_CAPHEIGHT HERSHEY_LARGE_CAPHEIGHT
  85. #define HERSHEY_ASCENT HERSHEY_LARGE_ASCENT
  86. #define HERSHEY_DESCENT HERSHEY_LARGE_DESCENT
  87. #define HERSHEY_HEIGHT HERSHEY_LARGE_HEIGHT
  88. #define HERSHEY_EM HERSHEY_LARGE_EM
  89. /* The scaling between distances in Hershey units and distances in user
  90. coordinates. Idea is that the font size (i.e. the nominal minimum
  91. inter-line spacing) corresponds to HERSHEY_LARGE_EM Hershey units. */
  92. #define HERSHEY_UNITS_TO_USER_UNITS(size) \
  93. ((size)*(_plotter->drawstate->true_font_size)/(HERSHEY_EM))
  94. /************************************************************************/
  95. /* Some miscellaneous information on typesetting mathematics, taken from
  96. Allen Hershey's 1969 TR (see g_her_glyph.c):
  97. Subscripts and superscripts, in math text, should be in indexical size.
  98. The centerline of subscripts/superscripts would be lowered/raised by 10
  99. vertical units.
  100. [In principal size the centerline is 9.5 units above the baseline; in
  101. indexical size the centerline is 6.5 units above the baseline. So when
  102. going to subscripts, the baseline should be lowered by 7 units; when
  103. going to superscripts, the baseline should be raised by 13 units. This
  104. is not actually the scheme we use; see alabel_str.c. -- rsm]
  105. In math text the quantity being supplied with a sub/superscript is
  106. typically an italic character. The transitions principal->superscript
  107. and subscript->principal are accordingly accompanied by 2 add'l units of
  108. horizontal space.
  109. In math text, conjuctive/predicative signs should be given a extra
  110. spacing of 1/2 en (i.e. 1/4 em), i.e. 8 units in principal size, to
  111. either side. This is accomplished by glyph 2198 (or 1198, in indexical
  112. size).
  113. Case fractions (e.g. \frac34) are formed by raising/lowering
  114. indexical-size characters by 12 vertical units; in mathematical text,
  115. they should be given a small (4-unit) spacing to either side.
  116. Simple limits, for sum and integral signs, are in indexical size, and
  117. are raised/lowered by 24 units. */
  118. /************************************************************************/