package provide Freetype::ftwinfnt 0.1

if {![info exists _source([file tail [info script]])]} {
package require Freetype::ft2build
package require $FT_FREETYPE

set FT_WinFNT_ID_CP1252    0
set FT_WinFNT_ID_DEFAULT   1
set FT_WinFNT_ID_SYMBOL    2
set FT_WinFNT_ID_MAC      77
set FT_WinFNT_ID_CP932   128
set FT_WinFNT_ID_CP949   129
set FT_WinFNT_ID_CP1361  130
set FT_WinFNT_ID_CP936   134
set FT_WinFNT_ID_CP950   136
set FT_WinFNT_ID_CP1253  161
set FT_WinFNT_ID_CP1254  162
set FT_WinFNT_ID_CP1258  163
set FT_WinFNT_ID_CP1255  177
set FT_WinFNT_ID_CP1256  178
set FT_WinFNT_ID_CP1257  186
set FT_WinFNT_ID_CP1251  204
set FT_WinFNT_ID_CP874   222
set FT_WinFNT_ID_CP1250  238
set FT_WinFNT_ID_OEM     255

ft::struct define FT_WinFNT_Header {
    {version               int    - FT_UShort 1 FT_UShort}
    {file_size             int    - FT_ULong  1 FT_ULong}
    {copyright             string - FT_Byte   60 FT_Byte}
    {file_type             int    - FT_UShort 1 FT_UShort}
    {nominal_point_size    int    - FT_UShort 1 FT_UShort}
    {vertical_resolution   int    - FT_UShort 1 FT_UShort}
    {horizontal_resolution int    - FT_UShort 1 FT_UShort}
    {ascent                int    - FT_UShort 1 FT_UShort}
    {internal_leading      int    - FT_UShort 1 FT_UShort}
    {external_leading      int    - FT_UShort 1 FT_UShort}
    {italic                int    - FT_Byte   1 FT_Byte}
    {underline             int    - FT_Byte   1 FT_Byte}
    {strike_out            int    - FT_Byte   1 FT_Byte}
    {weight                int    - FT_UShort 1 FT_UShort}
    {charset               int    - FT_Byte   1 FT_Byte}
    {pixel_width           int    - FT_UShort 1 FT_UShort}
    {pixel_height          int    - FT_UShort 1 FT_UShort}
    {pitch_and_family      int    - FT_Byte   1 FT_Byte}
    {avg_width             int    - FT_UShort 1 FT_UShort}
    {max_width             int    - FT_UShort 1 FT_UShort}
    {first_char            int    - FT_Byte   1 FT_Byte}
    {last_char             int    - FT_Byte   1 FT_Byte}
    {default_char          int    - FT_Byte   1 FT_Byte}
    {break_char            int    - FT_Byte   1 FT_Byte}
    {bytes_per_row         int    - FT_UShort 1 FT_UShort}
    {device_offset         int    - FT_ULong  1 FT_ULong}
    {face_name_offset      int    - FT_ULong  1 FT_ULong}
    {bits_pointer          int    - FT_ULong  1 FT_ULong}
    {bits_offset           int    - FT_ULong  1 FT_ULong}
    {reserved              int    - FT_Byte   1 FT_Byte}
    {flags                 int    - FT_ULong  1 FT_ULong}
    {A_space               int    - FT_UShort 1 FT_UShort}
    {B_space               int    - FT_UShort 1 FT_UShort}
    {C_space               int    - FT_UShort 1 FT_UShort}
    {color_table_offset    int    - FT_UShort 1 FT_UShort}
    {reserved1             int    - FT_ULong  4 FT_ULong}
}


::ffidl::callout _FT_Get_WinFNT_Header {pointer pointer} int \
    [::ffidl::symbol $::ft::lib FT_Get_WinFNT_Header]
proc  FT_Get_WinFNT_Header {face headerVarName} {
    set header [FT_WinFNT_Header new]
    set result [_FT_Get_WinFNT_Header [$face getPointer] [$header getPointer]]
    if {$result == 0} {
        uplevel [list set $headerVarName $header]
    } else {
        $header destroy
    }
    return $result
}

set _source([file tail [info script]]) 1
}
