]> gitweb.factorcode.org Git - factor.git/blob - extra/cairo/pango/gadgets/gadgets.factor
Refactored cairo gadgets, basing them on the texture-gadget in opengl.gadgets
[factor.git] / extra / cairo / pango / gadgets / gadgets.factor
1 ! Copyright (C) 2008 Matthew Willis.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: cairo.pango cairo cairo.ffi cairo.gadgets
4 alien.c-types kernel math ;
5 IN: cairo.pango.gadgets
6
7 : (pango-gadget) ( setup show -- gadget )
8     [ drop layout-size ]
9     [ compose [ with-pango ] curry <cairo-gadget> ] 2bi ;
10
11 : <pango-gadget> ( quot -- gadget )
12     [ cr layout pango_cairo_show_layout ] (pango-gadget) ;
13
14 USING: prettyprint sequences ui.gadgets.panes
15 threads io.backend io.encodings.utf8 io.files ;
16 : hello-pango ( -- )
17     50 [ 6 + ] map [
18         "Sans " swap unparse append
19         [ 
20             cr 0 1 0.2 0.6 cairo_set_source_rgba
21             layout-font "今日は、 Pango!" layout-text
22         ] curry
23         <pango-gadget> gadget. yield
24     ] each
25     [ 
26         "resource:extra/cairo/pango/gadgets/gadgets.factor"
27         normalize-path utf8 file-contents layout-text
28     ] <pango-gadget> gadget. ;
29
30 MAIN: hello-pango