summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hult <richard@imendio.com>2007-06-24 19:55:47 +0000
committerRichard Hult <rhult@src.gnome.org>2007-06-24 19:55:47 +0000
commite1c8f581032024799bf424d26d4a70852017cd56 (patch)
tree49e1509a173b73721d8668b5d7900dabd8117713
parentcd52bcd5dbb61f5cbada046ff917457e9f34b204 (diff)
downloadpango-e1c8f581032024799bf424d26d4a70852017cd56.tar.gz
Bug 449543 - Ship pangoatsui.h
2007-06-24 Richard Hult <richard@imendio.com> Bug 449543 - Ship pangoatsui.h * pango/pangoatsui-fontmap.c: * pango/pangoatsui-private.h: * pango/pangoatsui.c: * pango/pangoatsui.h: * pango/pangocairo-atsuifont.c: * pango/pangocairo-atsuifont.h: Move get_atsu_font_id from the cairo atsui font class to the atsui base class. Make the members of the atsui font private and adapt all users of them. * pango/Makefile.am: Ship pangoatsui.h. * modules/basic/basic-atsui.c: (basic_engine_shape): Adapt to the above changes. svn path=/trunk/; revision=2366
-rw-r--r--ChangeLog18
-rw-r--r--modules/basic/basic-atsui.c12
-rw-r--r--pango/Makefile.am1
-rw-r--r--pango/pangoatsui-fontmap.c13
-rw-r--r--pango/pangoatsui-private.h54
-rw-r--r--pango/pangoatsui.c117
-rw-r--r--pango/pangoatsui.h46
-rw-r--r--pango/pangocairo-atsuifont.c7
-rw-r--r--pango/pangocairo-atsuifont.h2
9 files changed, 206 insertions, 64 deletions
diff --git a/ChangeLog b/ChangeLog
index d0d64230..ede7d8f5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2007-06-24 Richard Hult <richard@imendio.com>
+
+ Bug 449543 - Ship pangoatsui.h
+
+ * pango/pangoatsui-fontmap.c:
+ * pango/pangoatsui-private.h:
+ * pango/pangoatsui.c:
+ * pango/pangoatsui.h:
+ * pango/pangocairo-atsuifont.c:
+ * pango/pangocairo-atsuifont.h: Move get_atsu_font_id from the
+ cairo atsui font class to the atsui base class. Make the members
+ of the atsui font private and adapt all users of them.
+
+ * pango/Makefile.am: Ship pangoatsui.h.
+
+ * modules/basic/basic-atsui.c: (basic_engine_shape): Adapt to the
+ above changes.
+
2007-06-21 Behdad Esfahbod <behdad@gnome.org>
* docs/pango.types: Add missing types.
diff --git a/modules/basic/basic-atsui.c b/modules/basic/basic-atsui.c
index 221da12c..fc343be6 100644
--- a/modules/basic/basic-atsui.c
+++ b/modules/basic/basic-atsui.c
@@ -27,7 +27,6 @@
#include "pango-utils.h"
#include "pango-fontmap.h"
#include "pangoatsui.h"
-#include "pangocairo-atsuifont.h"
/* No extra fields needed */
typedef PangoEngineShape BasicEngineATSUI;
@@ -112,14 +111,12 @@ basic_engine_shape (PangoEngineShape *engine,
ItemCount glyph_count;
int i;
const char *p;
- PangoCairoATSUIFont *cafont = PANGO_CAIRO_ATSUI_FONT (font);
+ PangoATSUIFont *afont = PANGO_ATSUI_FONT (font);
ATSUStyle style;
ATSUFontID fontID;
- ATSUAttributeTag styleTags[] =
- { kATSUFontTag };
+ ATSUAttributeTag styleTags[] = { kATSUFontTag };
ATSUAttributeValuePtr styleValues[] = { &fontID };
- ByteCount styleSizes[] =
- { sizeof(ATSUFontID) };
+ ByteCount styleSizes[] = { sizeof (ATSUFontID) };
utf16 = g_utf8_to_utf16 (text, length, NULL, &n16, NULL);
@@ -127,7 +124,7 @@ basic_engine_shape (PangoEngineShape *engine,
err = ATSUSetTextPointerLocation (text_layout, utf16, 0, n16, n16);
err = ATSUCreateStyle(&style);
- fontID = pango_cairo_atsui_font_get_atsu_font_id (cafont);
+ fontID = pango_atsui_font_get_atsu_font_id (afont);
err = ATSUSetAttributes(style,
sizeof(styleTags) / sizeof(styleTags[0]),
@@ -141,7 +138,6 @@ basic_engine_shape (PangoEngineShape *engine,
(void *)&layout_records,
&glyph_count);
-
p = text;
pango_glyph_string_set_size (glyphs, glyph_count - 1);
diff --git a/pango/Makefile.am b/pango/Makefile.am
index af0e6cf5..8f73ebd7 100644
--- a/pango/Makefile.am
+++ b/pango/Makefile.am
@@ -311,6 +311,7 @@ libpangocairo_1_0_la_SOURCES += \
pangocairo-atsuifont.c \
pangocairo-atsuifont.h \
pangocairo-atsuifontmap.c
+pangoinclude_HEADERS += pangoatsui.h
libpangocairo_1_0_la_CFLAGS = -xobjective-c
libpangocairo_1_0_la_LDFLAGS += -framework CoreFoundation -framework Carbon -framework Cocoa
diff --git a/pango/pangoatsui-fontmap.c b/pango/pangoatsui-fontmap.c
index 2fac21b9..e9cb54af 100644
--- a/pango/pangoatsui-fontmap.c
+++ b/pango/pangoatsui-fontmap.c
@@ -597,18 +597,17 @@ pango_atsui_font_map_add (PangoATSUIFontMap *atsuifontmap,
{
FontHashKey key;
FontHashKey *key_copy;
+ PangoATSUIFace *face;
- g_assert (atsuifont->fontmap == NULL);
-
- atsuifont->fontmap = g_object_ref (atsuifontmap);
+ _pango_atsui_font_set_font_map (atsuifont, atsuifontmap);
font_hash_key_for_context (atsuifontmap, context, &key);
- key.postscript_name = (char *)_pango_atsui_face_get_postscript_name (atsuifont->face);
- key.desc = atsuifont->desc;
+ face = _pango_atsui_font_get_face (atsuifont);
+ key.postscript_name = (char *)_pango_atsui_face_get_postscript_name (face);
+ key.desc = _pango_atsui_font_get_font_description (atsuifont);
key_copy = font_hash_key_copy (&key);
- atsuifont->context_key = key_copy->context_key;
- atsuifont->matrix = key.matrix;
+ _pango_atsui_font_set_context_key (atsuifont, key_copy->context_key);
g_hash_table_insert (atsuifontmap->font_hash, key_copy, g_object_ref (atsuifont));
}
diff --git a/pango/pangoatsui-private.h b/pango/pangoatsui-private.h
index d0a1ebff..f88f0060 100644
--- a/pango/pangoatsui-private.h
+++ b/pango/pangoatsui-private.h
@@ -25,6 +25,7 @@
#include <pango/pango-fontmap.h>
#include <pango/pango-context.h>
+#include "pangoatsui.h"
G_BEGIN_DECLS
@@ -35,22 +36,12 @@ G_BEGIN_DECLS
#define PANGO_IS_ATSUI_FONT_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_ATSUI_FONT_MAP))
#define PANGO_ATSUI_FONT_MAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_ATSUI_FONT_MAP, PangoATSUIFontMapClass))
-#define PANGO_TYPE_ATSUI_FONT (pango_atsui_font_get_type ())
-#define PANGO_ATSUI_FONT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_ATSUI_FONT, PangoATSUIFont))
-#define PANGO_ATSUI_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_ATSUI_FONT, PangoATSUIFontClass))
-#define PANGO_ATSUI_IS_FONT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_ATSUI_FONT))
-#define PANGO_ATSUI_IS_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_ATSUI_FONT))
-#define PANGO_ATSUI_FONT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_ATSUI_FONT, PangoATSUIFontClass))
-
-#define PANGO_RENDER_TYPE_ATSUI "PangoRenderATSUI"
typedef struct _PangoATSUIFamily PangoATSUIFamily;
typedef struct _PangoATSUIFace PangoATSUIFace;
typedef struct _PangoATSUIFontMap PangoATSUIFontMap;
typedef struct _PangoATSUIFontMapClass PangoATSUIFontMapClass;
-typedef struct _PangoATSUIFont PangoATSUIFont;
-typedef struct _PangoATSUIFontClass PangoATSUIFontClass;
struct _PangoATSUIFontMap
{
@@ -83,30 +74,27 @@ struct _PangoATSUIFontMapClass
const PangoFontDescription *desc);
};
-struct _PangoATSUIFont
-{
- PangoFont parent_instance;
-
- PangoATSUIFace *face;
- PangoFontDescription *desc;
- PangoMatrix matrix;
- gpointer context_key;
-
- PangoFontMap *fontmap;
-};
-
-struct _PangoATSUIFontClass
-{
- PangoFontClass parent_class;
-};
-
-GType pango_atsui_font_map_get_type (void) G_GNUC_CONST;
-GType pango_atsui_font_get_type (void) G_GNUC_CONST;
-const char * _pango_atsui_face_get_postscript_name (PangoATSUIFace *face);
-PangoCoverage *_pango_atsui_face_get_coverage (PangoATSUIFace *face,
- PangoLanguage *language);
-gboolean _pango_atsui_face_get_synthetic_italic (PangoATSUIFace *face);
+GType pango_atsui_font_map_get_type (void) G_GNUC_CONST;
+
+const char * _pango_atsui_face_get_postscript_name (PangoATSUIFace *face);
+PangoCoverage * _pango_atsui_face_get_coverage (PangoATSUIFace *face,
+ PangoLanguage *language);
+gboolean _pango_atsui_face_get_synthetic_italic (PangoATSUIFace *face);
+
+void _pango_atsui_font_set_font_description (PangoATSUIFont *afont,
+ const PangoFontDescription *desc);
+PangoFontDescription *_pango_atsui_font_get_font_description (PangoATSUIFont *afont);
+void _pango_atsui_font_set_font_map (PangoATSUIFont *afont,
+ PangoATSUIFontMap *fontmap);
+void _pango_atsui_font_set_face (PangoATSUIFont *afont,
+ PangoATSUIFace *aface);
+PangoATSUIFace * _pango_atsui_font_get_face (PangoATSUIFont *font);
+gpointer _pango_atsui_font_get_context_key (PangoATSUIFont *afont);
+void _pango_atsui_font_set_context_key (PangoATSUIFont *afont,
+ gpointer context_key);
+void _pango_atsui_font_set_atsu_font_id (PangoATSUIFont *font,
+ ATSUFontID font_id);
G_END_DECLS
diff --git a/pango/pangoatsui.c b/pango/pangoatsui.c
index dcb410df..ecea7868 100644
--- a/pango/pangoatsui.c
+++ b/pango/pangoatsui.c
@@ -21,18 +21,31 @@
#include <config.h>
+#include "pangoatsui.h"
#include "pangoatsui-private.h"
G_DEFINE_TYPE (PangoATSUIFont, pango_atsui_font, PANGO_TYPE_FONT);
+struct _PangoATSUIFontPrivate
+{
+ PangoATSUIFace *face;
+ PangoFontDescription *desc;
+ gpointer context_key;
+
+ ATSUFontID font_id;
+
+ PangoFontMap *fontmap;
+};
+
static void
pango_atsui_font_finalize (GObject *object)
{
- PangoATSUIFont *font = (PangoATSUIFont *)object;
+ PangoATSUIFont *afont = (PangoATSUIFont *)object;
+ PangoATSUIFontPrivate *priv = afont->priv;
- pango_font_description_free (font->desc);
+ pango_font_description_free (priv->desc);
- g_object_unref (font->fontmap);
+ g_object_unref (priv->fontmap);
G_OBJECT_CLASS (pango_atsui_font_parent_class)->finalize (object);
}
@@ -40,17 +53,21 @@ pango_atsui_font_finalize (GObject *object)
static PangoFontDescription *
pango_atsui_font_describe (PangoFont *font)
{
- PangoATSUIFont *atsuifont = PANGO_ATSUI_FONT (font);
+ PangoATSUIFont *afont = (PangoATSUIFont *)font;
+ PangoATSUIFontPrivate *priv = afont->priv;
- return pango_font_description_copy (atsuifont->desc);
+ return pango_font_description_copy (priv->desc);
}
static PangoCoverage *
pango_atsui_font_get_coverage (PangoFont *font,
PangoLanguage *language)
{
- return pango_coverage_ref (_pango_atsui_face_get_coverage (PANGO_ATSUI_FONT (font)->face,
- language));
+ PangoATSUIFont *afont = (PangoATSUIFont *)font;
+ PangoATSUIFontPrivate *priv = afont->priv;
+
+ return pango_coverage_ref (_pango_atsui_face_get_coverage (priv->face,
+ language));
}
static PangoEngineShape *
@@ -65,14 +82,17 @@ pango_atsui_font_find_shaper (PangoFont *font,
static PangoFontMap *
pango_atsui_font_get_font_map (PangoFont *font)
{
- PangoATSUIFont *atsuifont = (PangoATSUIFont *)font;
+ PangoATSUIFont *afont = (PangoATSUIFont *)font;
- return atsuifont->fontmap;
+ return afont->priv->fontmap;
}
static void
-pango_atsui_font_init (PangoATSUIFont *font)
+pango_atsui_font_init (PangoATSUIFont *afont)
{
+ afont->priv = G_TYPE_INSTANCE_GET_PRIVATE (afont,
+ PANGO_TYPE_ATSUI_FONT,
+ PangoATSUIFontPrivate);
}
static void
@@ -87,8 +107,85 @@ pango_atsui_font_class_init (PangoATSUIFontClass *class)
font_class->get_coverage = pango_atsui_font_get_coverage;
font_class->find_shaper = pango_atsui_font_find_shaper;
font_class->get_font_map = pango_atsui_font_get_font_map;
+
+ g_type_class_add_private (object_class, sizeof (PangoATSUIFontPrivate));
+}
+
+void
+_pango_atsui_font_set_font_description (PangoATSUIFont *font,
+ const PangoFontDescription *desc)
+{
+ PangoATSUIFontPrivate *priv = font->priv;
+
+ priv->desc = pango_font_description_copy (desc);
+}
+
+PangoFontDescription *
+_pango_atsui_font_get_font_description (PangoATSUIFont *font)
+{
+ PangoATSUIFontPrivate *priv = font->priv;
+
+ return priv->desc;
+}
+
+void
+_pango_atsui_font_set_font_map (PangoATSUIFont *font,
+ PangoATSUIFontMap *fontmap)
+{
+ PangoATSUIFontPrivate *priv = font->priv;
+
+ g_assert (priv->fontmap == NULL);
+
+ priv->fontmap = g_object_ref (fontmap);
+}
+
+void
+_pango_atsui_font_set_face (PangoATSUIFont *afont,
+ PangoATSUIFace *face)
+{
+ PangoATSUIFontPrivate *priv = afont->priv;
+
+ priv->face = face;
+}
+
+PangoATSUIFace *
+_pango_atsui_font_get_face (PangoATSUIFont *afont)
+{
+ PangoATSUIFontPrivate *priv = afont->priv;
+
+ return priv->face;
}
+gpointer
+_pango_atsui_font_get_context_key (PangoATSUIFont *afont)
+{
+ PangoATSUIFontPrivate *priv = afont->priv;
+ return priv->context_key;
+}
+void
+_pango_atsui_font_set_context_key (PangoATSUIFont *afont,
+ gpointer context_key)
+{
+ PangoATSUIFontPrivate *priv = afont->priv;
+ priv->context_key = context_key;
+}
+
+void
+_pango_atsui_font_set_atsu_font_id (PangoATSUIFont *font,
+ ATSUFontID font_id)
+{
+ PangoATSUIFontPrivate *priv = font->priv;
+
+ priv->font_id = font_id;
+}
+
+ATSUFontID
+pango_atsui_font_get_atsu_font_id (PangoATSUIFont *font)
+{
+ PangoATSUIFontPrivate *priv = font->priv;
+
+ return priv->font_id;
+}
diff --git a/pango/pangoatsui.h b/pango/pangoatsui.h
index 801d9e41..66ecea4b 100644
--- a/pango/pangoatsui.h
+++ b/pango/pangoatsui.h
@@ -23,11 +23,57 @@
#define __PANGOATSUI_H__
#include <pango/pango-context.h>
+#include <pango/pango-font.h>
+#include <ApplicationServices/ApplicationServices.h>
G_BEGIN_DECLS
+#define PANGO_TYPE_ATSUI_FONT (pango_atsui_font_get_type ())
+#define PANGO_ATSUI_FONT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_ATSUI_FONT, PangoATSUIFont))
+#define PANGO_ATSUI_IS_FONT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_ATSUI_FONT))
+
+typedef struct _PangoATSUIFont PangoATSUIFont;
+typedef struct _PangoATSUIFontClass PangoATSUIFontClass;
+
+#if defined(PANGO_ENABLE_ENGINE) || defined(PANGO_ENABLE_BACKEND)
+
#define PANGO_RENDER_TYPE_ATSUI "PangoRenderATSUI"
+#ifdef PANGO_ENABLE_BACKEND
+
+#define PANGO_ATSUI_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_ATSUI_FONT, PangoATSUIFontClass))
+#define PANGO_ATSUI_IS_FONT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_ATSUI_FONT))
+#define PANGO_ATSUI_FONT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_ATSUI_FONT, PangoATSUIFontClass))
+
+typedef struct _PangoATSUIFontPrivate PangoATSUIFontPrivate;
+
+struct _PangoATSUIFont
+{
+ PangoFont parent_instance;
+ PangoATSUIFontPrivate *priv;
+};
+
+struct _PangoATSUIFontClass
+{
+ PangoFontClass parent_class;
+
+ /*< private >*/
+
+ /* Padding for future expansion */
+ void (*_pango_reserved1) (void);
+ void (*_pango_reserved2) (void);
+ void (*_pango_reserved3) (void);
+ void (*_pango_reserved4) (void);
+};
+
+#endif /* PANGO_ENABLE_BACKEND */
+
+ATSUFontID pango_atsui_font_get_atsu_font_id (PangoATSUIFont *font);
+
+#endif /* PANGO_ENABLE_ENGINE || PANGO_ENABLE_BACKEND */
+
+GType pango_atsui_font_get_type (void) G_GNUC_CONST;
+
G_END_DECLS
#endif /* __PANGOATSUI_H__ */
diff --git a/pango/pangocairo-atsuifont.c b/pango/pangocairo-atsuifont.c
index e477a036..7c1042b3 100644
--- a/pango/pangocairo-atsuifont.c
+++ b/pango/pangocairo-atsuifont.c
@@ -179,10 +179,9 @@ static PangoFontDescription *
pango_cairo_atsui_font_describe_absolute (PangoFont *font)
{
PangoFontDescription *desc;
- PangoATSUIFont *afont = (PangoATSUIFont *) font;
PangoCairoATSUIFont *cafont = (PangoCairoATSUIFont *) font;
- desc = pango_font_description_copy (afont->desc);
+ desc = pango_font_describe (font);
pango_font_description_set_absolute_size (desc, cafont->absolute_size);
return desc;
@@ -275,8 +274,8 @@ _pango_cairo_atsui_font_new (PangoCairoATSUIFontMap *cafontmap,
cafont = g_object_new (PANGO_TYPE_CAIRO_ATSUI_FONT, NULL);
afont = PANGO_ATSUI_FONT (cafont);
- afont->desc = pango_font_description_copy (desc);
- afont->face = face;
+ _pango_atsui_font_set_font_description (afont, desc);
+ _pango_atsui_font_set_face (afont, face);
size = (double) pango_font_description_get_size (desc) / PANGO_SCALE;
cafont->font_id = font_id;
diff --git a/pango/pangocairo-atsuifont.h b/pango/pangocairo-atsuifont.h
index a0f36b3f..a55a9be3 100644
--- a/pango/pangocairo-atsuifont.h
+++ b/pango/pangocairo-atsuifont.h
@@ -33,6 +33,4 @@ typedef struct _PangoCairoATSUIFontClass PangoCairoATSUIFontClass;
GType pango_cairo_atsui_font_get_type (void) G_GNUC_CONST;
-ATSUFontID pango_cairo_atsui_font_get_atsu_font_id (PangoCairoATSUIFont *cafont);
-
#endif /* __PANGOCAIRO_ATSUIFONT_H__ */