~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/text/gimptextlayout.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* The GIMP -- an image manipulation program
 
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * GimpText
26
26
 
27
27
#include "text-types.h"
28
28
 
 
29
#include "libgimpmath/gimpmath.h"
 
30
 
29
31
#include "core/gimpimage.h"
30
32
#include "core/gimpunit.h"
31
33
 
34
36
#include "gimptextlayout.h"
35
37
 
36
38
 
37
 
static void   gimp_text_layout_class_init  (GimpTextLayoutClass *klass);
38
 
static void   gimp_text_layout_init        (GimpTextLayout      *layout);
39
 
static void   gimp_text_layout_finalize    (GObject             *object);
40
 
 
41
 
static void   gimp_text_layout_position    (GimpTextLayout      *layout);
42
 
 
43
 
static PangoContext * gimp_text_get_pango_context (GimpText     *text,
44
 
                                                   gdouble       xres,
45
 
                                                   gdouble       yres);
46
 
 
47
 
static gint   gimp_text_layout_pixel_size         (Gimp         *gimp,
48
 
                                                   gdouble       value,
49
 
                                                   GimpUnit      unit,
50
 
                                                   gdouble       res);
51
 
static gint   gimp_text_layout_point_size         (Gimp         *gimp,
52
 
                                                   gdouble       value,
53
 
                                                   GimpUnit      unit,
54
 
                                                   gdouble       res);
55
 
 
56
 
 
57
 
static GObjectClass * parent_class = NULL;
58
 
 
59
 
 
60
 
GType
61
 
gimp_text_layout_get_type (void)
62
 
{
63
 
  static GType layout_type = 0;
64
 
 
65
 
  if (! layout_type)
66
 
    {
67
 
      static const GTypeInfo layout_info =
68
 
      {
69
 
        sizeof (GimpTextLayoutClass),
70
 
        (GBaseInitFunc) NULL,
71
 
        (GBaseFinalizeFunc) NULL,
72
 
        (GClassInitFunc) gimp_text_layout_class_init,
73
 
        NULL,           /* class_finalize */
74
 
        NULL,           /* class_data     */
75
 
        sizeof (GimpTextLayout),
76
 
        0,              /* n_preallocs    */
77
 
        (GInstanceInitFunc) gimp_text_layout_init,
78
 
      };
79
 
 
80
 
      layout_type = g_type_register_static (G_TYPE_OBJECT,
81
 
                                            "GimpTextLayout",
82
 
                                            &layout_info, 0);
83
 
    }
84
 
 
85
 
  return layout_type;
86
 
}
 
39
static void   gimp_text_layout_finalize           (GObject        *object);
 
40
 
 
41
static void   gimp_text_layout_position           (GimpTextLayout *layout);
 
42
 
 
43
static PangoContext * gimp_text_get_pango_context (GimpText       *text,
 
44
                                                   gdouble         xres,
 
45
                                                   gdouble         yres);
 
46
 
 
47
static gint   gimp_text_layout_pixel_size         (Gimp           *gimp,
 
48
                                                   gdouble         value,
 
49
                                                   GimpUnit        unit,
 
50
                                                   gdouble         res);
 
51
static gint   gimp_text_layout_point_size         (Gimp           *gimp,
 
52
                                                   gdouble         value,
 
53
                                                   GimpUnit        unit,
 
54
                                                   gdouble         res);
 
55
 
 
56
 
 
57
G_DEFINE_TYPE (GimpTextLayout, gimp_text_layout, G_TYPE_OBJECT)
 
58
 
 
59
#define parent_class gimp_text_layout_parent_class
 
60
 
87
61
 
88
62
static void
89
63
gimp_text_layout_class_init (GimpTextLayoutClass *klass)
90
64
{
91
 
  GObjectClass *object_class;
92
 
 
93
 
  object_class = G_OBJECT_CLASS (klass);
94
 
 
95
 
  parent_class = g_type_class_peek_parent (klass);
 
65
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
96
66
 
97
67
  object_class->finalize = gimp_text_layout_finalize;
98
68
}
107
77
static void
108
78
gimp_text_layout_finalize (GObject *object)
109
79
{
110
 
  GimpTextLayout *layout;
111
 
 
112
 
  layout = GIMP_TEXT_LAYOUT (object);
 
80
  GimpTextLayout *layout = GIMP_TEXT_LAYOUT (object);
113
81
 
114
82
  if (layout->text)
115
83
    {
213
181
                                                         text->line_spacing,
214
182
                                                         text->unit,
215
183
                                                         yres));
 
184
  if (fabs (text->letter_spacing) > 0.1)
 
185
    {
 
186
      PangoAttrList  *attrs = pango_attr_list_new ();
 
187
      PangoAttribute *attr;
 
188
 
 
189
      attr = pango_attr_letter_spacing_new (text->letter_spacing * PANGO_SCALE);
 
190
 
 
191
      attr->start_index = 0;
 
192
      attr->end_index   = -1;
 
193
 
 
194
      pango_attr_list_insert (attrs, attr);
 
195
 
 
196
      pango_layout_set_attributes (layout->layout, attrs);
 
197
      pango_attr_list_unref (attrs);
 
198
    }
 
199
 
216
200
  gimp_text_layout_position (layout);
217
201
 
218
202
  switch (text->box_mode)