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.57 by root, Fri Apr 21 07:09:10 2006 UTC vs.
Revision 1.60 by root, Sun Apr 23 04:47:02 2006 UTC

40#define FOW_DARKNESS 32 40#define FOW_DARKNESS 32
41 41
42#define MAP_EXTEND_X 32 42#define MAP_EXTEND_X 32
43#define MAP_EXTEND_Y 512 43#define MAP_EXTEND_Y 512
44 44
45#define MIN_FONT_HEIGHT 8 * PANGO_SCALE
46
45typedef Mix_Chunk *CFClient__MixChunk; 47typedef Mix_Chunk *CFClient__MixChunk;
46typedef Mix_Music *CFClient__MixMusic; 48typedef Mix_Music *CFClient__MixMusic;
47 49
48static PangoContext *context; 50static PangoContext *context;
49static PangoFontMap *fontmap; 51static PangoFontMap *fontmap;
64layout_update (CFClient__Layout self) 66layout_update (CFClient__Layout self)
65{ 67{
66 /* use a random scale factor to account for unknown descenders, 0.8 works 68 /* use a random scale factor to account for unknown descenders, 0.8 works
67 * reasonably well with bitstream vera 69 * reasonably well with bitstream vera
68 */ 70 */
69 PangoFontDescription *font = pango_context_get_font_description (context); 71 PangoFontDescription *font = (PangoFontDescription *)
72 pango_layout_get_font_description (self->pl);
70 73
71 int height = self->base_height * (PANGO_SCALE * 8 / 10); 74 int height = self->base_height * (PANGO_SCALE * 8 / 10);
75
76 if (height < MIN_FONT_HEIGHT)
77 height = MIN_FONT_HEIGHT;
72 78
73 if (pango_font_description_get_size (font) != height) 79 if (pango_font_description_get_size (font) != height)
74 { 80 {
81 font = pango_font_description_copy (font);
75 pango_font_description_set_absolute_size (font, height); 82 pango_font_description_set_absolute_size (font, height);
76 pango_layout_context_changed (self->pl); 83 pango_layout_set_font_description (self->pl, font);
77 } 84 }
78} 85}
79 86
80static void 87static void
81layout_get_pixel_size (CFClient__Layout self, int *w, int *h) 88layout_get_pixel_size (CFClient__Layout self, int *w, int *h)
521{ 528{
522 int count; 529 int count;
523 FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)file, 0, 0, &count); 530 FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)file, 0, 0, &count);
524 PangoFontDescription *font = pango_fc_font_description_from_pattern (pattern, 0); 531 PangoFontDescription *font = pango_fc_font_description_from_pattern (pattern, 0);
525 FcPatternDestroy (pattern); 532 FcPatternDestroy (pattern);
533 pango_font_description_set_absolute_size (font, MIN_FONT_HEIGHT);
526 pango_context_set_font_description (context, font); 534 pango_context_set_font_description (context, font);
527} 535}
528 536
529void 537void
530load_image_inline (SV *image_) 538load_image_inline (SV *image_)
632 CODE: 640 CODE:
633 New (0, RETVAL, 1, struct cf_layout); 641 New (0, RETVAL, 1, struct cf_layout);
634 RETVAL->base_height = base_height; 642 RETVAL->base_height = base_height;
635 RETVAL->pl = pango_layout_new (context); 643 RETVAL->pl = pango_layout_new (context);
636 pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR); 644 pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR);
645 pango_layout_set_font_description (RETVAL->pl,
646 pango_font_description_copy (
647 pango_context_get_font_description (context)));
637 OUTPUT: 648 OUTPUT:
638 RETVAL 649 RETVAL
639 650
640void 651void
641DESTROY (CFClient::Layout self) 652DESTROY (CFClient::Layout self)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines