mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-20 19:43:01 +00:00
app/text/Makefile.am removed.
2008-11-04 Sven Neumann <sven@gimp.org> * app/text/Makefile.am * app/text/gimptext-bitmap.[ch]: removed. * app/text/gimptext-private.h * app/text/gimptext-vectors.c * app/text/gimptextlayer.c * app/text/gimptextlayout-render.[ch] * app/text/gimptextlayout.c: removed text render abstraction as this is now sufficiently provided by PangoCairo. svn path=/trunk/; revision=27542
This commit is contained in:
parent
3cd7f45a2b
commit
7dc80b79be
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2008-11-04 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/text/Makefile.am
|
||||
* app/text/gimptext-bitmap.[ch]: removed.
|
||||
|
||||
* app/text/gimptext-private.h
|
||||
* app/text/gimptext-vectors.c
|
||||
* app/text/gimptextlayer.c
|
||||
* app/text/gimptextlayout-render.[ch]
|
||||
* app/text/gimptextlayout.c: removed text render abstraction as
|
||||
this is now sufficiently provided by PangoCairo.
|
||||
|
||||
2008-11-03 Martin Nordholts <martinn@svn.gnome.org>
|
||||
|
||||
* app/gegl/gimpoperationpointlayermode.c
|
||||
|
|
|
@ -28,8 +28,6 @@ libapptext_a_sources = \
|
|||
gimpfontlist.h \
|
||||
gimptext.c \
|
||||
gimptext.h \
|
||||
gimptext-bitmap.c \
|
||||
gimptext-bitmap.h \
|
||||
gimptext-compat.c \
|
||||
gimptext-compat.h \
|
||||
gimptext-parasite.c \
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* GimpText
|
||||
* Copyright (C) 2003 Sven Neumann <sven@gimp.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (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
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include <pango/pangocairo.h>
|
||||
|
||||
#include "text-types.h"
|
||||
|
||||
#include "gimptext-bitmap.h"
|
||||
|
||||
|
||||
void
|
||||
gimp_text_render_bitmap (PangoFont *font,
|
||||
PangoGlyph glyph,
|
||||
cairo_font_options_t *options,
|
||||
cairo_matrix_t *trafo,
|
||||
gint x,
|
||||
gint y,
|
||||
cairo_t *cr)
|
||||
{
|
||||
|
||||
cairo_scaled_font_t *cfont;
|
||||
cairo_glyph_t cglyph;
|
||||
|
||||
cfont = pango_cairo_font_get_scaled_font ((PangoCairoFont *) font);
|
||||
|
||||
cglyph.x = PANGO_PIXELS (x);
|
||||
cglyph.y = PANGO_PIXELS (y);
|
||||
cglyph.index = glyph;
|
||||
|
||||
cairo_set_scaled_font (cr, cfont);
|
||||
cairo_set_font_options (cr, options);
|
||||
|
||||
cairo_transform (cr, trafo);
|
||||
|
||||
cairo_set_source_rgb (cr, 0.0, 0.0, 0.0);
|
||||
|
||||
cairo_show_glyphs (cr, &cglyph, 1);
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
/* GIMP - The GNU Image Manipulation Program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* GimpText
|
||||
* Copyright (C) 2003 Sven Neumann <sven@gimp.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (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
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_TEXT_BITMAP_H__
|
||||
#define __GIMP_TEXT_BITMAP_H__
|
||||
|
||||
|
||||
void gimp_text_render_bitmap (PangoFont *font,
|
||||
PangoGlyph glyph,
|
||||
cairo_font_options_t *options,
|
||||
cairo_matrix_t *trafo,
|
||||
gint x,
|
||||
gint y,
|
||||
cairo_t *cr);
|
||||
|
||||
|
||||
#endif /* __GIMP_TEXT_BITMAP_H__ */
|
|
@ -27,7 +27,6 @@
|
|||
* Cairo types from the rest of the gimp core.
|
||||
*/
|
||||
|
||||
|
||||
struct _GimpTextLayout
|
||||
{
|
||||
GObject object;
|
||||
|
@ -45,13 +44,4 @@ struct _GimpTextLayoutClass
|
|||
};
|
||||
|
||||
|
||||
typedef void (* GimpTextRenderFunc) (PangoFont *font,
|
||||
PangoGlyph glyph,
|
||||
cairo_font_options_t *options,
|
||||
cairo_matrix_t *tranform,
|
||||
gint x,
|
||||
gint y,
|
||||
gpointer render_data);
|
||||
|
||||
|
||||
#endif /* __GIMP_TEXT_LAYOUT_PRIVATE_H__ */
|
||||
|
|
|
@ -23,11 +23,8 @@
|
|||
|
||||
#include <gegl.h>
|
||||
|
||||
#define PANGO_ENABLE_ENGINE
|
||||
#include <cairo.h>
|
||||
#include <pango/pangocairo.h>
|
||||
|
||||
|
||||
#include "text-types.h"
|
||||
|
||||
#include "core/gimpimage.h"
|
||||
|
@ -37,45 +34,29 @@
|
|||
#include "vectors/gimpanchor.h"
|
||||
|
||||
#include "gimptext.h"
|
||||
#include "gimptext-private.h"
|
||||
#include "gimptext-vectors.h"
|
||||
#include "gimptextlayout.h"
|
||||
#include "gimptextlayout-render.h"
|
||||
|
||||
|
||||
/* for compatibility with older freetype versions */
|
||||
#ifndef FT_GLYPH_FORMAT_OUTLINE
|
||||
#define FT_GLYPH_FORMAT_OUTLINE ft_glyph_format_outline
|
||||
#endif
|
||||
|
||||
typedef struct _RenderContext RenderContext;
|
||||
|
||||
struct _RenderContext
|
||||
typedef struct
|
||||
{
|
||||
GimpVectors *vectors;
|
||||
GimpStroke *stroke;
|
||||
GimpAnchor *anchor;
|
||||
gdouble offset_x;
|
||||
gdouble offset_y;
|
||||
};
|
||||
GimpVectors *vectors;
|
||||
GimpStroke *stroke;
|
||||
GimpAnchor *anchor;
|
||||
} RenderContext;
|
||||
|
||||
|
||||
static void gimp_text_render_vectors (PangoFont *font,
|
||||
PangoGlyph glyph,
|
||||
cairo_font_options_t *options,
|
||||
cairo_matrix_t *cmatrix,
|
||||
gint x,
|
||||
gint y,
|
||||
RenderContext *context);
|
||||
static void gimp_text_render_vectors (cairo_t *cr,
|
||||
RenderContext *context);
|
||||
|
||||
|
||||
GimpVectors *
|
||||
gimp_text_vectors_new (GimpImage *image,
|
||||
GimpText *text)
|
||||
{
|
||||
GimpVectors *vectors;
|
||||
GimpTextLayout *layout;
|
||||
RenderContext context = { 0, };
|
||||
GimpVectors *vectors;
|
||||
RenderContext context = { NULL, };
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_TEXT (text), NULL);
|
||||
|
@ -84,18 +65,32 @@ gimp_text_vectors_new (GimpImage *image,
|
|||
|
||||
if (text->text)
|
||||
{
|
||||
gimp_object_set_name_safe (GIMP_OBJECT (vectors), text->text);
|
||||
GimpTextLayout *layout;
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
|
||||
layout = gimp_text_layout_new (text, image);
|
||||
gimp_object_set_name_safe (GIMP_OBJECT (vectors), text->text);
|
||||
|
||||
context.vectors = vectors;
|
||||
|
||||
gimp_text_layout_render (layout,
|
||||
(GimpTextRenderFunc) gimp_text_render_vectors,
|
||||
&context);
|
||||
/* A cairo_t needs an image surface to function, so "surface" is
|
||||
* created temporarily for this purpose. Nothing is drawn to
|
||||
* "surface", but it is still needed to be connected to "cr" for
|
||||
* "cr" to execute cr_glyph_path(). The size of surface is
|
||||
* therefore irrelevant.
|
||||
*/
|
||||
surface = cairo_image_surface_create (CAIRO_FORMAT_A8, 2, 2);
|
||||
cr = cairo_create (surface);
|
||||
|
||||
layout = gimp_text_layout_new (text, image);
|
||||
gimp_text_layout_render (layout, cr, TRUE);
|
||||
g_object_unref (layout);
|
||||
|
||||
gimp_text_render_vectors (cr, &context);
|
||||
|
||||
cairo_destroy (cr);
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
if (context.stroke)
|
||||
gimp_stroke_close (context.stroke);
|
||||
}
|
||||
|
@ -105,13 +100,12 @@ gimp_text_vectors_new (GimpImage *image,
|
|||
|
||||
|
||||
static inline void
|
||||
gimp_text_vector_coords (RenderContext *context,
|
||||
const double x,
|
||||
const double y,
|
||||
GimpCoords *coords)
|
||||
gimp_text_vector_coords (const double x,
|
||||
const double y,
|
||||
GimpCoords *coords)
|
||||
{
|
||||
coords->x = context->offset_x + (gdouble) x;
|
||||
coords->y = context->offset_y + (gdouble) y;
|
||||
coords->x = x;
|
||||
coords->y = y;
|
||||
coords->pressure = GIMP_COORDS_DEFAULT_PRESSURE;
|
||||
coords->xtilt = GIMP_COORDS_DEFAULT_TILT;
|
||||
coords->ytilt = GIMP_COORDS_DEFAULT_TILT;
|
||||
|
@ -129,7 +123,7 @@ moveto (RenderContext *context,
|
|||
g_printerr ("moveto %f, %f\n", x, y);
|
||||
#endif
|
||||
|
||||
gimp_text_vector_coords (context, x, y, &start);
|
||||
gimp_text_vector_coords (x, y, &start);
|
||||
|
||||
if (context->stroke)
|
||||
gimp_stroke_close (context->stroke);
|
||||
|
@ -156,7 +150,7 @@ lineto (RenderContext *context,
|
|||
if (! context->stroke)
|
||||
return 0;
|
||||
|
||||
gimp_text_vector_coords (context, x, y, &end);
|
||||
gimp_text_vector_coords (x, y, &end);
|
||||
|
||||
gimp_bezier_stroke_lineto (context->stroke, &end);
|
||||
|
||||
|
@ -183,9 +177,9 @@ cubicto (RenderContext *context,
|
|||
if (! context->stroke)
|
||||
return 0;
|
||||
|
||||
gimp_text_vector_coords (context, x1, y1, &control1);
|
||||
gimp_text_vector_coords (context, x2, y2, &control2);
|
||||
gimp_text_vector_coords (context, x3, y3, &end);
|
||||
gimp_text_vector_coords (x1, y1, &control1);
|
||||
gimp_text_vector_coords (x2, y2, &control2);
|
||||
gimp_text_vector_coords (x3, y3, &end);
|
||||
|
||||
gimp_bezier_stroke_cubicto (context->stroke, &control1, &control2, &end);
|
||||
|
||||
|
@ -199,7 +193,7 @@ closepath (RenderContext *context)
|
|||
g_printerr ("moveto\n");
|
||||
#endif
|
||||
|
||||
if (!context->stroke)
|
||||
if (! context->stroke)
|
||||
return 0;
|
||||
|
||||
gimp_stroke_close (context->stroke);
|
||||
|
@ -209,59 +203,24 @@ closepath (RenderContext *context)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gimp_text_render_vectors (PangoFont *font,
|
||||
PangoGlyph pango_glyph,
|
||||
cairo_font_options_t *options,
|
||||
cairo_matrix_t *matrix,
|
||||
gint x,
|
||||
gint y,
|
||||
RenderContext *context)
|
||||
gimp_text_render_vectors (cairo_t *cr,
|
||||
RenderContext *context)
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
cairo_path_t *cpath;
|
||||
cairo_scaled_font_t *cfont;
|
||||
cairo_glyph_t cglyph;
|
||||
gint i;
|
||||
cairo_path_t *path;
|
||||
gint i;
|
||||
|
||||
context->offset_x = (gdouble) x / PANGO_SCALE;
|
||||
context->offset_y = (gdouble) y / PANGO_SCALE;
|
||||
path = cairo_copy_path (cr);
|
||||
|
||||
cglyph.x = 0;
|
||||
cglyph.y = 0;
|
||||
cglyph.index = pango_glyph;
|
||||
|
||||
/* A cairo_t needs an image surface to function, so "surface" is created
|
||||
* temporarily for this purpose. Nothing is drawn to "surface", but it is
|
||||
* still needed to be connected to "cr" for "cr" to execute
|
||||
* cr_glyph_path(). The size of surface is therefore irrelevant.
|
||||
*/
|
||||
surface = cairo_image_surface_create (CAIRO_FORMAT_A8, 2, 2);
|
||||
cr = cairo_create (surface);
|
||||
|
||||
cfont = pango_cairo_font_get_scaled_font ((PangoCairoFont *) font);
|
||||
|
||||
cairo_set_scaled_font (cr, cfont);
|
||||
|
||||
cairo_set_font_options (cr, options);
|
||||
|
||||
cairo_transform (cr, matrix);
|
||||
|
||||
cairo_glyph_path (cr, &cglyph, 1);
|
||||
|
||||
cpath = cairo_copy_path (cr);
|
||||
|
||||
for (i = 0; i < cpath->num_data; i += cpath->data[i].header.length)
|
||||
for (i = 0; i < path->num_data; i += path->data[i].header.length)
|
||||
{
|
||||
cairo_path_data_t *data = &cpath->data[i];
|
||||
cairo_path_data_t *data = &path->data[i];
|
||||
|
||||
/* if the drawing operation is the final moveto of the glyph,
|
||||
* break to avoid creating an empty point. This is because cairo
|
||||
* always adds a moveto after each closepath.
|
||||
*/
|
||||
if (i + data->header.length >= cpath->num_data)
|
||||
if (i + data->header.length >= path->num_data)
|
||||
break;
|
||||
|
||||
switch (data->header.type)
|
||||
|
@ -287,8 +246,5 @@ gimp_text_render_vectors (PangoFont *font,
|
|||
}
|
||||
}
|
||||
|
||||
cairo_path_destroy (cpath);
|
||||
|
||||
cairo_destroy (cr);
|
||||
cairo_surface_destroy (surface);
|
||||
cairo_path_destroy (path);
|
||||
}
|
||||
|
|
|
@ -44,8 +44,6 @@
|
|||
#include "core/gimpparasitelist.h"
|
||||
|
||||
#include "gimptext.h"
|
||||
#include "gimptext-bitmap.h"
|
||||
#include "gimptext-private.h"
|
||||
#include "gimptextlayer.h"
|
||||
#include "gimptextlayer-transform.h"
|
||||
#include "gimptextlayout.h"
|
||||
|
@ -618,9 +616,7 @@ gimp_text_layer_render_layout (GimpTextLayer *layer,
|
|||
|
||||
cr = cairo_create (surface);
|
||||
|
||||
gimp_text_layout_render (layout,
|
||||
(GimpTextRenderFunc) gimp_text_render_bitmap,
|
||||
cr);
|
||||
gimp_text_layout_render (layout, cr, FALSE);
|
||||
|
||||
mask = tile_manager_new ( width, height, 1);
|
||||
pixel_region_init (&maskPR, mask, 0, 0, width, height, TRUE);
|
||||
|
|
|
@ -21,9 +21,7 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib-object.h>
|
||||
#include <pango/pangocairo.h>
|
||||
#include <pango/pango-font.h>
|
||||
|
||||
#include "text-types.h"
|
||||
|
||||
|
@ -36,187 +34,60 @@
|
|||
#include "gimptextlayout-render.h"
|
||||
|
||||
|
||||
static void gimp_text_layout_render_line (GimpTextLayout *layout,
|
||||
PangoLayoutLine *line,
|
||||
GimpTextRenderFunc render_func,
|
||||
gint x,
|
||||
gint y,
|
||||
gpointer render_data);
|
||||
static void gimp_text_layout_render_glyphs (GimpTextLayout *layout,
|
||||
PangoFont *font,
|
||||
PangoGlyphString *glyphs,
|
||||
GimpTextRenderFunc render_func,
|
||||
gint x,
|
||||
gint y,
|
||||
gpointer render_data);
|
||||
static cairo_font_options_t *
|
||||
gimp_text_layout_render_flags (GimpTextLayout *layout);
|
||||
static void gimp_text_layout_render_trafo (GimpTextLayout *layout,
|
||||
cairo_matrix_t *trafo);
|
||||
|
||||
static void gimp_text_layout_render_trafo (GimpTextLayout *layout,
|
||||
cairo_matrix_t *trafo);
|
||||
|
||||
|
||||
void
|
||||
gimp_text_layout_render (GimpTextLayout *layout,
|
||||
GimpTextRenderFunc render_func,
|
||||
gpointer render_data)
|
||||
gimp_text_layout_render (GimpTextLayout *layout,
|
||||
cairo_t *cr,
|
||||
gboolean path)
|
||||
{
|
||||
PangoLayoutIter *iter;
|
||||
PangoRectangle rect;
|
||||
gint x, y;
|
||||
cairo_matrix_t trafo;
|
||||
gint x, y;
|
||||
|
||||
g_return_if_fail (GIMP_IS_TEXT_LAYOUT (layout));
|
||||
g_return_if_fail (render_func != NULL);
|
||||
g_return_if_fail (cr != NULL);
|
||||
|
||||
gimp_text_layout_get_offsets (layout, &x, &y);
|
||||
|
||||
x *= PANGO_SCALE;
|
||||
y *= PANGO_SCALE;
|
||||
|
||||
pango_layout_get_extents (layout->layout, NULL, &rect);
|
||||
|
||||
/* If the width of the layout is > 0, then the text-box is FIXED
|
||||
* and the layout position should be offset if the alignment
|
||||
* is centered or right-aligned*/
|
||||
if (pango_layout_get_width (layout->layout) > 0)
|
||||
switch (pango_layout_get_alignment (layout->layout))
|
||||
{
|
||||
case PANGO_ALIGN_LEFT:
|
||||
break;
|
||||
|
||||
case PANGO_ALIGN_RIGHT:
|
||||
x += pango_layout_get_width (layout->layout) - rect.width;
|
||||
break;
|
||||
|
||||
case PANGO_ALIGN_CENTER:
|
||||
x += (pango_layout_get_width (layout->layout) - rect.width) / 2;
|
||||
break;
|
||||
}
|
||||
|
||||
iter = pango_layout_get_iter (layout->layout);
|
||||
|
||||
do
|
||||
{
|
||||
PangoLayoutLine *line;
|
||||
gint baseline;
|
||||
gint width;
|
||||
|
||||
line = pango_layout_iter_get_line_readonly (iter);
|
||||
pango_layout_get_pixel_size (layout->layout, &width, NULL);
|
||||
|
||||
pango_layout_iter_get_line_extents (iter, NULL, &rect);
|
||||
baseline = pango_layout_iter_get_baseline (iter);
|
||||
|
||||
gimp_text_layout_render_line (layout, line,
|
||||
render_func,
|
||||
x + rect.x,
|
||||
y + baseline,
|
||||
render_data);
|
||||
}
|
||||
while (pango_layout_iter_next_line (iter));
|
||||
|
||||
pango_layout_iter_free (iter);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_text_layout_render_line (GimpTextLayout *layout,
|
||||
PangoLayoutLine *line,
|
||||
GimpTextRenderFunc render_func,
|
||||
gint x,
|
||||
gint y,
|
||||
gpointer render_data)
|
||||
{
|
||||
PangoRectangle rect;
|
||||
GSList *list;
|
||||
gint x_off = 0;
|
||||
|
||||
for (list = line->runs; list; list = list->next)
|
||||
{
|
||||
PangoLayoutRun *run = list->data;
|
||||
|
||||
pango_glyph_string_extents (run->glyphs, run->item->analysis.font,
|
||||
NULL, &rect);
|
||||
gimp_text_layout_render_glyphs (layout,
|
||||
run->item->analysis.font, run->glyphs,
|
||||
render_func,
|
||||
x + x_off, y,
|
||||
render_data);
|
||||
|
||||
x_off += rect.width;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_text_layout_render_glyphs (GimpTextLayout *layout,
|
||||
PangoFont *font,
|
||||
PangoGlyphString *glyphs,
|
||||
GimpTextRenderFunc render_func,
|
||||
gint x,
|
||||
gint y,
|
||||
gpointer render_data)
|
||||
{
|
||||
PangoGlyphInfo *gi;
|
||||
cairo_font_options_t *flags;
|
||||
cairo_matrix_t trafo;
|
||||
double pos_x;
|
||||
double pos_y;
|
||||
gint i;
|
||||
gint x_position = 0;
|
||||
|
||||
flags = gimp_text_layout_render_flags (layout);
|
||||
gimp_text_layout_render_trafo (layout, &trafo);
|
||||
|
||||
for (i = 0, gi = glyphs->glyphs; i < glyphs->num_glyphs; i++, gi++)
|
||||
{
|
||||
if (gi->glyph != PANGO_GLYPH_EMPTY)
|
||||
switch (pango_layout_get_alignment (layout->layout))
|
||||
{
|
||||
case PANGO_ALIGN_LEFT:
|
||||
break;
|
||||
|
||||
pos_x = x + x_position + gi->geometry.x_offset;
|
||||
pos_y = y + gi->geometry.y_offset;
|
||||
case PANGO_ALIGN_RIGHT:
|
||||
x += PANGO_PIXELS (pango_layout_get_width (layout->layout)) - width;
|
||||
break;
|
||||
|
||||
cairo_matrix_transform_point (&trafo, &pos_x, &pos_y);
|
||||
|
||||
render_func (font, gi->glyph, flags, &trafo,
|
||||
pos_x, pos_y,
|
||||
render_data);
|
||||
case PANGO_ALIGN_CENTER:
|
||||
x += (PANGO_PIXELS (pango_layout_get_width (layout->layout))
|
||||
- width) / 2;
|
||||
break;
|
||||
}
|
||||
|
||||
x_position += glyphs->glyphs[i].geometry.width;
|
||||
}
|
||||
}
|
||||
|
||||
static cairo_font_options_t *
|
||||
gimp_text_layout_render_flags (GimpTextLayout *layout)
|
||||
{
|
||||
GimpText *text = layout->text;
|
||||
cairo_font_options_t *flags;
|
||||
|
||||
flags = cairo_font_options_create ();
|
||||
|
||||
cairo_font_options_set_antialias (flags, (text->antialias ?
|
||||
CAIRO_ANTIALIAS_DEFAULT :
|
||||
CAIRO_ANTIALIAS_NONE));
|
||||
|
||||
switch (text->hint_style)
|
||||
{
|
||||
case GIMP_TEXT_HINT_STYLE_NONE:
|
||||
cairo_font_options_set_hint_style (flags, CAIRO_HINT_STYLE_NONE);
|
||||
break;
|
||||
|
||||
case GIMP_TEXT_HINT_STYLE_SLIGHT:
|
||||
cairo_font_options_set_hint_style (flags, CAIRO_HINT_STYLE_SLIGHT);
|
||||
break;
|
||||
|
||||
case GIMP_TEXT_HINT_STYLE_MEDIUM:
|
||||
cairo_font_options_set_hint_style (flags, CAIRO_HINT_STYLE_MEDIUM);
|
||||
break;
|
||||
|
||||
case GIMP_TEXT_HINT_STYLE_FULL:
|
||||
cairo_font_options_set_hint_style (flags, CAIRO_HINT_STYLE_FULL);
|
||||
break;
|
||||
}
|
||||
|
||||
return flags;
|
||||
cairo_translate (cr, x, y);
|
||||
|
||||
gimp_text_layout_render_trafo (layout, &trafo);
|
||||
cairo_transform (cr, &trafo);
|
||||
|
||||
if (path)
|
||||
pango_cairo_layout_path (cr, layout->layout);
|
||||
else
|
||||
pango_cairo_show_layout (cr, layout->layout);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gimp_text_layout_render_trafo (GimpTextLayout *layout,
|
||||
cairo_matrix_t *trafo)
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
#define __GIMP_TEXT_LAYOUT_RENDER_H__
|
||||
|
||||
|
||||
void gimp_text_layout_render (GimpTextLayout *layout,
|
||||
GimpTextRenderFunc render_func,
|
||||
gpointer render_data);
|
||||
void gimp_text_layout_render (GimpTextLayout *layout,
|
||||
cairo_t *cr,
|
||||
gboolean path);
|
||||
|
||||
|
||||
#endif /* __GIMP_TEXT_LAYOUT_RENDER_H__ */
|
||||
|
|
|
@ -302,13 +302,45 @@ gimp_text_layout_position (GimpTextLayout *layout)
|
|||
#endif
|
||||
}
|
||||
|
||||
static cairo_font_options_t *
|
||||
gimp_text_get_font_options (GimpText *text)
|
||||
{
|
||||
cairo_font_options_t *options = cairo_font_options_create ();
|
||||
|
||||
cairo_font_options_set_antialias (options, (text->antialias ?
|
||||
CAIRO_ANTIALIAS_DEFAULT :
|
||||
CAIRO_ANTIALIAS_NONE));
|
||||
|
||||
switch (text->hint_style)
|
||||
{
|
||||
case GIMP_TEXT_HINT_STYLE_NONE:
|
||||
cairo_font_options_set_hint_style (options, CAIRO_HINT_STYLE_NONE);
|
||||
break;
|
||||
|
||||
case GIMP_TEXT_HINT_STYLE_SLIGHT:
|
||||
cairo_font_options_set_hint_style (options, CAIRO_HINT_STYLE_SLIGHT);
|
||||
break;
|
||||
|
||||
case GIMP_TEXT_HINT_STYLE_MEDIUM:
|
||||
cairo_font_options_set_hint_style (options, CAIRO_HINT_STYLE_MEDIUM);
|
||||
break;
|
||||
|
||||
case GIMP_TEXT_HINT_STYLE_FULL:
|
||||
cairo_font_options_set_hint_style (options, CAIRO_HINT_STYLE_FULL);
|
||||
break;
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
static PangoContext *
|
||||
gimp_text_get_pango_context (GimpText *text,
|
||||
gdouble xres,
|
||||
gdouble yres)
|
||||
{
|
||||
PangoContext *context;
|
||||
PangoCairoFontMap *fontmap;
|
||||
PangoContext *context;
|
||||
PangoCairoFontMap *fontmap;
|
||||
cairo_font_options_t *options;
|
||||
|
||||
fontmap = PANGO_CAIRO_FONT_MAP (pango_cairo_font_map_new ());
|
||||
|
||||
|
@ -317,6 +349,10 @@ gimp_text_get_pango_context (GimpText *text,
|
|||
context = pango_cairo_font_map_create_context (fontmap);
|
||||
g_object_unref (fontmap);
|
||||
|
||||
options = gimp_text_get_font_options (text);
|
||||
pango_cairo_context_set_font_options (context, options);
|
||||
cairo_font_options_destroy (options);
|
||||
|
||||
if (text->language)
|
||||
pango_context_set_language (context,
|
||||
pango_language_from_string (text->language));
|
||||
|
|
Loading…
Reference in a new issue