--- deliantra/Deliantra-Client/Client.xs 2006/04/11 13:27:48 1.16 +++ deliantra/Deliantra-Client/Client.xs 2006/04/11 19:31:17 1.18 @@ -25,6 +25,13 @@ } *CFClient__Layout; static void +layout_update (CFClient__Layout self) +{ + PangoFontDescription *font = pango_context_get_font_description (context); + pango_font_description_set_absolute_size (font, self->base_height * PANGO_SCALE); +} + +static void layout_get_pixel_size (CFClient__Layout self, int *w, int *h) { PangoFontDescription *font = pango_context_get_font_description (context); @@ -126,6 +133,7 @@ { int w, h; + layout_update (self); layout_get_pixel_size (self, &w, &h); EXTEND (SP, 2); @@ -133,6 +141,33 @@ PUSHs (sv_2mortal (newSViv (h))); } +int +xy_to_index (CFClient::Layout self, int x, int y) + CODE: +{ + int index, trailing; + + layout_update (self); + pango_layout_xy_to_index (self->pl, x * PANGO_SCALE, y * PANGO_SCALE, &index, &trailing); + + RETVAL = index; +} + OUTPUT: + RETVAL + +void +cursor_pos (CFClient::Layout self, int index) + PPCODE: +{ + PangoRectangle strong_pos; + layout_update (self); + pango_layout_get_cursor_pos (self->pl, index, &strong_pos, 0); + EXTEND (SP, 3); + PUSHs (sv_2mortal (newSViv (strong_pos.x / PANGO_SCALE))); + PUSHs (sv_2mortal (newSViv (strong_pos.y / PANGO_SCALE))); + PUSHs (sv_2mortal (newSViv (strong_pos.height / PANGO_SCALE))); +} + void render (CFClient::Layout self) PPCODE: @@ -141,6 +176,7 @@ int w, h; FT_Bitmap bitmap; + layout_update (self); layout_get_pixel_size (self, &w, &h); retval = newSV (w * h); @@ -178,8 +214,8 @@ if (items < 5) { - w = SvNV (*hv_fetch (hv, "width", 5, 1)); - h = SvNV (*hv_fetch (hv, "height", 6, 1)); + w = SvNV (*hv_fetch (hv, "w", 1, 1)); + h = SvNV (*hv_fetch (hv, "h", 1, 1)); } glBindTexture (GL_TEXTURE_2D, name);