lace_opengl_0.1.0_672a6415/source/lean/text/opengl-glyph-container.ads

  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
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
with
     freetype.Face,
     freetype.charMap;

private
with
     ada.Containers.Vectors;

package openGL.Glyph.Container
--
--  Contains the post processed Glyph objects.
--
is
   type Item       is tagged private;
   type Glyph_view is access all Glyph.item'Class;


   ---------
   --  Forge
   --

   function  to_glyph_Container (parent_Face : in freetype.Face.view) return glyph.Container.item;
   --
   -- parent_Face: The Freetype face.


   procedure destruct (Self : in out Item);


   --------------
   --  Attributes
   --

   function CharMap (Self : access Item;   Encoding : in freeType_c.FT_Encoding) return Boolean;
   --
   --  Sets the character map for the face.
   --
   -- Encoding: The Freetype encoding symbol.
   --
   --  Returns True if charmap was valid and set correctly.


   function FontIndex (Self : in Item;   Character : in freetype.charMap.characterCode) return Natural;
   --
   --  Get the font index of the input character.
   --
   --  Character: The character code of the requested glyph in the current encoding (eg apple roman).
   --
   --  Returns the font index for the character.


   procedure add (Self : in out Item;   Glyph     : in Glyph_view;
                                        Character : in freetype.charMap.characterCode);
   --
   --  Adds a glyph to this glyph list.
   --
   --  Glyph:     The FTGlyph to be inserted into the container.
   --  Character: The char code of the glyph NOT the glyph index.


   function Glyph (Self : in Item;   Character : in freetype.charMap.characterCode) return Glyph_view;
   --
   --  Get a glyph from the glyph list.
   --
   --  Character: The char code of the glyph NOT the glyph index.
   --
   --  Returns a Glyph or null is it hasn't been loaded.


   function BBox (Self : in Item;   Character : in freetype.charMap.characterCode) return Bounds;
   --
   --  Get the bounding box for a character.
   --
   --  Character: The char code of the glyph NOT the glyph index.


   function Advance (Self : in Item;   Character         : in freetype.charMap.characterCode;
                                       nextCharacterCode : in freetype.charMap.characterCode) return Real;
   --
   --  Character:         Glyph index of the character.
   --  nextCharacterCode: The next glyph in a string.
   --
   --  Returns the kerned advance width for a glyph.


   function Error (Self : in Item) return freetype_c.FT_Error;
   --
   --  Queries the glyph container for errors.
   --
   --  Returns the current error code.


   --------------
   --  Operations
   --

   function render (Self : access Item;   Character         : in freetype.charMap.characterCode;
                                          nextCharacterCode : in freetype.charMap.characterCode;
                                          penPosition       : in Vector_3;
                                          renderMode        : in Integer) return Vector_3;
   --
   --  Renders a character.
   --
   --  Character:         The glyph to be Rendered.
   --  nextCharacterCode: The next glyph in the string. Used for kerning.
   --  penPosition:       The position to Render the glyph.
   --  renderMode:        Render mode to display.
   --
   --  Returns the distance to advance the pen position after rendering,



private

   type    charMap_view  is access all freetype.charMap.item'class;
   package glyph_Vectors is new ada.Containers.Vectors (Positive, Glyph_view);

   type Item is tagged
      record
         Face    : freetype.Face.view;       -- The FTGL face.
         charMap : charMap_view;             -- The character map object associated with the current face.

         Glyphs  : glyph_Vectors.Vector;     -- A structure to hold the glyphs.
         Err     : freeType_c.FT_Error;      -- Current error code. Zero means no error.
      end record;

end openGL.Glyph.Container;