summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--ChangeLog.pre-1-108
-rw-r--r--ChangeLog.pre-1-48
-rw-r--r--ChangeLog.pre-1-68
-rw-r--r--ChangeLog.pre-1-88
-rw-r--r--pango/fonts.c30
-rw-r--r--pango/pango-font.h7
-rw-r--r--pango/pangofc-fontmap.c84
-rw-r--r--pango/pangowin32-fontmap.c11
9 files changed, 171 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index ecf2f496..d852e435 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2003-02-22 Noah Levitt <nlevitt@columbia.edu>
+
+ * pango/pango-font.h:
+ * pango/pangofc-fontmap.c:
+ * pango/pangowin32-fontmap.c:
+ * pango/fonts.c (pango_font_face_list_sizes): New API for
+ getting available sizes for a bitmap font face.
+
Sat Feb 21 11:31:16 2004 Owen Taylor <otaylor@redhat.com>
* pango/pango-layout.c (pango_layout_set_justify): Add
diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10
index ecf2f496..d852e435 100644
--- a/ChangeLog.pre-1-10
+++ b/ChangeLog.pre-1-10
@@ -1,3 +1,11 @@
+2003-02-22 Noah Levitt <nlevitt@columbia.edu>
+
+ * pango/pango-font.h:
+ * pango/pangofc-fontmap.c:
+ * pango/pangowin32-fontmap.c:
+ * pango/fonts.c (pango_font_face_list_sizes): New API for
+ getting available sizes for a bitmap font face.
+
Sat Feb 21 11:31:16 2004 Owen Taylor <otaylor@redhat.com>
* pango/pango-layout.c (pango_layout_set_justify): Add
diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4
index ecf2f496..d852e435 100644
--- a/ChangeLog.pre-1-4
+++ b/ChangeLog.pre-1-4
@@ -1,3 +1,11 @@
+2003-02-22 Noah Levitt <nlevitt@columbia.edu>
+
+ * pango/pango-font.h:
+ * pango/pangofc-fontmap.c:
+ * pango/pangowin32-fontmap.c:
+ * pango/fonts.c (pango_font_face_list_sizes): New API for
+ getting available sizes for a bitmap font face.
+
Sat Feb 21 11:31:16 2004 Owen Taylor <otaylor@redhat.com>
* pango/pango-layout.c (pango_layout_set_justify): Add
diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6
index ecf2f496..d852e435 100644
--- a/ChangeLog.pre-1-6
+++ b/ChangeLog.pre-1-6
@@ -1,3 +1,11 @@
+2003-02-22 Noah Levitt <nlevitt@columbia.edu>
+
+ * pango/pango-font.h:
+ * pango/pangofc-fontmap.c:
+ * pango/pangowin32-fontmap.c:
+ * pango/fonts.c (pango_font_face_list_sizes): New API for
+ getting available sizes for a bitmap font face.
+
Sat Feb 21 11:31:16 2004 Owen Taylor <otaylor@redhat.com>
* pango/pango-layout.c (pango_layout_set_justify): Add
diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8
index ecf2f496..d852e435 100644
--- a/ChangeLog.pre-1-8
+++ b/ChangeLog.pre-1-8
@@ -1,3 +1,11 @@
+2003-02-22 Noah Levitt <nlevitt@columbia.edu>
+
+ * pango/pango-font.h:
+ * pango/pangofc-fontmap.c:
+ * pango/pangowin32-fontmap.c:
+ * pango/fonts.c (pango_font_face_list_sizes): New API for
+ getting available sizes for a bitmap font face.
+
Sat Feb 21 11:31:16 2004 Owen Taylor <otaylor@redhat.com>
* pango/pango-layout.c (pango_layout_set_justify): Add
diff --git a/pango/fonts.c b/pango/fonts.c
index 89e65573..ea5dc406 100644
--- a/pango/fonts.c
+++ b/pango/fonts.c
@@ -1432,3 +1432,33 @@ pango_font_face_get_face_name (PangoFontFace *face)
return PANGO_FONT_FACE_GET_CLASS (face)->get_face_name (face);
}
+
+/**
+ * pango_font_face_list_sizes:
+ * @face: a #PangoFontFace.
+ * @sizes: location to store a pointer to an array of int. This array
+ * should be freed with g_free().
+ * @n_sizes: location to store the number of elements in @sizes
+ *
+ * List the available sizes for a font. This is only applicable to bitmap
+ * fonts. For scalable fonts, stores %NULL at the location pointed to by
+ * @sizes and 0 at the location pointed to by @n_sizes. The sizes returned
+ * are in pango units and are sorted in ascending order.
+ *
+ * Since: 1.4
+ **/
+void
+pango_font_face_list_sizes (PangoFontFace *face,
+ int **sizes,
+ int *n_sizes)
+{
+ g_return_val_if_fail (PANGO_IS_FONT_FACE (face), NULL);
+
+ if (PANGO_FONT_FACE_GET_CLASS (face)->list_sizes != NULL)
+ PANGO_FONT_FACE_GET_CLASS (face)->list_sizes (face, sizes, n_sizes);
+ else
+ {
+ *sizes = NULL;
+ *n_sizes = 0;
+ }
+}
diff --git a/pango/pango-font.h b/pango/pango-font.h
index 4750300d..f9cabfb3 100644
--- a/pango/pango-font.h
+++ b/pango/pango-font.h
@@ -241,6 +241,9 @@ GType pango_font_face_get_type (void) G_GNUC_CONST;
PangoFontDescription *pango_font_face_describe (PangoFontFace *face);
G_CONST_RETURN char *pango_font_face_get_face_name (PangoFontFace *face);
+void pango_font_face_list_sizes (PangoFontFace *face,
+ int **sizes,
+ int *n_sizes);
#ifdef PANGO_ENABLE_BACKEND
@@ -263,11 +266,13 @@ struct _PangoFontFaceClass
const char * (*get_face_name) (PangoFontFace *face);
PangoFontDescription * (*describe) (PangoFontFace *face);
+ void (*list_sizes) (PangoFontFace *face,
+ int **sizes,
+ int *n_sizes);
/*< private >*/
/* Padding for future expansion */
- void (*_pango_reserved1) (void);
void (*_pango_reserved2) (void);
void (*_pango_reserved3) (void);
void (*_pango_reserved4) (void);
diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c
index 7567a4ca..e7dfdd1a 100644
--- a/pango/pangofc-fontmap.c
+++ b/pango/pangofc-fontmap.c
@@ -1138,11 +1138,95 @@ pango_fc_face_get_face_name (PangoFontFace *face)
return fcface->style;
}
+static int
+compare_ints (int a,
+ int b)
+{
+ if (a == b)
+ return 0;
+ else if (a > b)
+ return 1;
+ else
+ return -1;
+}
+
+static void
+pango_fc_face_list_sizes (PangoFontFace *face,
+ int **sizes,
+ int *n_sizes)
+{
+ PangoFcFace *fcface = PANGO_FC_FACE (face);
+ FcPattern *pattern;
+ FcFontSet *fontset;
+ FcObjectSet *objectset;
+
+ pattern = FcPatternCreate ();
+ FcPatternAddString (pattern, FC_FAMILY, fcface->family->family_name);
+ FcPatternAddString (pattern, FC_STYLE, fcface->style);
+
+ objectset = FcObjectSetCreate ();
+ FcObjectSetAdd (objectset, FC_PIXEL_SIZE);
+
+ fontset = FcFontList (NULL, pattern, objectset);
+
+ if (fontset)
+ {
+ GArray *size_array;
+ double size, dpi = -1.0;
+ int i;
+
+ size_array = g_array_new (FALSE, FALSE, sizeof (int));
+
+ for (i = 0; i < fontset->nfont; i++)
+ {
+ if (FcPatternGetDouble (fontset->fonts[i], FC_PIXEL_SIZE, 0, &size) == FcResultMatch)
+ {
+ if (dpi < 0)
+ {
+ FcPattern *tmp = FcPatternDuplicate (fontset->fonts[i]);
+ pango_fc_default_substitute (fcface->family->fontmap, tmp);
+ FcPatternGetDouble (tmp, FC_DPI, 0, &dpi);
+ FcPatternDestroy (tmp);
+ }
+
+ int sizi = (int) (PANGO_SCALE * size * 72.0 / dpi);
+ g_array_append_val (size_array, sizi);
+ }
+ }
+
+ g_array_sort (size_array, compare_ints);
+
+ if (size_array->len == 0)
+ {
+ *sizes = NULL;
+ *n_sizes = 0;
+ g_array_free (size_array, TRUE);
+ }
+ else
+ {
+ *n_sizes = size_array->len;
+ *sizes = (int *) size_array->data;
+ g_array_free (size_array, FALSE);
+ }
+
+ FcFontSetDestroy (fontset);
+ }
+ else
+ {
+ *sizes = NULL;
+ *n_sizes = 0;
+ }
+
+ FcPatternDestroy (pattern);
+ FcObjectSetDestroy (objectset);
+}
+
static void
pango_fc_face_class_init (PangoFontFaceClass *class)
{
class->describe = pango_fc_face_describe;
class->get_face_name = pango_fc_face_get_face_name;
+ class->list_sizes = pango_fc_face_list_sizes;
}
static GType
diff --git a/pango/pangowin32-fontmap.c b/pango/pangowin32-fontmap.c
index fd6b05d5..44e7b43e 100644
--- a/pango/pangowin32-fontmap.c
+++ b/pango/pangowin32-fontmap.c
@@ -933,6 +933,17 @@ pango_win32_face_class_init (PangoFontFaceClass *class)
{
class->describe = pango_win32_face_describe;
class->get_face_name = pango_win32_face_get_face_name;
+ class->list_sizes = pango_win32_face_list_sizes;
+}
+
+static void
+pango_win32_face_list_sizes (PangoFontFace *face,
+ int **sizes,
+ int *n_sizes)
+{
+ g_warning ("font_face_list_sizes not implemented for win32 backend");
+ *sizes = NULL;
+ *n_sizes = 0;
}
GType