with Allegro.Bitmaps; use Allegro.Bitmaps;
with Allegro.Truecolor; use Allegro.Truecolor;
with Objects; use Objects;
package Font_API is
-- Initializes the font system and each underlying font API (ex: AlFont/FreeType).
-- An exception will be raised on error.
procedure Initialize;
-- Finalizes the font system and each underlying font API that was
-- previously initialized. If Initialize has not been called then this will
-- have no effect.
procedure Finalize;
----------------------------------------------------------------------------
-- An Abstract_Font represents a specific font of a specific size. Two
-- Abstract_Font instances are required to work with the same font in two
-- different font sizes.
type Abstract_Font is abstract new Limited_Object with private;
type Font_Type is access all Abstract_Font'Class;
-- Loads a font from disk at a specific size. The file format will be
-- automatically detected; it must be a supported font format. An exception
-- will be raised on error.
function Load_Font( filename : String; size : Positive ) return Font_Type;
pragma Precondition( filename'Length > 0 );
-- Returns the height in pixels of a string rendered with the font.
function Text_Height( this : access Abstract_Font ) return Positive is abstract;
-- Returns the length in pixels of a string rendered with the font.
function Text_Length( this : access Abstract_Font;
str : String ) return Natural is abstract;
-- Renders a string to a bitmap. 'color' is the color of the letters. If
-- 'smooth' is True, the text will be antialiased if possible.
procedure Textout( this : access Abstract_Font;
bmp : A_Bitmap;
str : String;
x, y : Integer;
color : Color_Type;
smooth : Boolean ) is abstract;
-- Deletes a font.
procedure Delete( this : in out Font_Type );
pragma Postcondition( this = null );
-- Raised by Initialize on error, or on failure to load a font. Check the
-- exception's message for details.
FONT_EXCEPTION : exception;
private
type Abstract_Font is abstract new Limited_Object with null record;
end Font_API;