ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/Client.xs
(Generate patch)

Comparing deliantra/Deliantra-Client/Client.xs (file contents):
Revision 1.105 by root, Mon Jun 5 03:33:09 2006 UTC vs.
Revision 1.111 by root, Mon Jun 12 13:26:14 2006 UTC

10#include "XSUB.h" 10#include "XSUB.h"
11 11
12#include <math.h> 12#include <math.h>
13#include <string.h> 13#include <string.h>
14#include <stdio.h> 14#include <stdio.h>
15#include <stdlib.h>
15 16
16#include <SDL.h> 17#include <SDL.h>
17#include <SDL_endian.h> 18#include <SDL_endian.h>
18#include <SDL_image.h> 19#include <SDL_image.h>
19#include <SDL_mixer.h> 20#include <SDL_mixer.h>
85static PangoFontMap *ft2_fontmap, *cairo_fontmap; 86static PangoFontMap *ft2_fontmap, *cairo_fontmap;
86 87
87static void 88static void
88substitute_func (FcPattern *pattern, gpointer data) 89substitute_func (FcPattern *pattern, gpointer data)
89{ 90{
90 FcPatternAddBool (pattern, FC_HINTING , 1); 91 FcPatternAddBool (pattern, FC_HINTING, 1);
92#ifdef FC_HINT_STYLE
93 FcPatternAddBool (pattern, FC_HINT_STYLE, FC_HINT_FULL);
94#endif
95#ifdef _WIN32
91 //FcPatternAddBool (pattern, FC_AUTOHINT, 1); 96 FcPatternAddBool (pattern, FC_AUTOHINT, 1);
97#else
92 FcPatternAddBool (pattern, FC_AUTOHINT, 0); 98 FcPatternAddBool (pattern, FC_AUTOHINT, 0);
99#endif
93} 100}
94 101
95static void 102static void
96layout_update_font (CFClient__Layout self) 103layout_update_font (CFClient__Layout self)
97{ 104{
422 { 429 {
423 ft2_fontmap = pango_ft2_font_map_new (); 430 ft2_fontmap = pango_ft2_font_map_new ();
424 pango_ft2_font_map_set_default_substitute ((PangoFT2FontMap *)ft2_fontmap, substitute_func, 0, 0); 431 pango_ft2_font_map_set_default_substitute ((PangoFT2FontMap *)ft2_fontmap, substitute_func, 0, 0);
425 ft2_context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)ft2_fontmap); 432 ft2_context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)ft2_fontmap);
426 } 433 }
427
428 { 434 {
429 cairo_font_options_t *fopt = cairo_font_options_create (); 435 cairo_font_options_t *fopt = cairo_font_options_create ();
430 cairo_fontmap = pango_cairo_font_map_get_default (); 436 cairo_fontmap = pango_cairo_font_map_get_default ();
431 cairo_context = pango_cairo_font_map_create_context ((PangoCairoFontMap *)cairo_fontmap); 437 cairo_context = pango_cairo_font_map_create_context ((PangoCairoFontMap *)cairo_fontmap);
438#ifdef _WIN32
439 // cairo looks like shit eaten twice on windows
440 cairo_font_options_set_antialias (fopt, CAIRO_ANTIALIAS_NONE);
441#else
432 cairo_font_options_set_antialias (fopt, CAIRO_ANTIALIAS_GRAY); 442 cairo_font_options_set_antialias (fopt, CAIRO_ANTIALIAS_GRAY);
443#endif
433 cairo_font_options_set_hint_style (fopt, CAIRO_HINT_STYLE_FULL); 444 cairo_font_options_set_hint_style (fopt, CAIRO_HINT_STYLE_FULL);
434 cairo_font_options_set_hint_metrics (fopt, CAIRO_HINT_METRICS_ON); 445 cairo_font_options_set_hint_metrics (fopt, CAIRO_HINT_METRICS_ON);
435 pango_cairo_context_set_font_options (cairo_context, fopt); 446 pango_cairo_context_set_font_options (cairo_context, fopt);
436 cairo_font_options_destroy (fopt); 447 cairo_font_options_destroy (fopt);
437 } 448 }
693 CODE: 704 CODE:
694 fprintf (stderr, "FATAL: %s\n", message); 705 fprintf (stderr, "FATAL: %s\n", message);
695#ifdef _WIN32 706#ifdef _WIN32
696 MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR); 707 MessageBox (0, message, "Crossfire+ Fatal Error", MB_OK | MB_ICONERROR);
697#endif 708#endif
698 exit (1); 709 _Exit (1);
710
711void
712_exit (int retval)
713 CODE:
714 _Exit (retval);
699 715
700MODULE = CFClient PACKAGE = CFClient::Font 716MODULE = CFClient PACKAGE = CFClient::Font
701 717
702CFClient::Font 718CFClient::Font
703new_from_file (SV *class, char *path, int id = 0) 719new_from_file (SV *class, char *path, int id = 0)
724MODULE = CFClient PACKAGE = CFClient::Layout 740MODULE = CFClient PACKAGE = CFClient::Layout
725 741
726CFClient::Layout 742CFClient::Layout
727new (SV *class, int rgba = 0) 743new (SV *class, int rgba = 0)
728 CODE: 744 CODE:
729#if _WIN32
730 //rgba = 0;//D makes text nicer, breaks TextView
731#endif
732 rgba=1;//D
733 New (0, RETVAL, 1, struct cf_layout); 745 New (0, RETVAL, 1, struct cf_layout);
734 746
735 RETVAL->pl = pango_layout_new (rgba ? cairo_context : ft2_context); 747 RETVAL->pl = pango_layout_new (rgba ? cairo_context : ft2_context);
736 RETVAL->rgba = rgba; 748 RETVAL->rgba = rgba;
737 RETVAL->r = 1.; 749 RETVAL->r = 1.;
781 793
782SV * 794SV *
783get_text (CFClient::Layout self) 795get_text (CFClient::Layout self)
784 CODE: 796 CODE:
785 RETVAL = newSVpv (pango_layout_get_text (self->pl), 0); 797 RETVAL = newSVpv (pango_layout_get_text (self->pl), 0);
786 SvUTF8_on (RETVAL); 798 sv_utf8_decode (RETVAL);
787 OUTPUT: 799 OUTPUT:
788 RETVAL 800 RETVAL
789 801
790void 802void
791set_foreground (CFClient::Layout self, float r, float g, float b, float a = 1.) 803set_foreground (CFClient::Layout self, float r, float g, float b, float a = 1.)
1047DESTROY (CFClient::Map self) 1059DESTROY (CFClient::Map self)
1048 CODE: 1060 CODE:
1049{ 1061{
1050 map_clear (self); 1062 map_clear (self);
1051 Safefree (self->face); 1063 Safefree (self->face);
1064 Safefree (self->tex);
1052 Safefree (self); 1065 Safefree (self);
1053} 1066}
1054 1067
1055void 1068void
1056clear (CFClient::Map self) 1069clear (CFClient::Map self)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines