]> gitweb.factorcode.org Git - factor.git/blob - unmaintained/pango/cairo/cairo.factor
Merge branch 'master' of git://factorcode.org/git/factor
[factor.git] / unmaintained / pango / cairo / cairo.factor
1 ! Copyright (C) 2008 Matthew Willis.
2 ! See http://factorcode.org/license.txt for BSD license.
3 !
4 ! pangocairo bindings, from pango/pangocairo.h
5 USING: cairo.ffi alien.c-types math
6 alien.syntax system combinators alien
7 memoize
8 arrays pango pango.fonts ;
9 IN: pango.cairo
10
11 << "pangocairo" {
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 >>
16
17 LIBRARY: pangocairo
18
19 FUNCTION: PangoFontMap*
20 pango_cairo_font_map_new  ( ) ;
21
22 FUNCTION: PangoFontMap*
23 pango_cairo_font_map_new_for_font_type ( cairo_font_type_t fonttype ) ;
24
25 FUNCTION: PangoFontMap*
26 pango_cairo_font_map_get_default ( ) ;
27
28 FUNCTION: cairo_font_type_t
29 pango_cairo_font_map_get_font_type ( PangoCairoFontMap* fontmap ) ;
30
31 FUNCTION: void
32 pango_cairo_font_map_set_resolution ( PangoCairoFontMap* fontmap, double dpi ) ;
33
34 FUNCTION: double
35 pango_cairo_font_map_get_resolution ( PangoCairoFontMap* fontmap ) ;
36
37 FUNCTION: PangoContext*
38 pango_cairo_font_map_create_context ( PangoCairoFontMap* fontmap ) ;
39
40 FUNCTION: cairo_scaled_font_t*
41 pango_cairo_font_get_scaled_font ( PangoCairoFont* font ) ;
42
43 ! Update a Pango context for the current state of a cairo context
44 FUNCTION: void
45 pango_cairo_update_context ( cairo_t* cr, PangoContext* context ) ;
46
47 FUNCTION: void
48 pango_cairo_context_set_font_options ( PangoContext* context, cairo_font_options_t* options ) ;
49
50 FUNCTION: cairo_font_options_t*
51 pango_cairo_context_get_font_options ( PangoContext* context ) ;
52
53 FUNCTION: void
54 pango_cairo_context_set_resolution ( PangoContext* context, double dpi ) ;
55
56 FUNCTION: double
57 pango_cairo_context_get_resolution ( PangoContext* context ) ;
58
59 ! Convenience
60 FUNCTION: PangoLayout*
61 pango_cairo_create_layout ( cairo_t* cr ) ;
62
63 FUNCTION: void
64 pango_cairo_update_layout ( cairo_t* cr, PangoLayout* layout ) ;
65
66 ! Rendering
67 FUNCTION: void
68 pango_cairo_show_glyph_string ( cairo_t* cr, PangoFont* font, PangoGlyphString* glyphs ) ;
69
70 FUNCTION: void
71 pango_cairo_show_layout_line ( cairo_t* cr, PangoLayoutLine* line ) ;
72
73 FUNCTION: void
74 pango_cairo_show_layout ( cairo_t* cr, PangoLayout* layout ) ;
75
76 FUNCTION: void
77 pango_cairo_show_error_underline ( cairo_t* cr, double x, double y, double width, double height ) ;
78
79 ! Rendering to a path
80 FUNCTION: void
81 pango_cairo_glyph_string_path ( cairo_t* cr, PangoFont* font, PangoGlyphString* glyphs ) ;
82
83 FUNCTION: void
84 pango_cairo_layout_line_path  ( cairo_t* cr, PangoLayoutLine* line ) ;
85
86 FUNCTION: void
87 pango_cairo_layout_path ( cairo_t* cr, PangoLayout* layout ) ;
88
89 FUNCTION: void
90 pango_cairo_error_underline_path ( cairo_t* cr, double x, double y, double width, double height ) ;
91
92 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
93 ! Higher level words and combinators
94 ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
95
96 USING: pango.layouts
97 destructors accessors namespaces kernel cairo ;
98
99 : (with-pango) ( layout quot -- )
100     >r alien>> pango-layout r> with-variable ; inline
101
102 : with-pango-cairo ( quot -- )
103     cr pango_cairo_create_layout swap with-layout ; inline
104
105 MEMO: dummy-cairo ( -- cr )
106     CAIRO_FORMAT_ARGB32 0 0 cairo_image_surface_create cairo_create ;
107
108 : dummy-pango ( quot -- )
109     >r dummy-cairo cairo r> [ with-pango-cairo ] curry with-variable ; inline
110
111 : layout-size ( quot -- dim )
112     [ layout pango-layout-get-pixel-size 2array ] compose dummy-pango ; inline
113
114 : show-layout ( -- )
115     cr layout pango_cairo_show_layout ;
116
117 : families ( -- families )
118     pango_cairo_font_map_get_default list-families ;