diff --git a/basis/glib/glib.factor b/basis/glib/glib.factor new file mode 100644 index 0000000000..1d13f91c8b --- /dev/null +++ b/basis/glib/glib.factor @@ -0,0 +1,14 @@ +! Copyright (C) 2008 Matthew Willis. +! See http://factorcode.org/license.txt for BSD license +USING: alien.syntax alien.destructors ; +IN: glib + +TYPEDEF: void* gpointer + +FUNCTION: void +g_object_unref ( gpointer object ) ; + +DESTRUCTOR: g_object_unref + +FUNCTION: void +g_free ( gpointer mem ) ; diff --git a/basis/pango/cairo/cairo.factor b/basis/pango/cairo/cairo.factor new file mode 100644 index 0000000000..171243ba7b --- /dev/null +++ b/basis/pango/cairo/cairo.factor @@ -0,0 +1,88 @@ +! Copyright (C) 2008 Matthew Willis. +! See http://factorcode.org/license.txt for BSD license. +! +! pangocairo bindings, from pango/pangocairo.h +USING: cairo.ffi alien.c-types math alien.syntax system +combinators alien arrays pango pango.fonts ; +IN: pango.cairo + +<< "pangocairo" { + { [ os winnt? ] [ "libpangocairo-1.0-0.dll" ] } + { [ os macosx? ] [ "libpangocairo-1.0.0.dylib" ] } + { [ os unix? ] [ "libpangocairo-1.0.so" ] } +} cond "cdecl" add-library >> + +LIBRARY: pangocairo + +FUNCTION: PangoFontMap* +pango_cairo_font_map_new ( ) ; + +FUNCTION: PangoFontMap* +pango_cairo_font_map_new_for_font_type ( cairo_font_type_t fonttype ) ; + +FUNCTION: PangoFontMap* +pango_cairo_font_map_get_default ( ) ; + +FUNCTION: cairo_font_type_t +pango_cairo_font_map_get_font_type ( PangoCairoFontMap* fontmap ) ; + +FUNCTION: void +pango_cairo_font_map_set_resolution ( PangoCairoFontMap* fontmap, double dpi ) ; + +FUNCTION: double +pango_cairo_font_map_get_resolution ( PangoCairoFontMap* fontmap ) ; + +FUNCTION: PangoContext* +pango_cairo_font_map_create_context ( PangoCairoFontMap* fontmap ) ; + +FUNCTION: cairo_scaled_font_t* +pango_cairo_font_get_scaled_font ( PangoCairoFont* font ) ; + +! Update a Pango context for the current state of a cairo context +FUNCTION: void +pango_cairo_update_context ( cairo_t* cr, PangoContext* context ) ; + +FUNCTION: void +pango_cairo_context_set_font_options ( PangoContext* context, cairo_font_options_t* options ) ; + +FUNCTION: cairo_font_options_t* +pango_cairo_context_get_font_options ( PangoContext* context ) ; + +FUNCTION: void +pango_cairo_context_set_resolution ( PangoContext* context, double dpi ) ; + +FUNCTION: double +pango_cairo_context_get_resolution ( PangoContext* context ) ; + +! Convenience +FUNCTION: PangoLayout* +pango_cairo_create_layout ( cairo_t* cr ) ; + +FUNCTION: void +pango_cairo_update_layout ( cairo_t* cr, PangoLayout* layout ) ; + +! Rendering +FUNCTION: void +pango_cairo_show_glyph_string ( cairo_t* cr, PangoFont* font, PangoGlyphString* glyphs ) ; + +FUNCTION: void +pango_cairo_show_layout_line ( cairo_t* cr, PangoLayoutLine* line ) ; + +FUNCTION: void +pango_cairo_show_layout ( cairo_t* cr, PangoLayout* layout ) ; + +FUNCTION: void +pango_cairo_show_error_underline ( cairo_t* cr, double x, double y, double width, double height ) ; + +! Rendering to a path +FUNCTION: void +pango_cairo_glyph_string_path ( cairo_t* cr, PangoFont* font, PangoGlyphString* glyphs ) ; + +FUNCTION: void +pango_cairo_layout_line_path ( cairo_t* cr, PangoLayoutLine* line ) ; + +FUNCTION: void +pango_cairo_layout_path ( cairo_t* cr, PangoLayout* layout ) ; + +FUNCTION: void +pango_cairo_error_underline_path ( cairo_t* cr, double x, double y, double width, double height ) ; diff --git a/basis/pango/fonts/fonts.factor b/basis/pango/fonts/fonts.factor new file mode 100644 index 0000000000..a6dbef16c9 --- /dev/null +++ b/basis/pango/fonts/fonts.factor @@ -0,0 +1,24 @@ +! Copyright (C) 2008 Matthew Willis. +! See http://factorcode.org/license.txt for BSD license +USING: pango alien.syntax alien.c-types kernel ; +IN: pango.fonts + +LIBRARY: pango + +FUNCTION: void +pango_font_map_list_families ( PangoFontMap* fontmap, PangoFontFamily*** families, int* n_families ) ; + +FUNCTION: char* +pango_font_family_get_name ( PangoFontFamily* family ) ; + +FUNCTION: int +pango_font_family_is_monospace ( PangoFontFamily* family ) ; + +FUNCTION: void +pango_font_family_list_faces ( PangoFontFamily* family, PangoFontFace*** faces, int* n_faces ) ; + +FUNCTION: char* +pango_font_face_get_face_name ( PangoFontFace* face ) ; + +FUNCTION: void +pango_font_face_list_sizes ( PangoFontFace* face, int** sizes, int* n_sizes ) ; diff --git a/basis/pango/layouts/layouts.factor b/basis/pango/layouts/layouts.factor new file mode 100644 index 0000000000..604f2d08f3 --- /dev/null +++ b/basis/pango/layouts/layouts.factor @@ -0,0 +1,33 @@ +! Copyright (C) 2008 Matthew Willis. +! See http://factorcode.org/license.txt for BSD license. +USING: arrays alien alien.c-types math destructors accessors +namespaces kernel pango pango.cairo cairo.ffi glib ; +IN: pango.layouts + +: layout-dim ( layout -- dim ) + 0 0 [ pango_layout_get_pixel_size ] 2keep + [ *int ] bi@ 2array ; + +ERROR: bad-font name ; + +: set-layout-font ( str layout -- ) + swap dup pango_font_description_from_string + [ ] [ bad-font ] ?if + &pango_font_description_free + pango_layout_set_font_description ; + +: set-layout-text ( str layout -- ) + -1 pango_layout_set_text ; + +: ( text font cairo -- layout ) + [ + pango_cairo_create_layout |g_object_unref + [ set-layout-font ] keep + [ set-layout-text ] keep + ] with-destructors ; + +: dummy-cairo ( -- cr ) + [ + CAIRO_FORMAT_ARGB32 0 0 cairo_image_surface_create + cairo_create + ] initialize-alien ; diff --git a/basis/pango/pango.factor b/basis/pango/pango.factor new file mode 100644 index 0000000000..22fbc24be7 --- /dev/null +++ b/basis/pango/pango.factor @@ -0,0 +1,54 @@ +! Copyright (C) 2008 Matthew Willis. +! See http://factorcode.org/license.txt for BSD license +USING: system alien.destructors alien.c-types alien.syntax alien +combinators ; +IN: pango + +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +! Helpful functions from other parts of pango +! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + +<< "pango" { + { [ os winnt? ] [ "libpango-1.0-0.dll" ] } + { [ os macosx? ] [ "libpango-1.0.0.dylib" ] } + { [ os unix? ] [ "libpango-1.0.so" ] } +} cond "cdecl" add-library >> + +LIBRARY: pango + +CONSTANT: PANGO_SCALE 1024 + +FUNCTION: PangoLayout* +pango_layout_new ( PangoContext* context ) ; + +FUNCTION: void +pango_layout_set_text ( PangoLayout* layout, char* text, int length ) ; + +FUNCTION: char* +pango_layout_get_text ( PangoLayout* layout ) ; + +FUNCTION: void +pango_layout_get_size ( PangoLayout* layout, int* width, int* height ) ; + +FUNCTION: PangoFontDescription* +pango_font_description_from_string ( char* str ) ; + +FUNCTION: char* +pango_font_description_to_string ( PangoFontDescription* desc ) ; + +FUNCTION: char* +pango_font_description_to_filename ( PangoFontDescription* desc ) ; + +FUNCTION: void +pango_layout_set_font_description ( PangoLayout* layout, PangoFontDescription* desc ) ; + +FUNCTION: PangoFontDescription* +pango_layout_get_font_description ( PangoLayout* layout ) ; + +FUNCTION: void +pango_layout_get_pixel_size ( PangoLayout* layout, int* width, int* height ) ; + +FUNCTION: void +pango_font_description_free ( PangoFontDescription* desc ) ; + +DESTRUCTOR: pango_font_description_free