1 ! Copyright (C) 2009 Anton Gorenko.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors alien alien.syntax alien.c-types alien.destructors
4 alien.strings alien.libraries arrays classes.struct combinators
5 destructors fonts init kernel math math.rectangles memoize
6 io.encodings.utf8 system
11 { [ os winnt? ] [ "libpango-1.0-0.dll" cdecl add-library ] }
12 { [ os macosx? ] [ "/opt/local/lib/libpango-1.0.0.dylib" cdecl add-library ] }
13 { [ os unix? ] [ drop ] }
19 TYPEDEF: void PangoLayoutRun ! не совсем верно
20 TYPEDEF: guint32 PangoGlyph
22 IN-GIR: pango vocab:pango/Pango-1.0.gir
26 FORGET: PangoRectangle
28 STRUCT: PangoRectangle
36 CONSTANT: PANGO_SCALE 1024
38 : pango>float ( n -- x ) PANGO_SCALE /f ; inline
39 : float>pango ( x -- n ) PANGO_SCALE * >integer ; inline
41 : PangoRectangle>rect ( PangoRectangle -- rect )
42 [ [ x>> pango>float ] [ y>> pango>float ] bi 2array ]
43 [ [ width>> pango>float ] [ height>> pango>float ] bi 2array ] bi
46 DESTRUCTOR: pango_font_description_free
48 DESTRUCTOR: pango_layout_iter_free
51 MEMO: (cache-font-description) ( font -- description )
53 [ pango_font_description_new |pango_font_description_free ] dip {
54 [ name>> utf8 string>alien pango_font_description_set_family ]
55 [ size>> float>pango pango_font_description_set_size ]
56 [ bold?>> PANGO_WEIGHT_BOLD PANGO_WEIGHT_NORMAL ? pango_font_description_set_weight ]
57 [ italic?>> PANGO_STYLE_ITALIC PANGO_STYLE_NORMAL ? pango_font_description_set_style ]
62 : cache-font-description ( font -- description )
63 strip-font-colors (cache-font-description) ;
65 [ \ (cache-font-description) reset-memoized ] "pango" add-startup-hook