Remove unmaintained/pango
parent
8ec3196d18
commit
8e9ca923b7
|
@ -1,118 +0,0 @@
|
|||
! 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
|
||||
memoize
|
||||
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 ) ;
|
||||
|
||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
! Higher level words and combinators
|
||||
! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
USING: pango.layouts
|
||||
destructors accessors namespaces kernel cairo ;
|
||||
|
||||
: (with-pango) ( layout quot -- )
|
||||
>r alien>> pango-layout r> with-variable ; inline
|
||||
|
||||
: with-pango-cairo ( quot -- )
|
||||
cr pango_cairo_create_layout swap with-layout ; inline
|
||||
|
||||
MEMO: dummy-cairo ( -- cr )
|
||||
CAIRO_FORMAT_ARGB32 0 0 cairo_image_surface_create cairo_create ;
|
||||
|
||||
: dummy-pango ( quot -- )
|
||||
>r dummy-cairo cairo r> [ with-pango-cairo ] curry with-variable ; inline
|
||||
|
||||
: layout-size ( quot -- dim )
|
||||
[ layout pango-layout-get-pixel-size 2array ] compose dummy-pango ; inline
|
||||
|
||||
: show-layout ( -- )
|
||||
cr layout pango_cairo_show_layout ;
|
||||
|
||||
: families ( -- families )
|
||||
pango_cairo_font_map_get_default list-families ;
|
|
@ -1,27 +0,0 @@
|
|||
! Copyright (C) 2008 Matthew Willis.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: pango.cairo pango.gadgets
|
||||
cairo.gadgets arrays namespaces
|
||||
fry accessors ui.gadgets
|
||||
sequences opengl.gadgets
|
||||
kernel pango.layouts ;
|
||||
|
||||
IN: pango.cairo.gadgets
|
||||
|
||||
TUPLE: pango-cairo-gadget < pango-gadget ;
|
||||
|
||||
SINGLETON: pango-cairo-backend
|
||||
pango-cairo-backend pango-backend set-global
|
||||
|
||||
M: pango-cairo-backend construct-pango
|
||||
pango-cairo-gadget construct-gadget ;
|
||||
|
||||
: setup-layout ( gadget -- quot )
|
||||
[ font>> ] [ text>> ] bi
|
||||
'[ , layout-font , layout-text ] ; inline
|
||||
|
||||
M: pango-cairo-gadget render* ( gadget -- )
|
||||
setup-layout [ layout-size dup ]
|
||||
[
|
||||
'[ [ @ show-layout ] with-pango-cairo ]
|
||||
] bi render-cairo render-bytes* ;
|
|
@ -1,18 +0,0 @@
|
|||
! Copyright (C) 2008 Matthew Willis.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: prettyprint sequences ui.gadgets.panes
|
||||
pango.cairo.gadgets math kernel cairo cairo.ffi
|
||||
pango.cairo pango.gadgets tools.time namespaces assocs
|
||||
threads io.backend io.encodings.utf8 io.files ;
|
||||
|
||||
IN: pango.cairo.samples
|
||||
|
||||
: hello-pango ( -- )
|
||||
"monospace 10" "resource:extra/pango/cairo/gadgets/gadgets.factor"
|
||||
normalize-path utf8 file-contents
|
||||
<pango> gadget. ;
|
||||
|
||||
: time-pango ( -- )
|
||||
[ hello-pango ] time ;
|
||||
|
||||
MAIN: time-pango
|
|
@ -1,40 +0,0 @@
|
|||
! 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 ) ;
|
||||
|
||||
: list-families ( PangoFontMap* -- PangoFontFamily*-seq )
|
||||
0 <int> 0 <int> [ pango_font_map_list_families ] 2keep
|
||||
*int swap *void* [ swap c-void*-array> ] [ g_free ] bi ;
|
||||
|
||||
: list-faces ( PangoFontFamily* -- PangoFontFace*-seq )
|
||||
0 <int> 0 <int> [ pango_font_family_list_faces ] 2keep
|
||||
*int swap *void* [ swap c-void*-array> ] [ g_free ] bi ;
|
||||
|
||||
: list-sizes ( PangoFontFace* -- ints )
|
||||
0 <int> 0 <int> [ pango_font_face_list_sizes ] 2keep
|
||||
*int swap *void* [ swap c-int-array> ] [ g_free ] bi ;
|
||||
|
||||
: monospace? ( PangoFontFamily* -- ? )
|
||||
pango_font_family_is_monospace 1 = ;
|
|
@ -1,56 +0,0 @@
|
|||
USING: alien alien.c-types
|
||||
math kernel byte-arrays freetype
|
||||
opengl.gadgets accessors pango
|
||||
ui.gadgets memoize
|
||||
arrays sequences libc opengl.gl
|
||||
system combinators alien.syntax
|
||||
pango.layouts ;
|
||||
IN: pango.ft2
|
||||
|
||||
<< "pangoft2" {
|
||||
{ [ os winnt? ] [ "libpangocairo-1.0-0.dll" ] }
|
||||
{ [ os macosx? ] [ "libpangocairo-1.0.0.dylib" ] }
|
||||
{ [ os unix? ] [ "libpangoft2-1.0.so" ] }
|
||||
} cond "cdecl" add-library >>
|
||||
|
||||
LIBRARY: pangoft2
|
||||
|
||||
FUNCTION: PangoFontMap*
|
||||
pango_ft2_font_map_new ( ) ;
|
||||
|
||||
FUNCTION: PangoContext*
|
||||
pango_ft2_font_map_create_context ( PangoFT2FontMap* fontmap ) ;
|
||||
|
||||
FUNCTION: void
|
||||
pango_ft2_render_layout ( FT_Bitmap* bitmap, PangoLayout* layout, int x, int y ) ;
|
||||
|
||||
: 4*-ceil ( n -- k*4 )
|
||||
3 + 4 /i 4 * ;
|
||||
|
||||
: <ft-bitmap> ( width height -- ft-bitmap )
|
||||
swap dup
|
||||
2dup * 4*-ceil
|
||||
"uchar" malloc-array
|
||||
256
|
||||
FT_PIXEL_MODE_GRAY
|
||||
"FT_Bitmap" <c-object> dup >r
|
||||
{
|
||||
[ set-FT_Bitmap-pixel_mode ]
|
||||
[ set-FT_Bitmap-num_grays ]
|
||||
[ set-FT_Bitmap-buffer ]
|
||||
[ set-FT_Bitmap-pitch ]
|
||||
[ set-FT_Bitmap-width ]
|
||||
[ set-FT_Bitmap-rows ]
|
||||
} cleave r> ;
|
||||
|
||||
: render-layout ( layout -- dims alien )
|
||||
[
|
||||
pango-layout-get-pixel-size
|
||||
2array dup 2^-bounds first2 <ft-bitmap> dup
|
||||
] [ 0 0 pango_ft2_render_layout ] bi FT_Bitmap-buffer ;
|
||||
|
||||
MEMO: ft2-context ( -- PangoContext* )
|
||||
pango_ft2_font_map_new pango_ft2_font_map_create_context ;
|
||||
|
||||
: with-ft2-layout ( quot -- )
|
||||
ft2-context pango_layout_new swap with-layout ; inline
|
|
@ -1,20 +0,0 @@
|
|||
! Copyright (C) 2008 Matthew Willis.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: pango.ft2 pango.gadgets opengl.gadgets
|
||||
accessors kernel opengl.gl libc
|
||||
sequences namespaces ui.gadgets pango.layouts ;
|
||||
IN: pango.ft2.gadgets
|
||||
|
||||
TUPLE: pango-ft2-gadget < pango-gadget ;
|
||||
|
||||
SINGLETON: pango-ft2-backend
|
||||
pango-ft2-backend pango-backend set-global
|
||||
|
||||
M: pango-ft2-backend construct-pango
|
||||
pango-ft2-gadget construct-gadget ;
|
||||
|
||||
M: pango-ft2-gadget render*
|
||||
[
|
||||
[ text>> layout-text ] [ font>> layout-font ] bi
|
||||
layout render-layout
|
||||
] with-ft2-layout [ GL_ALPHA render-bytes* ] keep free ;
|
|
@ -1,19 +0,0 @@
|
|||
! Copyright (C) 2008 Matthew Willis.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: opengl.gadgets kernel
|
||||
arrays
|
||||
accessors ;
|
||||
|
||||
IN: pango.gadgets
|
||||
|
||||
TUPLE: pango-gadget < texture-gadget text font ;
|
||||
|
||||
M: pango-gadget cache-key* [ font>> ] [ text>> ] bi 2array ;
|
||||
|
||||
SYMBOL: pango-backend
|
||||
HOOK: construct-pango pango-backend ( -- gadget )
|
||||
|
||||
: <pango> ( font text -- gadget )
|
||||
construct-pango
|
||||
swap >>text
|
||||
swap >>font ;
|
|
@ -1,30 +0,0 @@
|
|||
USING: alien alien.c-types
|
||||
math
|
||||
destructors accessors namespaces
|
||||
pango kernel ;
|
||||
IN: pango.layouts
|
||||
|
||||
: pango-layout-get-pixel-size ( layout -- width height )
|
||||
0 <int> 0 <int> [ pango_layout_get_pixel_size ] 2keep
|
||||
[ *int ] bi@ ;
|
||||
|
||||
TUPLE: pango-layout alien ;
|
||||
C: <pango-layout> pango-layout
|
||||
M: pango-layout dispose ( alien -- ) alien>> g_object_unref ;
|
||||
|
||||
: layout ( -- pango-layout ) pango-layout get ;
|
||||
|
||||
: (with-layout) ( pango-layout quot -- )
|
||||
>r alien>> pango-layout r> with-variable ; inline
|
||||
|
||||
: with-layout ( layout quot -- )
|
||||
>r <pango-layout> r> [ (with-layout) ] curry with-disposal ; inline
|
||||
|
||||
: layout-font ( str -- )
|
||||
pango_font_description_from_string
|
||||
dup zero? [ "pango: not a valid font." throw ] when
|
||||
layout over pango_layout_set_font_description
|
||||
pango_font_description_free ;
|
||||
|
||||
: layout-text ( str -- )
|
||||
layout swap -1 pango_layout_set_text ;
|
|
@ -1,62 +0,0 @@
|
|||
! Copyright (C) 2008 Matthew Willis.
|
||||
! See http://factorcode.org/license.txt for BSD license
|
||||
USING: system
|
||||
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
|
||||
|
||||
: 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 ) ;
|
||||
|
||||
! glib functions
|
||||
|
||||
TYPEDEF: void* gpointer
|
||||
|
||||
FUNCTION: void
|
||||
g_object_unref ( gpointer object ) ;
|
||||
|
||||
FUNCTION: void
|
||||
g_free ( gpointer mem ) ;
|
Loading…
Reference in New Issue