package provide Freetype::ftbitmap 0.1

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

::ffidl::callout _FT_Bitmap_New {pointer} void \
    [::ffidl::symbol $::ft::lib FT_Bitmap_New]
proc FT_Bitmap_New {bitmapVarName} {
    upvar $bitmapVarName bitmap
    if {[info exists bitmap] == 0} {
        set bitmap [FT_Bitmap new]
    }
    if {[info object isa object $bitmap] &&
        [info object isa typeof $bitmap FT_Bitmap]} {
        set adr [$bitmap getPointer]
    } else {
        error "invalid object class"
    }
    _FT_Bitmap_New $adr
    return
}

::ffidl::callout _FT_Bitmap_Copy {pointer pointer pointer} int \
    [::ffidl::symbol $::ft::lib FT_Bitmap_Copy]
proc FT_Bitmap_Copy {library source target} {
    set result [_FT_Bitmap_Copy [$library getPointer] \
        [$source getPointer] [$target getPointer]]
    return $result
}

::ffidl::callout _FT_Bitmap_Embolden {pointer pointer FT_Pos FT_Pos} int \
    [::ffidl::symbol $::ft::lib FT_Bitmap_Embolden]
proc FT_Bitmap_Embolden {library bitmap xStrength yStrength} {
    set result [_FT_Bitmap_Embolden [$library getPointer] [$bitmap getPointer] \
        $xStrength $yStrength]
    return $result
}

::ffidl::callout _FT_Bitmap_Convert {pointer pointer pointer FT_Int} int \
    [::ffidl::symbol $::ft::lib FT_Bitmap_Convert]
proc FT_Bitmap_Convert {library source target alignment} {
    set result [_FT_Bitmap_Convert [$library getPointer] [$source getPointer] \
        [$target getPointer] $alignment]
    return $result
}

::ffidl::callout _FT_GlyphSlot_Own_Bitmap {pointer} int \
    [::ffidl::symbol $::ft::lib FT_GlyphSlot_Own_Bitmap]
proc FT_GlyphSlot_Own_Bitmap {slot} {
    set result [_FT_GlyphSlot_Own_Bitmap [$slot getPointer]]
    return $result
}

::ffidl::callout _FT_Bitmap_Done {pointer pointer} int \
    [::ffidl::symbol $::ft::lib FT_Bitmap_Done]
proc FT_Bitmap_Done {library bitmap} {
    set result [_FT_Bitmap_Done [$library getPointer] [$bitmap getPointer]]
    return $result
}

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