On this page:
make-object
get-face
get-family
get-font-id
get-hinting
get-point-size
get-size
get-size-in-pixels
get-smoothing
get-style
get-underlined
get-weight
screen-glyph-exists?

class

font% : class?

  superclass: object%

A font is an object which determines the appearance of text, primarily when drawing text to a device context. A font is determined by seven properties:

To avoid creating multiple fonts with the same characteristics, use the global font-list% object the-font-list.

See also font-name-directory<%>.

Changed in version 1.2 of package draw-lib: Defined “points” as (/ 96 72) pixels on Windows, independent of the screen resolution.
Changed in version 1.14: Changed “weight” to allow integer values and the symbols 'thin, 'ultralight, 'semilight, 'book, 'medium, 'semibold, 'ultrabold, 'heavy, and 'ultraheavy.

constructor

(make-object font%)  (is-a?/c font%)

(make-object font% size    
  family    
  [style    
  weight    
  underline?    
  smoothing    
  size-in-pixels?    
  hinting])  (is-a?/c font%)
  size : (real-in 0.0 1024.0)
  family : font-family/c
  style : font-style/c = 'normal
  weight : font-weight/c = 'normal
  underline? : any/c = #f
  smoothing : font-smoothing/c = 'default
  size-in-pixels? : any/c = #f
  hinting : font-hinting/c = 'aligned
(make-object font% size    
  face    
  family    
  [style    
  weight    
  underline?    
  smoothing    
  size-in-pixels?    
  hinting])  (is-a?/c font%)
  size : (real-in 0.0 1024.0)
  face : string?
  family : font-family/c
  style : font-style/c = 'normal
  weight : font-weight/c = 'normal
  underline? : any/c = #f
  smoothing : font-smoothing/c = 'default
  size-in-pixels? : any/c = #f
  hinting : font-hinting/c = 'aligned
When no arguments are provided, creates an instance of the default font. If no face name is provided, the font is created without a face name.

See font% for information about family, style, weight, smoothing, size-in-pixels?, and hinting. font-name-directory<%>.

See also make-font.

Changed in version 1.4 of package draw-lib: Changed size to allow non-integer and zero values.
Changed in version 1.14: Changed weight to allow integer values and the symbols 'thin, 'ultralight, 'semilight, 'book, 'medium, 'semibold, 'ultrabold, 'heavy, and 'ultraheavy.

method

(send a-font get-face)  (or/c string? #f)

Gets the font’s face name, or #f if none is specified.

method

(send a-font get-family)  font-family/c

Gets the font’s family. See font% for information about families.

method

(send a-font get-font-id)  exact-integer?

Gets the font’s ID, for use with a font-name-directory<%>. The ID is determined by the font’s face and family specifications, only.

method

(send a-font get-hinting)  font-hinting/c

Gets the font’s hinting. See font% for information about hinting.

method

(send a-font get-point-size)  (integer-in 1 1024)

Gets the font’s size rounded to the nearest non-zero integer. Despite the method’s name, the result is in either logical units or points, depending on the result of get-size-in-pixels.

See get-size, instead. The get-point-size method is provided for backward compatibility.

method

(send a-font get-size)  (real-in 0.0 1024.0)

Gets the font’s size (roughly the height). The size is in either logical units or points, depending on the result of get-size-in-pixels.

Due to space included in a font by a font designer, a font tends to generate text that is slightly taller than the nominal size.

Added in version 1.4 of package draw-lib.

method

(send a-font get-size-in-pixels)  boolean?

Returns #t if the size reported by get-point-size is in logical drawing units, #f if it is in points.

For a size in points and a screen or bitmap drawing context, the logical height depends on the resolution of the screen.

method

(send a-font get-smoothing)  font-smoothing/c

Gets the font’s anti-alias smoothing mode. See font% for information about smoothing.

method

(send a-font get-style)  font-style/c

Gets the font’s slant style. See font% for information about styles.

method

(send a-font get-underlined)  boolean?

Returns #t if the font is underlined or #f otherwise.

method

(send a-font get-weight)  font-weight/c

Gets the font’s weight. See font% for information about weights.

method

(send a-font screen-glyph-exists? c    
  [for-label?])  boolean?
  c : char?
  for-label? : any/c = #f
Returns #t if the given character has a corresponding glyph when drawing to the screen or a bitmap, #f otherwise.

If the second argument is true, the result indicates whether the glyph is available for control labels. Otherwise, it indicates whether the glyph is available for dc<%> drawing.

For dc<%> drawing, due to automatic font substitution when drawing or measuring text, the result of this method does not depend on this font’s attributes (size, face, etc.). The font’s attributes merely provide a hint for the glyph search.

See also glyph-exists? .