1 | #ifdef _WIN32 |
1 | #ifdef _WIN32 |
|
|
2 | # define _WIN32_WINNT 0x0500 // needed to get win2000 api calls |
2 | # include <malloc.h> |
3 | # include <malloc.h> |
|
|
4 | # include <windows.h> |
3 | # pragma warning(disable:4244) |
5 | # pragma warning(disable:4244) |
4 | #endif |
6 | #endif |
5 | |
7 | |
6 | #include "EXTERN.h" |
8 | #include "EXTERN.h" |
7 | #include "perl.h" |
9 | #include "perl.h" |
8 | #include "XSUB.h" |
10 | #include "XSUB.h" |
9 | |
11 | |
|
|
12 | #include <math.h> |
10 | #include <string.h> |
13 | #include <string.h> |
11 | #include <stdio.h> |
14 | #include <stdio.h> |
12 | |
15 | |
13 | #include <SDL.h> |
16 | #include <SDL.h> |
14 | #include <SDL_endian.h> |
17 | #include <SDL_endian.h> |
… | |
… | |
81 | |
84 | |
82 | static void |
85 | static void |
83 | substitute_func (FcPattern *pattern, gpointer data) |
86 | substitute_func (FcPattern *pattern, gpointer data) |
84 | { |
87 | { |
85 | FcPatternAddBool (pattern, FC_HINTING , 1); |
88 | FcPatternAddBool (pattern, FC_HINTING , 1); |
|
|
89 | #ifdef _WIN32 |
|
|
90 | FcPatternAddBool (pattern, FC_AUTOHINT, 1); |
|
|
91 | #else |
86 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
92 | FcPatternAddBool (pattern, FC_AUTOHINT, 0); |
|
|
93 | #endif |
87 | } |
94 | } |
88 | |
95 | |
89 | static void |
96 | static void |
90 | layout_update_font (CFClient__Layout self) |
97 | layout_update_font (CFClient__Layout self) |
91 | { |
98 | { |
… | |
… | |
404 | # undef const_iv |
411 | # undef const_iv |
405 | }; |
412 | }; |
406 | |
413 | |
407 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
414 | for (civ = const_iv + sizeof (const_iv) / sizeof (const_iv [0]); civ-- > const_iv; ) |
408 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
415 | newCONSTSUB (stash, (char *)civ->name, newSViv (civ->iv)); |
|
|
416 | } |
409 | |
417 | |
|
|
418 | void |
|
|
419 | pango_init () |
|
|
420 | CODE: |
|
|
421 | { |
|
|
422 | // delayed, so it can pick up new fonts added by AddFontResourceEx |
410 | ft2_fontmap = pango_ft2_font_map_new (); |
423 | ft2_fontmap = pango_ft2_font_map_new (); |
411 | pango_ft2_font_map_set_default_substitute ((PangoFT2FontMap *)ft2_fontmap, substitute_func, 0, 0); |
424 | pango_ft2_font_map_set_default_substitute ((PangoFT2FontMap *)ft2_fontmap, substitute_func, 0, 0); |
412 | ft2_context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)ft2_fontmap); |
425 | ft2_context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)ft2_fontmap); |
413 | |
426 | |
414 | cairo_fontmap = pango_cairo_font_map_get_default (); |
427 | cairo_fontmap = pango_cairo_font_map_get_default (); |
415 | cairo_context = pango_cairo_font_map_create_context ((PangoCairoFontMap *)cairo_fontmap); |
428 | cairo_context = pango_cairo_font_map_create_context ((PangoCairoFontMap *)cairo_fontmap); |
416 | } |
429 | } |
417 | |
430 | |
418 | int |
431 | int |
419 | SDL_Init (U32 flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO) |
432 | SDL_Init (U32 flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO) |
420 | |
433 | |
… | |
… | |
559 | |
572 | |
560 | void |
573 | void |
561 | add_font (char *file) |
574 | add_font (char *file) |
562 | CODE: |
575 | CODE: |
563 | FcConfigAppFontAddFile (0, (const FcChar8 *)file); /* no idea wether this is required */ |
576 | FcConfigAppFontAddFile (0, (const FcChar8 *)file); /* no idea wether this is required */ |
|
|
577 | #ifdef _WIN32 |
|
|
578 | // cairo... sigh... requires win2000 |
|
|
579 | AddFontResourceEx (file, FR_PRIVATE, 0); |
|
|
580 | #endif |
564 | |
581 | |
565 | void |
582 | void |
566 | load_image_inline (SV *image_) |
583 | load_image_inline (SV *image_) |
567 | ALIAS: |
584 | ALIAS: |
568 | load_image_file = 1 |
585 | load_image_file = 1 |
… | |
… | |
784 | |
801 | |
785 | void |
802 | void |
786 | set_width (CFClient::Layout self, int max_width = -1) |
803 | set_width (CFClient::Layout self, int max_width = -1) |
787 | CODE: |
804 | CODE: |
788 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
805 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
|
|
806 | |
|
|
807 | void |
|
|
808 | set_indent (CFClient::Layout self, int indent) |
|
|
809 | CODE: |
|
|
810 | pango_layout_set_indent (self->pl, indent * PANGO_SCALE); |
|
|
811 | |
|
|
812 | void |
|
|
813 | set_spacing (CFClient::Layout self, int spacing) |
|
|
814 | CODE: |
|
|
815 | pango_layout_set_spacing (self->pl, spacing * PANGO_SCALE); |
|
|
816 | |
|
|
817 | void |
|
|
818 | set_ellipsise (CFClient::Layout self, int ellipsise) |
|
|
819 | CODE: |
|
|
820 | pango_layout_set_ellipsize (self->pl, |
|
|
821 | ellipsise == 1 ? PANGO_ELLIPSIZE_START |
|
|
822 | : ellipsise == 2 ? PANGO_ELLIPSIZE_MIDDLE |
|
|
823 | : ellipsise == 3 ? PANGO_ELLIPSIZE_END |
|
|
824 | : PANGO_ELLIPSIZE_NONE |
|
|
825 | ); |
|
|
826 | |
|
|
827 | void |
|
|
828 | set_single_paragraph_mode (CFClient::Layout self, int spm) |
|
|
829 | CODE: |
|
|
830 | pango_layout_set_single_paragraph_mode (self->pl, !!spm); |
789 | |
831 | |
790 | void |
832 | void |
791 | size (CFClient::Layout self) |
833 | size (CFClient::Layout self) |
792 | PPCODE: |
834 | PPCODE: |
793 | { |
835 | { |
… | |
… | |
1577 | void glEnd () |
1619 | void glEnd () |
1578 | |
1620 | |
1579 | void glColor (float r, float g, float b, float a = 1.0) |
1621 | void glColor (float r, float g, float b, float a = 1.0) |
1580 | PROTOTYPE: @ |
1622 | PROTOTYPE: @ |
1581 | CODE: |
1623 | CODE: |
1582 | glColor4ub (r * 255.999, g * 255.999, b * 255.999, a * 255.999); |
1624 | glColor4ub (MIN ((int)(r * 255.f), 255), |
|
|
1625 | MIN ((int)(g * 255.f), 255), |
|
|
1626 | MIN ((int)(b * 255.f), 255), |
|
|
1627 | MIN ((int)(a * 255.f), 255)); |
1583 | |
1628 | |
1584 | void glVertex (float x, float y, float z = 0.) |
1629 | void glVertex (float x, float y, float z = 0.) |
1585 | CODE: |
1630 | CODE: |
1586 | glVertex3f (x, y, z); |
1631 | glVertex3f (x, y, z); |
1587 | |
1632 | |