… | |
… | |
6 | |
6 | |
7 | #include <SDL.h> |
7 | #include <SDL.h> |
8 | #include <SDL_opengl.h> |
8 | #include <SDL_opengl.h> |
9 | |
9 | |
10 | #include <pango/pango.h> |
10 | #include <pango/pango.h> |
|
|
11 | #include <pango/pangofc-fontmap.h> |
11 | #include <pango/pangoft2.h> |
12 | #include <pango/pangoft2.h> |
|
|
13 | |
|
|
14 | #include <sys/types.h> |
|
|
15 | #include <sys/socket.h> |
|
|
16 | #include <netinet/in.h> |
|
|
17 | #include <netinet/tcp.h> |
12 | |
18 | |
13 | static PangoContext *context; |
19 | static PangoContext *context; |
14 | static PangoFontMap *fontmap; |
20 | static PangoFontMap *fontmap; |
15 | |
21 | |
16 | MODULE = Crossfire::Client PACKAGE = Crossfire::Client |
22 | MODULE = Crossfire::Client PACKAGE = Crossfire::Client |
17 | |
23 | |
18 | BOOT: |
24 | BOOT: |
19 | { |
25 | { |
20 | fontmap = pango_ft2_font_map_new (); |
26 | fontmap = pango_ft2_font_map_new (); |
21 | context = pango_context_new (); |
27 | context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)fontmap); |
22 | pango_context_set_font_map (context, fontmap); |
|
|
23 | } |
28 | } |
|
|
29 | |
|
|
30 | void |
|
|
31 | lowdelay (int fd, int val = 1) |
|
|
32 | CODE: |
|
|
33 | setsockopt (fd, IPPROTO_TCP, TCP_NODELAY, &val, sizeof (val)); |
24 | |
34 | |
25 | char * |
35 | char * |
26 | gl_version () |
36 | gl_version () |
27 | CODE: |
37 | CODE: |
28 | RETVAL = (char *)glGetString (GL_VERSION); |
38 | RETVAL = (char *)glGetString (GL_VERSION); |
… | |
… | |
35 | RETVAL = (char *)glGetString (GL_EXTENSIONS); |
45 | RETVAL = (char *)glGetString (GL_EXTENSIONS); |
36 | OUTPUT: |
46 | OUTPUT: |
37 | RETVAL |
47 | RETVAL |
38 | |
48 | |
39 | void |
49 | void |
|
|
50 | set_font (char *file) |
|
|
51 | CODE: |
|
|
52 | { |
|
|
53 | int count; |
|
|
54 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)file, 0, 0, &count); |
|
|
55 | FcConfigAppFontAddFile (0, (const FcChar8 *)file); /* no idea wether this is required */ |
|
|
56 | PangoFontDescription *font = pango_fc_font_description_from_pattern (pattern, 0); |
|
|
57 | FcPatternDestroy (pattern); |
|
|
58 | pango_context_set_font_description (context, font); |
|
|
59 | } |
|
|
60 | |
|
|
61 | void |
40 | font_render (SV *text_, int height) |
62 | font_render (SV *text_, int height = 10) |
41 | PPCODE: |
63 | PPCODE: |
42 | { |
64 | { |
43 | STRLEN textlen; |
65 | STRLEN textlen; |
44 | char *text = SvPVutf8 (text_, textlen); |
66 | char *text = SvPVutf8 (text_, textlen); |
45 | SV *retval; |
67 | SV *retval; |
46 | int w, h; |
68 | int w, h; |
47 | FT_Bitmap bitmap; |
69 | FT_Bitmap bitmap; |
48 | PangoLayout *layout; |
70 | PangoLayout *layout; |
49 | PangoFontDescription *font = pango_context_get_font_description (context); |
71 | PangoFontDescription *font = pango_context_get_font_description (context); |
50 | pango_font_description_set_absolute_size (font, 40 * PANGO_SCALE); |
72 | pango_font_description_set_absolute_size (font, height * PANGO_SCALE); |
51 | |
73 | |
52 | layout = pango_layout_new (context); |
74 | layout = pango_layout_new (context); |
53 | pango_layout_set_markup (layout, text, textlen); |
75 | pango_layout_set_markup (layout, text, textlen); |
54 | pango_layout_get_pixel_size (layout, &w, &h); |
76 | pango_layout_get_pixel_size (layout, &w, &h); |
55 | |
77 | |