home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 August / macformat-027.iso / mac / Shareware City / Developers / Oberon⁄F / System / Docu / Fonts (.txt) < prev    next >
Encoding:
Oberon Document  |  1994-06-07  |  15.5 KB  |  213 lines  |  [oODC/obnF]

  1. Documents.StdDocumentDesc
  2. Documents.DocumentDesc
  3. Containers.ViewDesc
  4. Views.ViewDesc
  5. Stores.StoreDesc
  6. Documents.ModelDesc
  7. Containers.ModelDesc
  8. Models.ModelDesc
  9. Stores.ElemDesc
  10. TextViews.StdViewDesc
  11. TextViews.ViewDesc
  12. TextModels.StdModelDesc
  13. TextModels.ModelDesc
  14. TextModels.AttributesDesc
  15. Geneva
  16. Geneva
  17. HostPictures.StdViewDesc
  18. Geneva
  19. Dialog
  20. Views
  21. Files
  22. Ports
  23. Domains
  24. Fonts
  25. Stores
  26. Models
  27. Controllers
  28. Geneva
  29. TextRulers.StdRulerDesc
  30. TextRulers.RulerDesc
  31. TextRulers.StdStyleDesc
  32. TextRulers.StyleDesc
  33. TextRulers.AttributesDesc
  34. Geneva
  35. N    base line
  36. ascent
  37. descent
  38. +xO    base line
  39. ascent
  40. descent
  41. Geneva
  42. 5.3 Fonts
  43. DEFINITION Fonts;
  44.     CONST
  45.         mm = 36000;
  46.         point = LONG(12700);
  47.         italic = 0; underline = 1; strikeout = 2;
  48.         normal = 400; bold = 700;
  49.     TYPE
  50.         LONGCHAR = INTEGER;
  51.         Typeface = ARRAY 32 OF CHAR;
  52.         Font = POINTER TO FontDesc;
  53.         FontDesc = RECORD
  54.             typeface-: Typeface;
  55.             size-: LONGINT;
  56.             style-: SET;
  57.             weight-: INTEGER;
  58.             asc, dsc: LONGINT;
  59.             w: LONGINT;
  60.             fingerprint: LONGINT;
  61.             PROCEDURE (f: Font) Init (typeface: Typeface; size: LONGINT;
  62.                                                         style: SET; weight: INTEGER;
  63.                                                         asc, dsc, w, fingerprint: LONGINT);
  64.             PROCEDURE (f: Font) StringWidth (s: ARRAY OF CHAR): LONGINT;
  65.             PROCEDURE (f: Font) LStringWidth (s: ARRAY OF LONGCHAR): LONGINT;
  66.             PROCEDURE (f: Font) IsAlien (): BOOLEAN
  67.         END;
  68.         Directory = POINTER TO DirectoryDesc;
  69.         DirectoryDesc = RECORD
  70.             PROCEDURE (d: Directory) This (typeface: Typeface; size: LONGINT;
  71.                                                                 style: SET; weight: INTEGER): Font;
  72.             PROCEDURE (d: Directory) Default (): Font;
  73.             PROCEDURE (d: Directory) System (): Font
  74.         END;
  75.     VAR dir-, stdDir-: Directory;
  76.     PROCEDURE SetDir (d: Directory);
  77. END Fonts.
  78. A font is a collection of character glyphs, i.e. a collection of distinct visual representations of characters. Visual representations of the same character may differ in size (e.g. 12 point vs. 16 point), style (e.g. plain vs. italic), typeface (e.g. Times vs. Helvetica), and weight (e.g. bold vs. normal).
  79. In Oberon, most distances are measured in universal units. Several important distance values in these units are defined below:
  80.  um    = 36    micrometer
  81.  mm    = 36000    millimeter
  82.  cm    = 10 * mm    centimeter
  83.  m    = 1000 * mm    meter
  84.  inch    = 914400    inch
  85. Font sizes are measured in these universal units as well. The following values are used in connection with font sizes:
  86.  point    = 12700    1/72 inch    (desktop publishing point)
  87.  pica    = 12636    0.351 mm
  88.  didot    = 13500    0.375 mm
  89.  cicero    = 163800    4.55 mm
  90. However, it should be mentioned that in modern typography the millimeter is the dominating measure, followed by the point as established in desktop publishing software.
  91. Module Fonts provides an abstract type Font, which mainly allows to measure the widths of characters and strings in universal units. These measures are completely device-independent. There is no device-specific information (e.g. character bitmap) in a font object. Font objects are only used for measurements and for the identification of a font. In the latter capacity, they can be passed as parameters to output routines. These output routines generate or access (device-dependent) character bitmaps in a way not specified by Oberon.
  92. An application need not be aware whether font bitmaps are stored permanently ("bitmapped fonts") or whether they are generated on demand (using "outline fonts").
  93. The meanings of two important font metrics, namely ascent and descent, are illustrated in the following diagram:
  94. Picture 5.3a  Base Line, Ascent, Descent
  95. Characters of a word are placed side by side on a so-called base line. The ascent measures how far any character of a font may extend above the base line. The descent measures how far any character of a font may extend below the base line. The line spacing is the sum of ascent and descent.
  96. In Oberon, the ascent must be large enough to accomodate oversized characters plus the minimal required distance between lines. Thus the ascent includes "line gap", "internal leading", and "external leading" as defined in other font models.
  97. Not all character codes need to be represented in a font. A character which is not represented in a font is displayed by a special "missing" symbol, e.g. an empty rectangle. Alternatively, Oberon may use another font to display the character.
  98. It is often desirable to display text on the screen in a way which is similar to the way it is printed on paper. This is known as WYSIWYG display (What You See Is What You Get). However, there are several factors which make true WYSIWYG display a problematic proposition.
  99. The most fundamental problem is the large difference between today's screen and printer resolutions. Screens have typical spatial resolutions of about 70 to 100 dpi (dot per inch), while laser printers have resolutions of at least 300 dpi. This large difference forces the programmer to decide whether
  100. - to tune text drawing for maximal legibility on screen, and thereby giving up device-independence and reducing the quality of hard copy, or
  101. - to tune text drawing for maximal precision, which results in reduced legibility on screen due to rounding effects, or
  102. - to give up the strict WYSIWYG requirements to some degree.
  103. All three solutions have their merits and problems, and all three solutions can be found in commercial word processors.
  104. Another problem for pure WYSIWYG display is that not all fonts are available on every machine. This means that a document containing a particular font cannot be shown correctly on a computer where this font is not installed. In order to make it possible to open a document containing such a missing font (without converting this font permanently) a mechanism is provided in Oberon to temporarily substitute a place holder for a missing font, a so-called "alien" font.
  105. A font can be looked up in a font directory. Module Fonts provides an abstract type Directory for this purpose. If the directory cannot find a font, it creates an alien font object. An alien font internally uses an existing font for measurements and display, such that it can be used like any other font.
  106. A particular user-interface typically uses its own system font e.g. for the text in menus or in buttons. Inherently this font looks different on different platforms. Its measures in particular may differ also. On a given platform, system fonts usually don't vary over time. There is a procedure which returns the system font.
  107. An application which needs a font but has no preferences should use the default font. The default font is a system- or user-made choice out of one of the available fonts. The identity of the default font may vary over time.
  108. CONST mm, point
  109. These are the most important font size measures in universal units.
  110. CONST italic, underline, strikeout
  111. Three standard font attributes.
  112. CONST normal, bold
  113. Two major font weights.
  114. TYPE LONGCHAR
  115. Type for 2-byte characters in the Unicode character set.
  116. TYPE Typeface
  117. String type for the typeface name of a font.
  118. TYPE Font
  119. Interface
  120. This is the base type for fonts, which allows to identify fonts and to measure font information in universal units.
  121. Fonts are allocated by font directories.
  122. Fonts are used by models which contain formatted text, by views which draw text, and by commands which operate on text.
  123. Fonts are extended by Oberon, internally.
  124. typeface-: Typeface
  125. The font's typeface name.
  126. size-: LONGINT    size > 0
  127. The font's size in universal units.
  128. style-: SET    subset of {italic, underline, strikeout}
  129. The set of the font's style attributes.
  130. weight-: INTEGER    0 <= weigth <= 1000
  131. A font's weight, i.e. the thickness of the strokes.
  132. asc, dsc: LONGINT    asc >= 0  &  dsc >= 0
  133. The font's ascent and descent.
  134. w: LONGINT    w >= 0
  135. The width of the widest character in the font.
  136. fingerprint: LONGINT
  137. This value is needed to verify a font's version. It is used internally.
  138. PROCEDURE (f: Font) Init (typeface: Typeface; size: LONGINT; style: SET;
  139.                                                 weight: INTEGER; asc, dsc, w, fingerprint: LONGINT)
  140. Initialize font fields.
  141. Init is called by Oberon, internally.
  142. f.size = 0    20    font must not be initialized yet
  143. size > 0    21
  144. style is subset of {italic, underline, strikeout}    22
  145. 0 <= weight <= 1000    23
  146. asc >= 0    24
  147. dsc >= 0    25
  148. w >= 0    26
  149. f.fingerprint = fingerprint
  150. f.typeface = typeface  &  f.size = size  &  f.style = style  &  f.weight = weight
  151. f.asc = asc  &  f.dsc = dsc  &  f.w = w  &  f.size > 0
  152. PROCEDURE (f: Font) StringWidth (s: ARRAY OF CHAR): LONGINT
  153. Interface
  154. Measures the width of a string in universal units.
  155. StringWidth is used by models or views which need to format text.
  156. s is terminated by 0X    index trap
  157. result >= 0    width of string
  158. PROCEDURE (f: Font) LStringWidth (s: ARRAY OF LONGCHAR): LONGINT
  159. Interface
  160. Measures the width of a string in universal units.
  161. LStringWidth is used by models or views which need to format text.
  162. s is terminated by 0H    index trap
  163. result >= 0    width of string
  164. PROCEDURE (f: Font) IsAlien (): BOOLEAN
  165. Interface
  166. Tells whether f is an alien font.  An alien font is returned upon lookup of a font which cannot be found or generated. It is used as a place holder for the missing font. Alien fonts can be displayed, but their metrics are usually not the same as the correct font's metrics and their glyphs usually differ significantly from the correct font's glyphs.
  167. IsAlien is used in commands which inform users about the existence of alien fonts in a document.
  168. TYPE Directory
  169. Interface
  170. Directory for the lookup of fonts.
  171. Font directories are allocated by Oberon.
  172. Font directories are used in models, views, and commands which need to specify a font for later use.
  173. Font directories are extended by Oberon, internally.
  174. PROCEDURE (d: Directory) This (typeface: Typeface; size: LONGINT;
  175.                                                             style: SET; weight: INTEGER): Font
  176. Interface
  177. Returns the font with the attributes (typeface, size, style, weight). If the font information cannot be found or generated, an alien font is returned instead. An alien font has the requested attributes, even though a different font is actually used.
  178. If a font is requested which has the same attributes as another, previously requested font, the directory attempts to return the same font object (i.e. the same pointer value) as it did before. However, if a large number of fonts is used, it may happen that another font object is returned instead. Such an object has the same attributes and provides the same metrics and identical glyphs as the older font object.
  179. This is used to look up a font when specific font attributes are given.
  180. size > 0    20
  181. result # NIL
  182. result.typeface = typeface
  183. result.size = size
  184. result.style = style
  185. result.weight = weight
  186. PROCEDURE (d: Directory) Default (): Font
  187. Interface
  188. Returns the current default font.
  189. Default is used when a font is needed and no specific font attributes are desired.
  190. result # NIL
  191. PROCEDURE (d: Directory) System (): Font
  192. Interface
  193. Returns the system font, which is never an alien font.
  194. System is used by Oberon, internally.
  195. result # NIL  & ~result.IsAlien()
  196. VAR dir-, stdDir-: Directory    dir # NIL  &  stdDir # NIL
  197. Directories for the lookup of fonts.
  198. PROCEDURE SetDir (d: Directory)
  199. Assigns directory.
  200. SetDir is used in configuration routines.
  201. d # NIL    20
  202. stdDir' = NIL
  203.     stdDir = d
  204. stdDir' # NIL
  205.     stdDir = stdDir'
  206. dir = d
  207. TextControllers.StdCtrlDesc
  208. TextControllers.ControllerDesc
  209. Containers.ControllerDesc
  210. Controllers.ControllerDesc
  211. Geneva
  212. Documents.ControllerDesc
  213.