2006-12-09 13:33:38 -08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2003-07-06 11:43:58 -07:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
|
*
|
|
|
|
|
* GimpText
|
|
|
|
|
* Copyright (C) 2002-2003 Sven Neumann <sven@gimp.org>
|
|
|
|
|
*
|
2009-01-17 14:28:01 -08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2003-07-06 11:43:58 -07:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 14:28:01 -08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2003-07-06 11:43:58 -07:00
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-07-11 14:47:19 -07:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2003-07-06 11:43:58 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
2008-10-26 10:39:55 -07:00
|
|
|
#include <pango/pangocairo.h>
|
2003-07-06 11:43:58 -07:00
|
|
|
|
|
|
|
|
#include "text-types.h"
|
|
|
|
|
|
|
|
|
|
#include "gimptextlayout.h"
|
|
|
|
|
#include "gimptextlayout-render.h"
|
|
|
|
|
|
|
|
|
|
|
2003-07-20 14:23:01 -07:00
|
|
|
void
|
2010-02-21 08:47:21 -08:00
|
|
|
gimp_text_layout_render (GimpTextLayout *layout,
|
|
|
|
|
cairo_t *cr,
|
|
|
|
|
GimpTextDirection base_dir,
|
|
|
|
|
gboolean path)
|
2003-07-06 11:43:58 -07:00
|
|
|
{
|
2008-11-03 15:44:19 -08:00
|
|
|
PangoLayout *pango_layout;
|
2008-11-03 15:25:05 -08:00
|
|
|
cairo_matrix_t trafo;
|
|
|
|
|
gint x, y;
|
2018-07-28 21:57:38 -07:00
|
|
|
gint width, height;
|
2003-07-06 11:43:58 -07:00
|
|
|
|
2003-07-20 14:23:01 -07:00
|
|
|
g_return_if_fail (GIMP_IS_TEXT_LAYOUT (layout));
|
2008-11-03 15:25:05 -08:00
|
|
|
g_return_if_fail (cr != NULL);
|
2003-07-06 11:43:58 -07:00
|
|
|
|
2014-04-11 07:52:42 -07:00
|
|
|
cairo_save (cr);
|
2003-07-06 11:43:58 -07:00
|
|
|
|
2014-04-11 07:52:42 -07:00
|
|
|
gimp_text_layout_get_offsets (layout, &x, &y);
|
2008-11-03 15:25:05 -08:00
|
|
|
cairo_translate (cr, x, y);
|
2008-10-26 10:39:55 -07:00
|
|
|
|
2009-06-19 08:08:34 -07:00
|
|
|
gimp_text_layout_get_transform (layout, &trafo);
|
2008-11-03 15:25:05 -08:00
|
|
|
cairo_transform (cr, &trafo);
|
2003-07-06 11:43:58 -07:00
|
|
|
|
2018-07-28 21:57:38 -07:00
|
|
|
if (base_dir == GIMP_TEXT_DIRECTION_TTB_RTL ||
|
|
|
|
|
base_dir == GIMP_TEXT_DIRECTION_TTB_RTL_UPRIGHT)
|
|
|
|
|
{
|
|
|
|
|
gimp_text_layout_get_size (layout, &width, &height);
|
|
|
|
|
cairo_translate (cr, width, 0);
|
|
|
|
|
cairo_rotate (cr, G_PI_2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (base_dir == GIMP_TEXT_DIRECTION_TTB_LTR ||
|
|
|
|
|
base_dir == GIMP_TEXT_DIRECTION_TTB_LTR_UPRIGHT)
|
|
|
|
|
{
|
|
|
|
|
gimp_text_layout_get_size (layout, &width, &height);
|
|
|
|
|
cairo_translate (cr, 0, height);
|
|
|
|
|
cairo_rotate (cr, -G_PI_2);
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-11 11:50:16 -08:00
|
|
|
pango_layout = gimp_text_layout_get_pango_layout (layout);
|
|
|
|
|
|
2008-11-03 15:25:05 -08:00
|
|
|
if (path)
|
2008-11-03 15:44:19 -08:00
|
|
|
pango_cairo_layout_path (cr, pango_layout);
|
2008-11-03 15:25:05 -08:00
|
|
|
else
|
2008-11-03 15:44:19 -08:00
|
|
|
pango_cairo_show_layout (cr, pango_layout);
|
2014-04-11 07:52:42 -07:00
|
|
|
|
|
|
|
|
cairo_restore (cr);
|
2003-07-06 11:43:58 -07:00
|
|
|
}
|