1. -- 
  2. -- Copyright (c) 2012 Kevin Wellwood 
  3. -- All rights reserved. 
  4. -- 
  5. -- This source code is distributed under the Modified BSD License. For terms and 
  6. -- conditions, see license.txt. 
  7. -- 
  8.  
  9. with Allegro.Bitmaps;                   use Allegro.Bitmaps; 
  10. with Allegro.Truecolor;                 use Allegro.Truecolor; 
  11. with Objects;                           use Objects; 
  12.  
  13. package Font_API is 
  14.  
  15.     -- Initializes the font system and each underlying font API (ex: AlFont/FreeType). 
  16.     -- An exception will be raised on error. 
  17.     procedure Initialize; 
  18.  
  19.     -- Finalizes the font system and each underlying font API that was 
  20.     -- previously initialized. If Initialize has not been called then this will 
  21.     -- have no effect. 
  22.     procedure Finalize; 
  23.  
  24.     ---------------------------------------------------------------------------- 
  25.  
  26.     -- An Abstract_Font represents a specific font of a specific size. Two 
  27.     -- Abstract_Font instances are required to work with the same font in two 
  28.     -- different font sizes. 
  29.     type Abstract_Font is abstract new Limited_Object with private; 
  30.     type Font_Type is access all Abstract_Font'Class; 
  31.  
  32.     -- Loads a font from disk at a specific size. The file format will be 
  33.     -- automatically detected; it must be a supported font format. An exception 
  34.     -- will be raised on error. 
  35.     function Load_Font( filename : String; size : Positive ) return Font_Type; 
  36.     pragma Precondition( filename'Length > 0 ); 
  37.  
  38.     -- Returns the height in pixels of a string rendered with the font. 
  39.     function Text_Height( this : access Abstract_Font ) return Positive is abstract; 
  40.  
  41.     -- Returns the length in pixels of a string rendered with the font. 
  42.     function Text_Length( this : access Abstract_Font; 
  43.                           str  : String ) return Natural is abstract; 
  44.  
  45.     -- Renders a string to a bitmap. 'color' is the color of the letters. If 
  46.     -- 'smooth' is True, the text will be antialiased if possible. 
  47.     procedure Textout( this   : access Abstract_Font; 
  48.                        bmp    : A_Bitmap; 
  49.                        str    : String; 
  50.                        x, y   : Integer; 
  51.                        color  : Color_Type; 
  52.                        smooth : Boolean ) is abstract; 
  53.  
  54.     -- Deletes a font. 
  55.     procedure Delete( this : in out Font_Type ); 
  56.     pragma Postcondition( this = null ); 
  57.  
  58.     -- Raised by Initialize on error, or on failure to load a font. Check the 
  59.     -- exception's message for details. 
  60.     FONT_EXCEPTION : exception; 
  61.  
  62. private 
  63.  
  64.     type Abstract_Font is abstract new Limited_Object with null record; 
  65.  
  66. end Font_API;