… | |
… | |
16 | MODULE = Crossfire::Client PACKAGE = Crossfire::Client |
16 | MODULE = Crossfire::Client PACKAGE = Crossfire::Client |
17 | |
17 | |
18 | BOOT: |
18 | BOOT: |
19 | { |
19 | { |
20 | fontmap = pango_ft2_font_map_new (); |
20 | fontmap = pango_ft2_font_map_new (); |
21 | context = pango_context_new (); |
21 | context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)fontmap); |
22 | pango_context_set_font_map (context, fontmap); |
|
|
23 | } |
22 | } |
24 | |
23 | |
25 | char * |
24 | char * |
26 | gl_version () |
25 | gl_version () |
27 | CODE: |
26 | CODE: |
… | |
… | |
35 | RETVAL = (char *)glGetString (GL_EXTENSIONS); |
34 | RETVAL = (char *)glGetString (GL_EXTENSIONS); |
36 | OUTPUT: |
35 | OUTPUT: |
37 | RETVAL |
36 | RETVAL |
38 | |
37 | |
39 | void |
38 | void |
|
|
39 | set_font (char *file) |
|
|
40 | CODE: |
|
|
41 | { |
|
|
42 | int count; |
|
|
43 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)file, 0, 0, &count); |
|
|
44 | FcConfigAppFontAddFile (0, (const FcChar8 *)file); /* no idea wether this is required */ |
|
|
45 | PangoFontDescription *font = pango_fc_font_description_from_pattern (pattern); |
|
|
46 | FcPatternDestroy (pattern); |
|
|
47 | pango_context_set_font_description (context, font); |
|
|
48 | } |
|
|
49 | |
|
|
50 | void |
40 | font_render (SV *text_, int height) |
51 | font_render (SV *text_, int height = 10) |
41 | PPCODE: |
52 | PPCODE: |
42 | { |
53 | { |
43 | STRLEN textlen; |
54 | STRLEN textlen; |
44 | char *text = SvPVutf8 (text_, textlen); |
55 | char *text = SvPVutf8 (text_, textlen); |
45 | SV *retval; |
56 | SV *retval; |
46 | int w, h; |
57 | int w, h; |
47 | FT_Bitmap bitmap; |
58 | FT_Bitmap bitmap; |
48 | PangoLayout *layout; |
59 | PangoLayout *layout; |
49 | PangoFontDescription *font = pango_context_get_font_description (context); |
60 | PangoFontDescription *font = pango_context_get_font_description (context); |
50 | pango_font_description_set_absolute_size (font, 40 * PANGO_SCALE); |
61 | pango_font_description_set_absolute_size (font, height * PANGO_SCALE); |
51 | |
62 | |
52 | layout = pango_layout_new (context); |
63 | layout = pango_layout_new (context); |
53 | pango_layout_set_markup (layout, text, textlen); |
64 | pango_layout_set_markup (layout, text, textlen); |
54 | pango_layout_get_pixel_size (layout, &w, &h); |
65 | pango_layout_get_pixel_size (layout, &w, &h); |
55 | |
66 | |
56 | w = (w + 3) & ~3; |
67 | w = (w + 3) & ~3; |
|
|
68 | if (!w) w = 1; |
57 | if (h == 0) h = 1; |
69 | if (!h) h = 1; |
58 | |
70 | |
59 | retval = newSV (w * h); |
71 | retval = newSV (w * h); |
60 | SvPOK_only (retval); |
72 | SvPOK_only (retval); |
61 | SvCUR_set (retval, w * h); |
73 | SvCUR_set (retval, w * h); |
62 | |
74 | |