package provide Freetype::ftadvanc 0.1

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


set FT_ADVANCE_FLAG_FAST_ONLY  [expr 0x20000000]

::ffidl::callout _FT_Get_Advance {pointer FT_UInt FT_Int32 pointer-var} int \
    [::ffidl::symbol $::ft::lib FT_Get_Advance]
proc FT_Get_Advance {face gindex load_flags advanceVarName} {
    upvar $advanceVarName advance
    set p [::ft::_bytearray_from FT_Fixed 0]
    set result [_FT_Get_Advance [$face getPointer] $gindex $load_flags p]
    set advance [::ft::_bytearray_to FT_Fixed $p]
    return $result
}

::ffidl::callout _FT_Get_Advances {pointer FT_UInt FT_UInt FT_Int32 pointer-var} int \
    [::ffidl::symbol $::ft::lib FT_Get_Advances]
proc FT_Get_Advances {face start count load_flags advancesVarName} {
    upvar $advancesVarName advances
    set size [expr {$count * [::ffidl::info sizeof FT_Fixed]}]
    set buf [binary format x$size]
    set result [_FT_Get_Advances [$face getPointer] $start $count $load_flags buf]
    set advances [::ft::_bytearray_to_list $buf FT_Fixed]
    return $result
}

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