1 ! Copyright (C) 2008 Matthew Willis.
2 ! See http://factorcode.org/license.txt for BSD license.
4 ! pangocairo bindings, from pango/pangocairo.h
5 USING: cairo.ffi alien.c-types math
6 alien.syntax system combinators alien
8 arrays pango pango.fonts ;
12 { [ os winnt? ] [ "libpangocairo-1.0-0.dll" ] }
13 { [ os macosx? ] [ "libpangocairo-1.0.0.dylib" ] }
14 { [ os unix? ] [ "libpangocairo-1.0.so" ] }
15 } cond "cdecl" add-library >>
19 FUNCTION: PangoFontMap*
20 pango_cairo_font_map_new ( ) ;
22 FUNCTION: PangoFontMap*
23 pango_cairo_font_map_new_for_font_type ( cairo_font_type_t fonttype ) ;
25 FUNCTION: PangoFontMap*
26 pango_cairo_font_map_get_default ( ) ;
28 FUNCTION: cairo_font_type_t
29 pango_cairo_font_map_get_font_type ( PangoCairoFontMap* fontmap ) ;
32 pango_cairo_font_map_set_resolution ( PangoCairoFontMap* fontmap, double dpi ) ;
35 pango_cairo_font_map_get_resolution ( PangoCairoFontMap* fontmap ) ;
37 FUNCTION: PangoContext*
38 pango_cairo_font_map_create_context ( PangoCairoFontMap* fontmap ) ;
40 FUNCTION: cairo_scaled_font_t*
41 pango_cairo_font_get_scaled_font ( PangoCairoFont* font ) ;
43 ! Update a Pango context for the current state of a cairo context
45 pango_cairo_update_context ( cairo_t* cr, PangoContext* context ) ;
48 pango_cairo_context_set_font_options ( PangoContext* context, cairo_font_options_t* options ) ;
50 FUNCTION: cairo_font_options_t*
51 pango_cairo_context_get_font_options ( PangoContext* context ) ;
54 pango_cairo_context_set_resolution ( PangoContext* context, double dpi ) ;
57 pango_cairo_context_get_resolution ( PangoContext* context ) ;
60 FUNCTION: PangoLayout*
61 pango_cairo_create_layout ( cairo_t* cr ) ;
64 pango_cairo_update_layout ( cairo_t* cr, PangoLayout* layout ) ;
68 pango_cairo_show_glyph_string ( cairo_t* cr, PangoFont* font, PangoGlyphString* glyphs ) ;
71 pango_cairo_show_layout_line ( cairo_t* cr, PangoLayoutLine* line ) ;
74 pango_cairo_show_layout ( cairo_t* cr, PangoLayout* layout ) ;
77 pango_cairo_show_error_underline ( cairo_t* cr, double x, double y, double width, double height ) ;
81 pango_cairo_glyph_string_path ( cairo_t* cr, PangoFont* font, PangoGlyphString* glyphs ) ;
84 pango_cairo_layout_line_path ( cairo_t* cr, PangoLayoutLine* line ) ;
87 pango_cairo_layout_path ( cairo_t* cr, PangoLayout* layout ) ;
90 pango_cairo_error_underline_path ( cairo_t* cr, double x, double y, double width, double height ) ;
92 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
93 ! Higher level words and combinators
94 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
97 destructors accessors namespaces kernel cairo ;
99 : (with-pango) ( layout quot -- )
100 >r alien>> pango-layout r> with-variable ; inline
102 : with-pango-cairo ( quot -- )
103 cr pango_cairo_create_layout swap with-layout ; inline
105 MEMO: dummy-cairo ( -- cr )
106 CAIRO_FORMAT_ARGB32 0 0 cairo_image_surface_create cairo_create ;
108 : dummy-pango ( quot -- )
109 >r dummy-cairo cairo r> [ with-pango-cairo ] curry with-variable ; inline
111 : layout-size ( quot -- dim )
112 [ layout pango-layout-get-pixel-size 2array ] compose dummy-pango ; inline
115 cr layout pango_cairo_show_layout ;
117 : families ( -- families )
118 pango_cairo_font_map_get_default list-families ;