* Boston, MA 02111-1307, USA.
*/
-#include <config.h>
+#include "config.h"
#include <math.h>
#include <pango/pangocairo.h>
#include "gdkcairo.h"
PangoMatrix tmp_matrix;
tmp_matrix = *matrix;
- tmp_matrix.x0 = x;
- tmp_matrix.y0 = y;
+ tmp_matrix.x0 += x;
+ tmp_matrix.y0 += y;
+ pango_renderer_set_matrix (renderer, &tmp_matrix);
+
+ x = 0;
+ y = 0;
+ }
+ /* Fall back to introduce a matrix if the coords would scale out of range.
+ * The x and y here will be added to in-layout coordinates. So we cannot
+ * support the entire range here safely. So, we just accept the middle half
+ * and use fallback for the rest. */
+ else if (GDK_PANGO_UNITS_OVERFLOWS (x, y))
+ {
+ PangoMatrix tmp_matrix = PANGO_MATRIX_INIT;
+ tmp_matrix.x0 += x;
+ tmp_matrix.y0 += y;
pango_renderer_set_matrix (renderer, &tmp_matrix);
x = 0;
release_renderer (renderer);
}
-/* Gets the bounds of a layout in device coordinates. Note cut-and-paste
- * between here and gtklabel.c */
-static void
-get_rotated_layout_bounds (PangoLayout *layout,
- GdkRectangle *rect)
-{
- PangoContext *context = pango_layout_get_context (layout);
- const PangoMatrix *matrix = pango_context_get_matrix (context);
- gdouble x_min = 0, x_max = 0, y_min = 0, y_max = 0; /* quiet gcc */
- PangoRectangle logical_rect;
- gint i, j;
-
- pango_layout_get_extents (layout, NULL, &logical_rect);
-
- for (i = 0; i < 2; i++)
- {
- gdouble x = (i == 0) ? logical_rect.x : logical_rect.x + logical_rect.width;
- for (j = 0; j < 2; j++)
- {
- gdouble y = (j == 0) ? logical_rect.y : logical_rect.y + logical_rect.height;
-
- gdouble xt = (x * matrix->xx + y * matrix->xy) / PANGO_SCALE + matrix->x0;
- gdouble yt = (x * matrix->yx + y * matrix->yy) / PANGO_SCALE + matrix->y0;
-
- if (i == 0 && j == 0)
- {
- x_min = x_max = xt;
- y_min = y_max = yt;
- }
- else
- {
- if (xt < x_min)
- x_min = xt;
- if (yt < y_min)
- y_min = yt;
- if (xt > x_max)
- x_max = xt;
- if (yt > y_max)
- y_max = yt;
- }
- }
- }
-
- rect->x = floor (x_min);
- rect->width = ceil (x_max) - rect->x;
- rect->y = floor (y_min);
- rect->height = floor (y_max) - rect->y;
-}
-
/**
* gdk_draw_layout_with_colors:
* @drawable: the drawable on which to draw string
if (matrix)
{
PangoMatrix tmp_matrix;
- GdkRectangle rect;
+ PangoRectangle rect;
- get_rotated_layout_bounds (layout, &rect);
+ pango_layout_get_extents (layout, NULL, &rect);
+ pango_matrix_transform_rectangle (matrix, &rect);
+ pango_extents_to_pixels (&rect, NULL);
tmp_matrix = *matrix;
tmp_matrix.x0 += x - rect.x;
tmp_matrix.y0 += y - rect.y;
pango_renderer_set_matrix (renderer, &tmp_matrix);
+ x = 0;
+ y = 0;
+ }
+ else if (GDK_PANGO_UNITS_OVERFLOWS (x, y))
+ {
+ PangoMatrix tmp_matrix = PANGO_MATRIX_INIT;
+ tmp_matrix.x0 = x;
+ tmp_matrix.y0 = y;
+ pango_renderer_set_matrix (renderer, &tmp_matrix);
+
x = 0;
y = 0;
}
layout_iter_get_line_clip_region (PangoLayoutIter *iter,
gint x_origin,
gint y_origin,
- gint *index_ranges,
+ const gint *index_ranges,
gint n_ranges)
{
PangoLayoutLine *line;
gint baseline;
gint i;
- line = pango_layout_iter_get_line (iter);
+ line = pango_layout_iter_get_line_readonly (iter);
clip_region = gdk_region_new ();
gdk_pango_layout_line_get_clip_region (PangoLayoutLine *line,
gint x_origin,
gint y_origin,
- gint *index_ranges,
+ const gint *index_ranges,
gint n_ranges)
{
GdkRegion *clip_region;
g_return_val_if_fail (index_ranges != NULL, NULL);
iter = pango_layout_get_iter (line->layout);
- while (pango_layout_iter_get_line (iter) != line)
+ while (pango_layout_iter_get_line_readonly (iter) != line)
pango_layout_iter_next_line (iter);
clip_region = layout_iter_get_line_clip_region(iter, x_origin, y_origin, index_ranges, n_ranges);
gdk_pango_layout_get_clip_region (PangoLayout *layout,
gint x_origin,
gint y_origin,
- gint *index_ranges,
+ const gint *index_ranges,
gint n_ranges)
{
PangoLayoutIter *iter;
baseline = pango_layout_iter_get_baseline (iter);
line_region = layout_iter_get_line_clip_region(iter,
- x_origin + logical_rect.x / PANGO_SCALE,
- y_origin + baseline / PANGO_SCALE,
+ x_origin + PANGO_PIXELS (logical_rect.x),
+ y_origin + PANGO_PIXELS (baseline),
index_ranges,
n_ranges);