… | |
… | |
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 = pango_layout_get_font_description (self->pl); |
70 | |
72 | |
71 | int height = self->base_height * (PANGO_SCALE * 8 / 10); |
73 | int height = self->base_height * (PANGO_SCALE * 8 / 10); |
|
|
74 | |
|
|
75 | if (height < MIN_FONT_HEIGHT) |
|
|
76 | height = MIN_FONT_HEIGHT; |
72 | |
77 | |
73 | if (pango_font_description_get_size (font) != height) |
78 | if (pango_font_description_get_size (font) != height) |
74 | { |
79 | { |
|
|
80 | font = pango_font_description_copy (font); |
75 | pango_font_description_set_absolute_size (font, height); |
81 | pango_font_description_set_absolute_size (font, height); |
76 | pango_layout_context_changed (self->pl); |
82 | pango_layout_set_font_description (self->pl, font); |
77 | } |
83 | } |
78 | } |
84 | } |
79 | |
85 | |
80 | static void |
86 | static void |
81 | layout_get_pixel_size (CFClient__Layout self, int *w, int *h) |
87 | layout_get_pixel_size (CFClient__Layout self, int *w, int *h) |
… | |
… | |
521 | { |
527 | { |
522 | int count; |
528 | int count; |
523 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)file, 0, 0, &count); |
529 | FcPattern *pattern = FcFreeTypeQuery ((const FcChar8 *)file, 0, 0, &count); |
524 | PangoFontDescription *font = pango_fc_font_description_from_pattern (pattern, 0); |
530 | PangoFontDescription *font = pango_fc_font_description_from_pattern (pattern, 0); |
525 | FcPatternDestroy (pattern); |
531 | FcPatternDestroy (pattern); |
|
|
532 | pango_font_description_set_absolute_size (font, MIN_FONT_HEIGHT); |
526 | pango_context_set_font_description (context, font); |
533 | pango_context_set_font_description (context, font); |
527 | } |
534 | } |
528 | |
535 | |
529 | void |
536 | void |
530 | load_image_inline (SV *image_) |
537 | load_image_inline (SV *image_) |
… | |
… | |
632 | CODE: |
639 | CODE: |
633 | New (0, RETVAL, 1, struct cf_layout); |
640 | New (0, RETVAL, 1, struct cf_layout); |
634 | RETVAL->base_height = base_height; |
641 | RETVAL->base_height = base_height; |
635 | RETVAL->pl = pango_layout_new (context); |
642 | RETVAL->pl = pango_layout_new (context); |
636 | pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR); |
643 | pango_layout_set_wrap (RETVAL->pl, PANGO_WRAP_WORD_CHAR); |
|
|
644 | pango_layout_set_font_description (RETVAL->pl, |
|
|
645 | pango_font_description_copy ( |
|
|
646 | pango_context_get_font_description (context))); |
637 | OUTPUT: |
647 | OUTPUT: |
638 | RETVAL |
648 | RETVAL |
639 | |
649 | |
640 | void |
650 | void |
641 | DESTROY (CFClient::Layout self) |
651 | DESTROY (CFClient::Layout self) |