X11 + Pango platform: improve text drawing with angle.

Make sure that text length computed without angle is equal to text length drawn with angle.
This property is essential so that rotated text appears at controlled location at both ends.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12244 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2017-05-22 14:42:06 +00:00
parent c364bb73f6
commit 3a390bfb5f

View File

@ -1214,8 +1214,14 @@ void Fl_Xlib_Graphics_Driver::draw_unscaled(const char *str, int n, int x, int y
void Fl_Xlib_Graphics_Driver::draw_unscaled(int angle, const char *str, int n, int x, int y) {
PangoMatrix mat = PANGO_MATRIX_INIT; // 1.6
pango_matrix_translate(&mat, x+offset_x_*scale_, y+offset_y_*scale_); // 1.6
double l = width_unscaled(str, n);
pango_matrix_rotate(&mat, angle); // 1.6
pango_context_set_matrix(pctxt_, &mat); // 1.6
pango_layout_set_text(playout_, str, n);
int w, h;
pango_layout_get_pixel_size(playout_, &w, &h);
pango_matrix_scale(&mat, l/w, l/w); // 1.6
pango_context_set_matrix(pctxt_, &mat); // 1.6
do_draw(0, str, n, 0, 0);
pango_context_set_matrix(pctxt_, NULL); // 1.6
}