1. -- 
  2. -- Copyright (c) 2013 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.Color;                     use Allegro.Color; 
  11. with Allegro.UTF8;                      use Allegro.UTF8; 
  12. with Interfaces;                        use Interfaces; 
  13. with Interfaces.C;                      use Interfaces.C; 
  14.  
  15. -- Allegro 5.0.9 - Fonts addon 
  16. package Allegro.Fonts is 
  17.  
  18.     -- Initialization 
  19.  
  20.     procedure Al_Init_Font_Addon; 
  21.     pragma Import( C, Al_Init_Font_Addon, "al_init_font_addon" ); 
  22.  
  23.     procedure Al_Shutdown_Font_Addon; 
  24.     pragma Import( C, Al_Shutdown_Font_Addon, "al_shutdown_font_addon" ); 
  25.  
  26.     function Al_Get_Allegro_Font_Version return Unsigned_32; 
  27.     pragma Import( C, Al_Get_Allegro_Font_Version, "al_get_allegro_font_version" ); 
  28.  
  29.     -- General font routines 
  30.  
  31.     type Allegro_Font is limited private; 
  32.     type A_Allegro_Font is access all Allegro_Font; 
  33.  
  34.     subtype Font_Loading_Flags is Unsigned_32; 
  35.  
  36.     function Al_Load_Font( filename : String; 
  37.                            size     : Integer; 
  38.                            flags    : Font_Loading_Flags ) return A_Allegro_Font; 
  39.  
  40.     procedure Al_Destroy_Font( f : in out A_Allegro_Font ); 
  41.  
  42.     type A_Loader_Proc is access 
  43.         function( filename : C.char_array; 
  44.                   size     : Integer; 
  45.                   flags    : Font_Loading_Flags ) return A_Allegro_Font; 
  46.     pragma Convention( C, A_Loader_Proc ); 
  47.  
  48.     function Al_Register_Font_Loader( ext : String; load : A_Loader_Proc ) return Boolean; 
  49.  
  50.     function Al_Get_Font_Line_Height( f : A_Allegro_Font ) return Integer; 
  51.     pragma Import( C, Al_Get_Font_Line_Height, "al_get_font_line_height" ); 
  52.  
  53.     function Al_Get_Font_Ascent( f : A_Allegro_Font ) return Integer; 
  54.     pragma Import( C, Al_Get_Font_Ascent, "al_get_font_ascent" ); 
  55.  
  56.     function Al_Get_Font_Descent( f : A_Allegro_Font ) return Integer; 
  57.     pragma Import( C, Al_Get_Font_Descent, "al_get_font_descent" ); 
  58.  
  59.     function Al_Get_Text_Width( f : A_Allegro_Font; str : String ) return Integer; 
  60.  
  61.     function Al_Get_Ustr_Width( f : A_Allegro_Font; ustr : A_Allegro_Ustr ) return Integer; 
  62.     pragma Import( C, Al_Get_Ustr_Width, "al_get_ustr_width" ); 
  63.  
  64.     subtype Font_Draw_Flags is Unsigned_32; 
  65.     ALLEGRO_ALIGN_LEFT    : constant Font_Draw_Flags := 0; 
  66.     ALLEGRO_ALIGN_CENTRE  : constant Font_Draw_Flags := 1; 
  67.     ALLEGRO_ALIGN_CENTER  : constant Font_Draw_Flags := 1; 
  68.     ALLEGRO_ALIGN_RIGHT   : constant Font_Draw_Flags := 2; 
  69.     ALLEGRO_ALIGN_INTEGER : constant Font_Draw_Flags := 4; 
  70.  
  71.     procedure Al_Draw_Text( font  : A_Allegro_Font; 
  72.                             color : Allegro_Color; 
  73.                             x, y  : Float; 
  74.                             flags : Font_Draw_Flags; 
  75.                             text  : String ); 
  76.  
  77.     procedure Al_Draw_Ustr( font  : A_Allegro_Font; 
  78.                             color : Allegro_Color; 
  79.                             x, y  : Float; 
  80.                             flags : Font_Draw_Flags; 
  81.                             ustr  : A_Allegro_Ustr ); 
  82.     pragma Import( C, Al_Draw_Ustr, "al_draw_ustr" ); 
  83.  
  84.     procedure Al_Draw_Justified_Text( font   : A_Allegro_Font; 
  85.                                       color  : Allegro_Color; 
  86.                                       x1, x2 : Float; 
  87.                                       y      : Float; 
  88.                                       diff   : Float; 
  89.                                       flags  : Font_Draw_Flags; 
  90.                                       text   : String ); 
  91.  
  92.     procedure Al_Draw_Justified_Ustr( font   : A_Allegro_Font; 
  93.                                       color  : Allegro_Color; 
  94.                                       x1, x2 : Float; 
  95.                                       y      : Float; 
  96.                                       diff   : Float; 
  97.                                       flags  : Font_Draw_Flags; 
  98.                                       text   : A_Allegro_Ustr ); 
  99.     pragma Import( C, Al_Draw_Justified_Ustr, "al_draw_justified_ustr" ); 
  100.  
  101. --  ALLEGRO_FONT_PRINTFUNC(void, al_draw_textf, (const ALLEGRO_FONT *font, ALLEGRO_COLOR color, float x, float y, int flags, char const *format, ...), 6, 7); 
  102.  
  103. --  procedure Al_Draw_Text( font   : A_Allegro_Font; 
  104. --                          color  : Allegro_Color; 
  105. --                          x, y   : Float; 
  106. --                          flags  : Font_Draw_Flags; 
  107. --                          format : String ); 
  108.  
  109. --  ALLEGRO_FONT_PRINTFUNC(void, al_draw_justified_textf, (const ALLEGRO_FONT *font, ALLEGRO_COLOR color, float x1, float x2, float y, float diff, int flags, char const *format, ...), 8, 9); 
  110.  
  111. --  procedure Al_Draw_Justified_Textf( font   : A_Allegro_Font; 
  112. --                                     color  : Allegro_Color; 
  113. --                                     x1, x2 : Float; 
  114. --                                     y      : Float; 
  115. --                                     diff   : Float; 
  116. --                                     flags  : Font_Draw_Flags; 
  117. --                                     format : String ); 
  118.  
  119.     procedure Al_Get_Text_Dimensions( f    : A_Allegro_Font; 
  120.                                       text : String; 
  121.                                       bbx  : out Integer; 
  122.                                       bby  : out Integer; 
  123.                                       bbw  : out Integer; 
  124.                                       bbh  : out Integer ); 
  125.  
  126.     procedure Al_Get_Ustr_Dimensions( f    : A_Allegro_Font; 
  127.                                       text : A_Allegro_Ustr; 
  128.                                       bbx  : out Integer; 
  129.                                       bby  : out Integer; 
  130.                                       bbw  : out Integer; 
  131.                                       bbh  : out Integer ); 
  132.  
  133.     -- Bitmap fonts 
  134.  
  135.     type Unicode_Range is 
  136.         record 
  137.             first : Integer; 
  138.             last  : Integer; 
  139.         end record; 
  140.     pragma Convention( C, Unicode_Range ); 
  141.  
  142.     type Unicode_Range_Array is array (Integer range <>) of Unicode_Range; 
  143.     pragma Convention( C, Unicode_Range_Array ); 
  144.  
  145.     function Al_Grab_Font_From_Bitmap( bmp    : A_Allegro_Bitmap; 
  146.                                        ranges : Unicode_Range_Array 
  147.                                      ) return A_Allegro_Font; 
  148.     pragma Precondition( ranges'Length > 0 ); 
  149.  
  150.     function Al_Create_Builtin_Font return A_Allegro_Font; 
  151.     pragma Import( C, Al_Create_Builtin_Font, "al_create_builtin_font" ); 
  152.  
  153.     function Al_Load_Bitmap_Font( filename : String ) return A_Allegro_Font; 
  154.  
  155. private 
  156.  
  157.     type Allegro_Font is limited null record; 
  158.     pragma Convention( C, Allegro_Font ); 
  159.  
  160. end Allegro.Fonts;