factor/basis/pango/pango.factor

67 lines
1.9 KiB
Factor
Raw Normal View History

! Copyright (C) 2009 Anton Gorenko.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors alien alien.syntax alien.c-types alien.destructors
alien.strings alien.libraries arrays classes.struct combinators
destructors fonts init kernel math math.rectangles memoize
io.encodings.utf8 system
gir glib glib.ffi ;
2009-02-26 03:31:24 -05:00
<<
"pango" {
{ [ os winnt? ] [ "libpango-1.0-0.dll" cdecl add-library ] }
{ [ os macosx? ] [ "/opt/local/lib/libpango-1.0.0.dylib" cdecl add-library ] }
{ [ os unix? ] [ drop ] }
} cond
>>
2009-02-26 03:31:24 -05:00
IN: pango.ffi
2009-02-26 03:31:24 -05:00
TYPEDEF: void PangoLayoutRun ! не совсем верно
TYPEDEF: guint32 PangoGlyph
2009-02-26 03:31:24 -05:00
IN-GIR: pango vocab:pango/Pango-1.0.gir
IN: pango.ffi
FORGET: PangoRectangle
2009-02-26 03:31:24 -05:00
2009-08-31 13:23:08 -04:00
STRUCT: PangoRectangle
{ x int }
{ y int }
{ width int }
{ height int } ;
2009-02-28 02:31:51 -05:00
IN: pango
CONSTANT: PANGO_SCALE 1024
: pango>float ( n -- x ) PANGO_SCALE /f ; inline
: float>pango ( x -- n ) PANGO_SCALE * >integer ; inline
2009-02-28 02:31:51 -05:00
: PangoRectangle>rect ( PangoRectangle -- rect )
2009-08-31 13:23:08 -04:00
[ [ x>> pango>float ] [ y>> pango>float ] bi 2array ]
[ [ width>> pango>float ] [ height>> pango>float ] bi 2array ] bi
2009-03-26 00:00:19 -04:00
<rect> ;
DESTRUCTOR: pango_font_description_free
DESTRUCTOR: pango_layout_iter_free
! перенести в ui.*?
MEMO: (cache-font-description) ( font -- description )
[
[ pango_font_description_new |pango_font_description_free ] dip {
[ name>> utf8 string>alien pango_font_description_set_family ]
[ size>> float>pango pango_font_description_set_size ]
[ bold?>> PANGO_WEIGHT_BOLD PANGO_WEIGHT_NORMAL ? pango_font_description_set_weight ]
[ italic?>> PANGO_STYLE_ITALIC PANGO_STYLE_NORMAL ? pango_font_description_set_style ]
[ drop ]
} 2cleave
] with-destructors ;
: cache-font-description ( font -- description )
strip-font-colors (cache-font-description) ;
[ \ (cache-font-description) reset-memoized ] "pango" add-startup-hook