From 25ecf82123aa4dff2238bf420779ac6616976c1d Mon Sep 17 00:00:00 2001 From: Anuj Khare Date: Mon, 21 Jul 2014 00:03:11 +0530 Subject: [PATCH 2/4] glib: Add PopplerFontDescription boxed type This boxed type is used to represent the font attributes of annotations. --- glib/poppler-annot.cc | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++ glib/poppler-annot.h | 14 ++++++++++++ glib/poppler.h | 1 + 3 files changed, 77 insertions(+) diff --git a/glib/poppler-annot.cc b/glib/poppler-annot.cc index e87bce3..67602f4 100644 --- a/glib/poppler-annot.cc +++ b/glib/poppler-annot.cc @@ -1808,6 +1808,68 @@ poppler_annot_callout_line_free (PopplerAnnotCalloutLine *callout) g_free (callout); } +/* PopplerFontDescription */ +POPPLER_DEFINE_BOXED_TYPE (PopplerFontDescription, poppler_font_description, + poppler_font_description_copy, + poppler_font_description_free) + +/** + * poppler_font_description_new: + * + * Creates a new empty #PopplerFontDescription. + * + * Return value: a new allocated #PopplerFontDescription, %NULL in other case. + * It must be freed with poppler_font_description_free when done. + **/ +PopplerFontDescription * +poppler_font_description_new (void) +{ + return g_new0 (PopplerFontDescription, 1); +} + +/** + * poppler_font_description_copy: + * @font: the #PopplerFontDescription to be copied. + * + * It does copy @font to a new #PopplerFontDescription. + * + * Return value: a new allocated #PopplerFontDescription as exact copy of + * @font, %NULL in other case. It must be freed with + poppler_font_description_free when done. + **/ +PopplerFontDescription * +poppler_font_description_copy (PopplerFontDescription *font) +{ + PopplerFontDescription *new_font; + + g_return_val_if_fail (font != NULL, NULL); + + new_font = g_new0 (PopplerFontDescription, 1); + + *new_font = *font; + new_font->name = g_strdup (font->name); + return new_font; +} + +/** + * poppler_font_description_free: + * @font: a #PopplerFontDescription + * + * Frees the memory used by #PopplerFontDescription. + **/ +void +poppler_font_description_free (PopplerFontDescription *font) +{ + if (font->name) + g_free (font->name); + + if (font->color) + g_free (font->color); + + g_free (font); +} + + /* PopplerAnnotMovie */ /** diff --git a/glib/poppler-annot.h b/glib/poppler-annot.h index 441563e..1177f13 100644 --- a/glib/poppler-annot.h +++ b/glib/poppler-annot.h @@ -64,6 +64,7 @@ G_BEGIN_DECLS #define POPPLER_IS_ANNOT_LINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), POPPLER_TYPE_ANNOT_LINE)) #define POPPLER_TYPE_ANNOT_CALLOUT_LINE (poppler_annot_callout_line_get_type ()) +#define POPPLER_TYPE_FONT_DESCRIPTION (poppler_font_description_get_type ()) #define POPPLER_TYPE_ANNOT_CIRCLE (poppler_annot_circle_get_type ()) #define POPPLER_ANNOT_CIRCLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), POPPLER_TYPE_ANNOT_CIRCLE, PopplerAnnotCircle)) @@ -170,6 +171,13 @@ struct _PopplerAnnotCalloutLine gdouble y3; }; +struct _PopplerFontDescription +{ + PopplerColor *color; + gdouble size; + gchar *name; +}; + GType poppler_annot_get_type (void) G_GNUC_CONST; PopplerAnnotType poppler_annot_get_annot_type (PopplerAnnot *poppler_annot); gchar *poppler_annot_get_contents (PopplerAnnot *poppler_annot); @@ -275,6 +283,12 @@ PopplerAnnotCalloutLine *poppler_annot_callout_line_new ( PopplerAnnotCalloutLine *poppler_annot_callout_line_copy (PopplerAnnotCalloutLine *callout); void poppler_annot_callout_line_free (PopplerAnnotCalloutLine *callout); +/* PopplerFontDescription */ +GType poppler_font_description_get_type (void) G_GNUC_CONST; +PopplerFontDescription *poppler_font_description_new (void); +PopplerFontDescription *poppler_font_description_copy (PopplerFontDescription *font); +void poppler_font_description_free (PopplerFontDescription *font); + /* PopplerAnnotCircle */ GType poppler_annot_circle_get_type (void) G_GNUC_CONST; PopplerAnnot *poppler_annot_circle_new (PopplerDocument *doc, diff --git a/glib/poppler.h b/glib/poppler.h index 4df9c0e..93f2d92 100644 --- a/glib/poppler.h +++ b/glib/poppler.h @@ -208,6 +208,7 @@ typedef struct _PopplerAnnotCalloutLine PopplerAnnotCalloutLine; typedef struct _PopplerAnnotLine PopplerAnnotLine; typedef struct _PopplerAnnotCircle PopplerAnnotCircle; typedef struct _PopplerAnnotSquare PopplerAnnotSquare; +typedef struct _PopplerFontDescription PopplerFontDescription; typedef struct _PopplerQuadrilateral PopplerQuadrilateral; typedef struct _PopplerStructureElement PopplerStructureElement; typedef struct _PopplerStructureElementIter PopplerStructureElementIter; -- 1.9.1