freetypeada_0.1.0_4fd90f57/src/ft-utilities.adb

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
--  part of FreeTypeAda, (c) 2017 Felix Krause
--  released under the terms of the MIT license, see the file "COPYING"

with Ada.Text_IO; use Ada.Text_IO;

with FT.Glyphs;

package body FT.Utilities is
   use Interfaces.C;

   procedure Print_Bitmap_Metadata (Bitmap : FT.Bitmap_Record) is
   begin
      New_Line;
      Put_Line ("Bitmap data:");
      Put_Line ("Rows: " & Interfaces.C.unsigned'Image (Bitmap.Rows));
      Put_Line ("Width: " & Interfaces.C.unsigned'Image (Bitmap.Width));
      Put_Line ("Pitch: " & Interfaces.C.int'Image (Bitmap.Pitch));
      Put_Line ("Num_Grays: " & Interfaces.C.short'Image (Bitmap.Num_Grays));
      Put_Line ("Pixel_mode: " & unsigned_char'Image (Bitmap.Pixel_Mode));
      Put_Line ("Palette_mode: " & unsigned_char'Image (Bitmap.Palette_Mode));
      New_Line;
   end Print_Bitmap_Metadata;

   --  -------------------------------------------------------------------------

   procedure Print_Character_Metadata (aFace : FT.Faces.Face_Reference;
                                       aChar : Character) is
      Slot : constant FT.Glyph_Slot_Reference := aFace.Glyph_Slot;
      Bitmap : constant FT.Bitmap_Record := Glyphs.Bitmap (Slot);
   begin
      Put_Line ("Character " & aChar & " Data");
      Put_Line ("Width: " & Interfaces.C.unsigned'Image (Bitmap.Width));
      Put_Line ("Rows: " & Interfaces.C.unsigned'Image (Bitmap.Rows));
      Put_Line ("Left: " & Interfaces.C.int'Image (Glyphs.Bitmap_Left (Slot)));
      Put_Line ("Top: " & Interfaces.C.int'Image (Glyphs.Bitmap_Top (Slot)));
      Put_Line ("Advance X: " & Position'Image (Glyphs.Advance (Slot).X) & " bits");
      Put_Line ("Glyph format: " & FT.Glyph_Format'Image (Glyphs.Format (Slot)));
      New_Line;
   end Print_Character_Metadata;

   --  ------------------------------------------------------------------------

end FT.Utilities;