1 USING: alien alien.c-types
2 math kernel byte-arrays freetype
3 opengl.gadgets accessors pango
5 arrays sequences libc opengl.gl
6 system combinators alien.syntax
11 { [ os winnt? ] [ "libpangocairo-1.0-0.dll" ] }
12 { [ os macosx? ] [ "libpangocairo-1.0.0.dylib" ] }
13 { [ os unix? ] [ "libpangoft2-1.0.so" ] }
14 } cond "cdecl" add-library >>
18 FUNCTION: PangoFontMap*
19 pango_ft2_font_map_new ( ) ;
21 FUNCTION: PangoContext*
22 pango_ft2_font_map_create_context ( PangoFT2FontMap* fontmap ) ;
25 pango_ft2_render_layout ( FT_Bitmap* bitmap, PangoLayout* layout, int x, int y ) ;
27 : 4*-ceil ( n -- k*4 )
30 : <ft-bitmap> ( width height -- ft-bitmap )
36 "FT_Bitmap" <c-object> dup >r
38 [ set-FT_Bitmap-pixel_mode ]
39 [ set-FT_Bitmap-num_grays ]
40 [ set-FT_Bitmap-buffer ]
41 [ set-FT_Bitmap-pitch ]
42 [ set-FT_Bitmap-width ]
43 [ set-FT_Bitmap-rows ]
46 : render-layout ( layout -- dims alien )
48 pango-layout-get-pixel-size
49 2array dup 2^-bounds first2 <ft-bitmap> dup
50 ] [ 0 0 pango_ft2_render_layout ] bi FT_Bitmap-buffer ;
52 MEMO: ft2-context ( -- PangoContext* )
53 pango_ft2_font_map_new pango_ft2_font_map_create_context ;
55 : with-ft2-layout ( quot -- )
56 ft2-context pango_layout_new swap with-layout ; inline