… | |
… | |
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 | |
45 | typedef Mix_Chunk *CFClient__MixChunk; |
47 | typedef Mix_Chunk *CFClient__MixChunk; |
46 | typedef Mix_Music *CFClient__MixMusic; |
48 | typedef Mix_Music *CFClient__MixMusic; |
47 | |
49 | |
48 | static PangoContext *context; |
50 | static PangoContext *context; |
49 | static PangoFontMap *fontmap; |
51 | static PangoFontMap *fontmap; |
… | |
… | |
64 | layout_update (CFClient__Layout self) |
66 | layout_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 | |
80 | static void |
87 | static void |
81 | layout_get_pixel_size (CFClient__Layout self, int *w, int *h) |
88 | layout_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 | |
529 | void |
537 | void |
530 | load_image_inline (SV *image_) |
538 | load_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 | |
640 | void |
651 | void |
641 | DESTROY (CFClient::Layout self) |
652 | DESTROY (CFClient::Layout self) |