… | |
… | |
25 | } *CFClient__Layout; |
25 | } *CFClient__Layout; |
26 | |
26 | |
27 | static void |
27 | static void |
28 | layout_get_pixel_size (CFClient__Layout self, int *w, int *h) |
28 | layout_get_pixel_size (CFClient__Layout self, int *w, int *h) |
29 | { |
29 | { |
|
|
30 | PangoFontDescription *font = pango_context_get_font_description (context); |
|
|
31 | pango_font_description_set_absolute_size (font, self->base_height * PANGO_SCALE); |
|
|
32 | |
30 | pango_layout_get_pixel_size (self->pl, w, h); |
33 | pango_layout_get_pixel_size (self->pl, w, h); |
31 | |
34 | |
32 | *w = (*w + 3) & ~3; |
35 | *w = (*w + 3) & ~3; |
33 | if (!*w) *w = 1; |
36 | if (!*w) *w = 1; |
34 | if (!*h) *h = 1; |
37 | if (!*h) *h = 1; |
… | |
… | |
106 | |
109 | |
107 | pango_layout_set_markup (self->pl, text, textlen); |
110 | pango_layout_set_markup (self->pl, text, textlen); |
108 | } |
111 | } |
109 | |
112 | |
110 | void |
113 | void |
|
|
114 | set_height (CFClient::Layout self, int base_height) |
|
|
115 | CODE: |
|
|
116 | self->base_height = base_height; |
|
|
117 | |
|
|
118 | void |
111 | set_width (CFClient::Layout self, int max_width = -1) |
119 | set_width (CFClient::Layout self, int max_width = -1) |
112 | CODE: |
120 | CODE: |
113 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
121 | pango_layout_set_width (self->pl, max_width < 0 ? max_width : max_width * PANGO_SCALE); |
114 | |
122 | |
115 | void |
123 | void |
116 | size (CFClient::Layout self) |
124 | size (CFClient::Layout self) |
117 | PPCODE: |
125 | PPCODE: |
118 | { |
126 | { |
119 | int w, h; |
127 | int w, h; |
120 | |
|
|
121 | PangoFontDescription *font = pango_context_get_font_description (context); |
|
|
122 | pango_font_description_set_absolute_size (font, self->base_height * PANGO_SCALE); |
|
|
123 | |
128 | |
124 | layout_get_pixel_size (self, &w, &h); |
129 | layout_get_pixel_size (self, &w, &h); |
125 | |
130 | |
126 | EXTEND (SP, 2); |
131 | EXTEND (SP, 2); |
127 | PUSHs (sv_2mortal (newSViv (w))); |
132 | PUSHs (sv_2mortal (newSViv (w))); |