Fonts

Font | SystemFont

 

Font
class : Object
  • DESCRIPTION
    • Manages a bitmapped font. A font loads png or jpeg images containing font strips, breaks up the letters, arranges them onto square textures, and draws the images piece by piece as needed.
    • Fonts can be loaded as proportional or non-proportional. All letters in a font must have the same height (though parts of that area can be blank/transparent). The drawing origin of every character is the top-left corner.
    • The image width of a non-proportional font is divided by the number of characters in it to determine the character width.
    • A proportional font has a single-pixel-high band of alternating colors in the topmost row. The length of any contiguous patch of the same color determines the width of the character underneath. The actual color used does not matter.
    • Since font strips tend to be images that are too long for texture hardware to support, every font is automatically broken up and laid out on square textures up to 256x256 in size. Any empty pixels around each letter are removed before laying out the letter on a texture.
    • Either point filtering or linear filtering can be selected for a font. If linear filtering is chosen, an extra outline of padding is added around each letter before it is laid out to avoid color bleeding.
    • Copy and paste the following letter strip in Photoshop or another paint program to get started on a font strip. Notice the first character is a space; if you accidentally leave it out then all your letters will be one position off.
    •  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~
      
  • PROPERTIES
    • height : Int32
      • The original pixel height of each character in the font.
    • color : Color
      • The multiplier for each pixel in this font as it's drawn. The default color of Color(255,255,255,255) ensures that the font will appear "normal". A color of Color(255,255,0) would not draw any of the blue channel, making a grey-scale letter appear to be tinted yellow. The 'alpha' value is applied to the color as the letters are drawn.
    • scale : Vector2
      • The size multiplier for rendering, (1.0,1.0) by default. Setting "scale = Vector2(2.0,0.5)" would cause the font to render at twice the width and half the height.
    • characters : HashTable<<Char,FontCharacter>>
  • METHODS
    • init(String filename[,FontStyle style][,String mapping])
      • Intializes this font from characters in the given font strip.
      • Parameters:
          filename
            A png or jpeg file containing a strip of characters.
        
          style
            Any combination of FontStyle categories.
        
          mapping
            A string of characters specifying the Unicode value of
            each character in the font strip.  The default is a
            string of 95 characters ranging from ' ' (space) to
            '~'.
        
        

        If you want to create a single font out of several different font strips, use a FontBuilder instead.

    • init(Bitmap bitmap[,FontStyle style][,String mapping])
    • init(HashTable<<Char,FontCharacter>> init:characters,Int32 init:height)
      • Initializes this font with an existing lookup table of Char->FontCharacter mappings and a font height.
    • alpha().Int32
      • Alpha property-get method - returns the alpha component (0-255) of the current color multiplier.
    • alpha(Int32 new_alpha)
      • Alpha property-set method - sets the alpha component of this image's color multiplier.
      • new_alpha should be 0 (transparent) through 255 (opaque).
    • height().Real64
      • Height property-get. Returns the original pixel height times the y-scale value.
    • scaled(Vector2 new_scale)
      • Scale property-set.
    • scaled(Real64 uniform_scale)
      • Scale property-set.
    • draw(String st,Vector2 pos)
      • Draws the given string of characters to the screen with the top-left corner of the first character at the given position.
    • draw_center(String st,Vector2 pos)
      • Draws the given string to the screen with the top-center of all the characters at the given position.
    • draw_center(String st,Vector2 pos,Real64 field_width)
      • Draws the given string centered in the given field width. 'pos' is the top-left corner of the field.
    • draw_right(String st,Vector2 pos,Real64 field_width)
      • Draws the given string right-justified in a field with the given top-left 'pos' and width.
    • draw_right(String st,Vector2 pos)
      • Draws the given string right-justified with its right edge at 'pos'.
    • draw_line(String st,Vector2 pos)
      • Internal use. Draws a single line of text with its top-left corner at position 'pos'.
    • text_width_of(String text).Real64
      • Returns the render width of 'text' in pixels, taking the current scale into account.
    • text_width_of(Char ch).Real64
      • Returns the render width of 'ch' in pixels, taking the current scale into account.
    • adjust_character_widths(Int32 amount)
      • Adjusts the logical widths of all the characters in this font. A positive value will space characters further apart while a negative value will scoot them closer together.
    • word_wrap(String st,Int32 pixel_width).String[]
      • Returns a word-wrapped version of this string as a list of lines. Existing newlines characters will cause a new line to begin immediately. Spaces immediately following existing newline characters are preserved.
    • init_object()
    • hash_code().Int32
    • create_duplicate().Object
    • to_String().String
    • op==(Object other).Logical {multimethod}
    • op<>(Object other).Logical {multimethod}
    • type_name().String : native
    • runtime_type().RuntimeType : native
    • runtime_properties().RuntimeProperties
    • runtime_methods().RuntimeMethods

 

SystemFont
deferred singleton class : Font, ResourceGroup
  • DESCRIPTION
    • A monospaced, 17 pixel-high font.
  • PROPERTIES
    • height : Int32
      • The original pixel height of each character in the font.
    • color : Color
      • The multiplier for each pixel in this font as it's drawn. The default color of Color(255,255,255,255) ensures that the font will appear "normal". A color of Color(255,255,0) would not draw any of the blue channel, making a grey-scale letter appear to be tinted yellow. The 'alpha' value is applied to the color as the letters are drawn.
    • scale : Vector2
      • The size multiplier for rendering, (1.0,1.0) by default. Setting "scale = Vector2(2.0,0.5)" would cause the font to render at twice the width and half the height.
    • characters : HashTable<<Char,FontCharacter>>
    • count : Int32
    • index : Int32
    • is_loaded : Logical
    • is_permanent : Logical
  • METHODS
    • init()
    • load()
    • load_next-inner().Logical
    • unload-inner()
    • num_remaining().Int32
    • load_next().Logical
    • unload()
    • count().Int32
    • count(Int32 count.1241)
    • index().Int32
    • index(Int32 index.1242)
    • is_loaded().Logical
    • is_loaded(Logical is_loaded.1243)
    • is_permanent().Logical
    • is_permanent(Logical is_permanent.1244)
    • load-inner()
    • init_object()
    • hash_code().Int32
    • create_duplicate().Object
    • to_String().String
    • op==(Object other).Logical {multimethod}
    • op<>(Object other).Logical {multimethod}
    • type_name().String : native
    • runtime_type().RuntimeType : native
    • runtime_properties().RuntimeProperties
    • runtime_methods().RuntimeMethods
    • init(String filename[,FontStyle style][,String mapping])
    • init(Bitmap bitmap[,FontStyle style][,String mapping])
    • init(HashTable<<Char,FontCharacter>> init:characters,Int32 init:height)
    • alpha().Int32
    • alpha(Int32 new_alpha)
    • height().Real64
    • scaled(Vector2 new_scale)
    • scaled(Real64 uniform_scale)
    • draw(String st,Vector2 pos)
    • draw_center(String st,Vector2 pos)
    • draw_center(String st,Vector2 pos,Real64 field_width)
    • draw_right(String st,Vector2 pos,Real64 field_width)
    • draw_right(String st,Vector2 pos)
    • draw_line(String st,Vector2 pos)
    • text_width_of(String text).Real64
    • text_width_of(Char ch).Real64
    • adjust_character_widths(Int32 amount)
    • word_wrap(String st,Int32 pixel_width).String[]