; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "BSD 2-clause" license."          |
;|_______________________________________________________________________________________|
;
;  Description: FreeType library constants and structures.
;
;  Target OS: Linux
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________


FT_LOAD_DEFAULT                         =  $0
FT_LOAD_NO_SCALE                        =  $1
FT_LOAD_NO_HINTING                      =  $2
FT_LOAD_RENDER                          =  $4
FT_LOAD_NO_BITMAP                       =  $8
FT_LOAD_VERTICAL_LAYOUT                 =  $10
FT_LOAD_FORCE_AUTOHINT                  =  $20
FT_LOAD_CROP_BITMAP                     =  $40
FT_LOAD_PEDANTIC                        =  $80
FT_LOAD_ADVANCE_ONLY                    =  $100
FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH     =  $200
FT_LOAD_NO_RECURSE                      =  $400
FT_LOAD_IGNORE_TRANSFORM                =  $800
FT_LOAD_MONOCHROME                      =  $1000
FT_LOAD_LINEAR_DESIGN                   =  $2000
FT_LOAD_SBITS_ONLY                      =  $4000
FT_LOAD_NO_AUTOHINT                     =  $8000

;FT_LOAD_TARGET_(x)   ( (FT_Int32)( (x) & 15 ) << 16 )
;FT_LOAD_TARGET_NORMAL   FT_LOAD_TARGET_( FT_RENDER_MODE_NORMAL )
;FT_LOAD_TARGET_LIGHT   FT_LOAD_TARGET_( FT_RENDER_MODE_LIGHT )
;FT_LOAD_TARGET_MONO   FT_LOAD_TARGET_( FT_RENDER_MODE_MONO )
;FT_LOAD_TARGET_LCD   FT_LOAD_TARGET_( FT_RENDER_MODE_LCD )
;FT_LOAD_TARGET_LCD_V   FT_LOAD_TARGET_( FT_RENDER_MODE_LCD_V )
;FT_LOAD_TARGET_MODE(x)   ( (FT_Render_Mode)( ( (x) >> 16 ) & 15 ) )

FT_RENDER_MODE_NORMAL = 0
FT_RENDER_MODE_LIGHT  = 1
FT_RENDER_MODE_MONO   = 2
FT_RENDER_MODE_LCD    = 3
FT_RENDER_MODE_LCD_V  = 4
FT_RENDER_MODE_MAX    = 5


FT_PIXEL_MODE_NONE  = 0
FT_PIXEL_MODE_MONO  = 1
FT_PIXEL_MODE_GRAY  = 2
FT_PIXEL_MODE_GRAY2 = 3
FT_PIXEL_MODE_GRAY4 = 4
FT_PIXEL_MODE_LCD   = 5
FT_PIXEL_MODE_LCD_V = 6
FT_PIXEL_MODE_BGRA  = 7


struct FT_Generic
  .data         dd ?
  .finalizer    dd ?    ; pointer to procedure with one argument.
ends

struct FT_BBox
  .xMin         dd ?
  .yMin         dd ?
  .xMax         dd ?
  .yMax         dd ?
ends

struct FT_Vector
  .x dd ?
  .y dd ?
ends

struct FT_Bitmap
  .rows         dd ?
  .width        dd ?
  .pitch        dd ?
  .buffer       dd ?    ; pointer to the buffer.
  .num_grays    dw ?
  .pixel_mode   db ?
  .palette_mode db ?
  .palette      dd ?    ; pointer to the palette.
ends




struct FT_Outline
  .n_contours  dw  ?
  .n_points    dw  ?
  .points      dd  ?    ; pointer to array of FT_Vector elements.
  .tags        dd  ?    ; pointer to byte array.
  .contours    dd  ?    ; pointer to word array.
  .flags       dd  ?
ends



struct  FT_Glyph_Metrics
  .width        dd ?
  .height       dd ?
  .horiBearingX dd ?
  .horiBearingY dd ?
  .horiAdvance  dd ?

  .vertBearingX dd ?
  .vertBearingY dd ?
  .vertAdvance  dd ?
ends



struct FT_GlyphSlot
  .library      dd ?
  .face         dd ?    ; parent FT_Face object
  .next         dd ?    ; pointer tp FT_GlyphSlot
  .reserved     dd ?
  .generic      FT_Generic

  .metrics      FT_Glyph_Metrics
  .linearHoriAdvance dd ?
  .linearVertAdvance dd ?

  .advance      FT_Vector

  .format       dd ?

  .bitmap       FT_Bitmap
  .bitmap_left  dd ?
  .bitmap_top   dd ?

  .outline      FT_Outline

  .num_subglyphs dd ?
  .subglyphs     dd ?   ; pointer to array of FT_SubGlyphRec elements.

  .control_data  dd ?
  .control_len   dd ?

  .lsb_delta     dd ?
  .rsb_delta     dd ?

  .other         dd ?
  .internal      dd ?   ; pointer to FT_Slot_InternalRec
ends


struct FT_Face
  .num_faces    dd ?
  .face_index   dd ?
  .face_flags   dd ?
  .style_flags  dd ?
  .num_glyphs   dd ?
  .family_name  dd ?
  .style_name   dd ?

  .num_fixed_sizes dd ?
  .available_sizes dd ?

  .num_charmaps dd ?
  .charmaps     dd ?
  .generic      FT_Generic

; scalable fonts members down to .underline_thickness

  .bbpx                 FT_BBox

  .units_per_EM         dw ?
  .ascender             dw ?
  .descender            dw ?
  .height               dw ?

  .max_advance_width    dw ?
  .max_advance_height   dw ?

  .underline_position   dw ?
  .underline_thickness  dw ?


  .glyph        dd  ?   ; pointer to FT_GlyphSlot
  .size         dd  ?   ; pointer to FT_Size
  .charmap      dd  ?   ; pointer to FT_CharMap

; down is the private part.

ends


struct FTC_ImageType
  .face_id  dd  ?
  .width    dd  ?
  .height   dd  ?
  .flags    dd  ?
ends


struct FT_GlyphRec
  .library      dd      ?
  .clazz        dd      ?
  .format       dd      ?
  .advance      FT_Vector
ends


struct FT_BitmapGlyphRec
  .root         FT_GlyphRec
  .left         dd ?
  .top          dd ?
  .bitmap       FT_Bitmap
ends



interface FT_Face_Requester, .face_id, .library, .request_data, .pFace