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.17 by root, Tue Apr 11 17:02:35 2006 UTC vs.
Revision 1.22 by root, Wed Apr 12 20:06:36 2006 UTC

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/pangofc-fontmap.h>
12#include <pango/pangoft2.h> 12#include <pango/pangoft2.h>
13
14#include <sys/time.h>
15#include <sys/types.h>
16#include <unistd.h>
13 17
14#include <sys/types.h> 18#include <sys/types.h>
15#include <sys/socket.h> 19#include <sys/socket.h>
16#include <netinet/in.h> 20#include <netinet/in.h>
17#include <netinet/tcp.h> 21#include <netinet/tcp.h>
23 PangoLayout *pl; 27 PangoLayout *pl;
24 int base_height; 28 int base_height;
25} *CFClient__Layout; 29} *CFClient__Layout;
26 30
27static void 31static void
32substitute_func (FcPattern *pattern, gpointer data)
33{
34 FcPatternAddBool (pattern, FC_HINTING , 1);
35 FcPatternAddBool (pattern, FC_AUTOHINT, 1);
36}
37
38static void
28layout_update (CFClient__Layout self) 39layout_update (CFClient__Layout self)
29{ 40{
41 /* use a random scale factor to account for unknown descenders, 0.8 works
42 * reasonably well with bitstream vera
43 */
30 PangoFontDescription *font = pango_context_get_font_description (context); 44 PangoFontDescription *font = pango_context_get_font_description (context);
31 pango_font_description_set_absolute_size (font, self->base_height * PANGO_SCALE); 45 pango_font_description_set_absolute_size (font, self->base_height * (PANGO_SCALE * 8 / 10));
32} 46}
33 47
34static void 48static void
35layout_get_pixel_size (CFClient__Layout self, int *w, int *h) 49layout_get_pixel_size (CFClient__Layout self, int *w, int *h)
36{ 50{
37 PangoFontDescription *font = pango_context_get_font_description (context); 51 layout_update (self);
38 pango_font_description_set_absolute_size (font, self->base_height * PANGO_SCALE);
39 52
40 pango_layout_get_pixel_size (self->pl, w, h); 53 pango_layout_get_pixel_size (self->pl, w, h);
41 54
42 *w = (*w + 3) & ~3; 55 *w = (*w + 3) & ~3;
43 if (!*w) *w = 1; 56 if (!*w) *w = 1;
49PROTOTYPES: ENABLE 62PROTOTYPES: ENABLE
50 63
51BOOT: 64BOOT:
52{ 65{
53 fontmap = pango_ft2_font_map_new (); 66 fontmap = pango_ft2_font_map_new ();
67 pango_ft2_font_map_set_default_substitute ((PangoFT2FontMap *)fontmap, substitute_func, 0, 0);
54 context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)fontmap); 68 context = pango_ft2_font_map_create_context ((PangoFT2FontMap *)fontmap);
55} 69}
56 70
57void 71void
58lowdelay (int fd, int val = 1) 72lowdelay (int fd, int val = 1)
212 double t = SvNV (*hv_fetch (hv, "t", 1, 1)); 226 double t = SvNV (*hv_fetch (hv, "t", 1, 1));
213 int name = SvIV (*hv_fetch (hv, "name", 4, 1)); 227 int name = SvIV (*hv_fetch (hv, "name", 4, 1));
214 228
215 if (items < 5) 229 if (items < 5)
216 { 230 {
217 w = SvNV (*hv_fetch (hv, "width", 5, 1)); 231 w = SvNV (*hv_fetch (hv, "w", 1, 1));
218 h = SvNV (*hv_fetch (hv, "height", 6, 1)); 232 h = SvNV (*hv_fetch (hv, "h", 1, 1));
219 } 233 }
220 234
221 glBindTexture (GL_TEXTURE_2D, name); 235 glBindTexture (GL_TEXTURE_2D, name);
222 glBegin (GL_QUADS); 236 glBegin (GL_QUADS);
223 glTexCoord2d (0, 0); glVertex2d (x , y ); 237 glTexCoord2d (0, 0); glVertex2d (x , y );

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines