summaryrefslogtreecommitdiff
path: root/pango
diff options
context:
space:
mode:
Diffstat (limited to 'pango')
-rw-r--r--pango/makefile.msc60
-rw-r--r--pango/pango.def37
-rw-r--r--pango/pangowin32-fontmap.c397
-rw-r--r--pango/pangowin32-private.h18
-rw-r--r--pango/pangowin32.c4
-rw-r--r--pango/pangowin32.h3
-rw-r--r--pango/testfonts.c43
7 files changed, 358 insertions, 204 deletions
diff --git a/pango/makefile.msc b/pango/makefile.msc
index 3af4796c..0a80691e 100644
--- a/pango/makefile.msc
+++ b/pango/makefile.msc
@@ -6,7 +6,7 @@ PERL = perl
!ENDIF
# Possibly override Pango version from build/win32/module.defs
-PANGO_VER = 0.17
+PANGO_VER = 0.19
# INCLUDES = -I .. -I .
# DEFINES =
@@ -14,7 +14,7 @@ PANGO_VER = 0.17
!IFNDEF PACKAGE
-DLLS = pango pangowin32 # pangoft2
+DLLS = pango pangowin32 pangoft2 # pangox
EXES = querymodules testfonts
#? test1 test2 test3 test4 test5
@@ -24,8 +24,12 @@ all : \
sub-all:
for %d in ($(DLLS)) do nmake -nologo -f makefile.msc sub-one-dll THIS=%d
+ for %d in ($(DLLS)) do nmake -nologo -f makefile.msc sub-one-lib THIS=%d
for %d in ($(EXES)) do nmake -nologo -f makefile.msc sub-one-exe THIS=%d
+sub-one-lib:
+ nmake -nologo -f makefile.msc $(THIS)-$(PANGO_VER)s.lib PACKAGE=$(THIS) OBJS_$(THIS)=1
+
sub-one-dll:
nmake -nologo -f makefile.msc $(THIS)-$(PANGO_VER).dll PACKAGE=$(THIS) OBJS_$(THIS)=1
@@ -38,30 +42,47 @@ PRJ_TOP = ..
PKG_VER = $(PANGO_VER)
PKG_DEF = $(PACKAGE).def
-PKG_CFLAGS = -I.. -I. -I$(PRJ_TOP) $(GLIB_CFLAGS) $(LIBICONV_CFLAGS) $(FREETYPE2_CFLAGS)
+PKG_CFLAGS = -I.. -I. -I$(PRJ_TOP) \
+ -DPANGO_ENABLE_BACKEND -DPANGO_ENABLE_ENGINE \
+ $(GLIB_CFLAGS) $(LIBICONV_CFLAGS) \
+ $(FREETYPE2_CFLAGS) \
+ $(X11_CFLAGS) -DSYSCONFDIR=\"/etc\"
!IFDEF OBJS_pango
# don't link with itself
PKG_LINK = $(GLIB_LIBS)
-!ELSE
-#not yet $(FREETYPE2_LIBS)
+!ENDIF
+
!IFDEF OBJS_pangowin32
PKG_LINK = $(GLIB_LIBS) $(LIBICONV_LIBS) \
pango-$(PANGO_VER).lib
-!ELSE
+!ENDIF
+
+!IFDEF OBJS_pangoft2
+PKG_LINK = $(GLIB_LIBS) $(LIBICONV_LIBS) $(FREETYPE2_LIBS) \
+ pango-$(PANGO_VER).lib
+!ENDIF
+
+!IFDEF OBJS_pangox
PKG_LINK = $(GLIB_LIBS) $(LIBICONV_LIBS) \
- pango-$(PANGO_VER).lib pangowin32-$(PANGO_VER).lib
+ pango-$(PANGO_VER).lib $(X11_LIBS)
!ENDIF
+
+!IF DEFINED (OBJS_querymodules) || DEFINED (OBJS_testfonts)
+PKG_LINK = $(GLIB_LIBS) $(LIBICONV_LIBS) \
+ pango-$(PANGO_VER).lib pangowin32-$(PANGO_VER).lib
!ENDIF
!IFDEF OBJS_pango
OBJECTS = \
+# backend.obj \
break.obj \
fonts.obj \
glyphstring.obj \
mapping.obj \
modules.obj \
pango-attributes.obj \
+ pango-color.obj \
pango-context.obj \
pango-coverage.obj \
pango-fontmap.obj \
@@ -81,6 +102,13 @@ OBJECTS = \
basic-win32.obj : ..\modules\basic\basic-win32.c
$(CC) $(PKG_CFLAGS) -GD -DMODULE_PREFIX -c ..\modules\basic\basic-win32.c
+basic-ft2.obj : ..\modules\basic\basic-ft2.c
+ $(CC) $(PKG_CFLAGS) -GD -DFT2_MODULE_PREFIX -c ..\modules\basic\basic-ft2.c
+
+basic-x.obj : ..\modules\basic\basic-x.c
+ $(CC) $(PKG_CFLAGS) -GD -DX_MODULE_PREFIX -c ..\modules\basic\basic-x.c
+
+
fribidi.obj : mini-fribidi\fribidi.c
$(CC) $(PKG_CFLAGS) -GD -c mini-fribidi\fribidi.c
fribidi_get_type.obj : mini-fribidi\fribidi_get_type.c
@@ -97,9 +125,21 @@ OBJECTS = \
!IFDEF OBJS_pangoft2
OBJECTS = \
+ module-defs-ft2.obj \
pangoft2.obj \
pangoft2-fontcache.obj \
- pangoft2-fontmap.obj
+ pangoft2-fontmap.obj \
+ basic-ft2.obj
+!ENDIF
+
+!IFDEF OBJS_pangox
+OBJECTS = \
+ module-defs-x.obj \
+ pangox.obj \
+ pangox-fontcache.obj \
+ pangox-fontmap.obj \
+ pango-indic.obj \
+ basic-x.obj
!ENDIF
!IFDEF OBJS_querymodules
@@ -151,8 +191,8 @@ pango-enum-types.c: $(pango_headers) pango-enum-types.h
--vtail " { 0, NULL, NULL }\n };\n etype = g_enum_register_static (\"@EnumName@\", values);\n }\n return etype;\n}\n" \
$(pango_headers) > pango-enum-types.c
-$(PACKAGE).lib : $(OBJECTS) $(PRJ_TOP)\config.h
- lib /out:$(PACKAGE).lib $(OBJECTS)
+$(PACKAGE)-$(PKG_VER)s.lib : $(OBJECTS) $(PRJ_TOP)\config.h
+ lib /out:$(PACKAGE)-$(PKG_VER)s.lib $(OBJECTS)
$(PACKAGE)-$(PKG_VER).dll : $(OBJECTS) $(PKG_DEF) $(PRJ_TOP)\config.h
$(CC) $(CFLAGS) -LD -Fe$(PACKAGE)-$(PKG_VER).dll $(OBJECTS) $(PKG_LINK) user32.lib gdi32.lib advapi32.lib $(LDFLAGS) /def:$(PKG_DEF)
diff --git a/pango/pango.def b/pango/pango.def
index 72004c91..a752e5c1 100644
--- a/pango/pango.def
+++ b/pango/pango.def
@@ -48,7 +48,6 @@ EXPORTS
pango_context_get_metrics
pango_context_get_type
pango_context_list_families
- pango_context_list_fonts
pango_context_load_font
pango_context_new
pango_context_set_base_dir
@@ -69,24 +68,55 @@ EXPORTS
pango_find_map
pango_find_paragraph_boundary
pango_font_describe
+ pango_font_description_better_match
pango_font_description_copy
+ pango_font_description_copy_static
pango_font_description_equal
pango_font_description_free
pango_font_description_from_string
+ pango_font_description_get_family
+ pango_font_description_get_set_fields
+ pango_font_description_get_size
+ pango_font_description_get_stretch
+ pango_font_description_get_style
pango_font_description_get_type
+ pango_font_description_get_variant
+ pango_font_description_get_weight
+ pango_font_description_hash
+ pango_font_description_merge
+ pango_font_description_new
+ pango_font_description_set_family
+ pango_font_description_set_family_static
+ pango_font_description_set_size
+ pango_font_description_set_stretch
+ pango_font_description_set_style
+ pango_font_description_set_variant
+ pango_font_description_set_weight
pango_font_description_to_filename
pango_font_description_to_string
+ pango_font_description_unset_fields
pango_font_descriptions_free
+ pango_font_face_describe
+ pango_font_face_get_face_name
+ pango_font_face_get_type
+ pango_font_family_get_name
+ pango_font_family_get_type
+ pango_font_family_list_faces
pango_font_find_shaper
pango_font_get_coverage
pango_font_get_glyph_extents
pango_font_get_metrics
pango_font_get_type
- pango_font_map_free_families
pango_font_map_get_type
pango_font_map_list_families
- pango_font_map_list_fonts
pango_font_map_load_font
+ pango_font_metrics_get_approximate_char_width
+ pango_font_metrics_get_approximate_digit_width
+ pango_font_metrics_get_ascent
+ pango_font_metrics_get_descent
+ pango_font_metrics_new
+ pango_font_metrics_ref
+ pango_font_metrics_unref
pango_get_lib_subdirectory
pango_get_log_attrs
pango_get_mirror_char
@@ -215,3 +245,4 @@ EXPORTS
pango_underline_get_type
pango_variant_get_type
pango_weight_get_type
+
diff --git a/pango/pangowin32-fontmap.c b/pango/pangowin32-fontmap.c
index 4df6c257..bcaa2275 100644
--- a/pango/pangowin32-fontmap.c
+++ b/pango/pangowin32-fontmap.c
@@ -35,14 +35,10 @@
#define PANGO_TYPE_WIN32_FONT_MAP (pango_win32_font_map_get_type ())
#define PANGO_WIN32_FONT_MAP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_TYPE_WIN32_FONT_MAP, PangoWin32FontMap))
-#define PANGO_WIN32_FONT_MAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_WIN32_FONT_MAP, PangoWin32FontMapClass))
#define PANGO_WIN32_IS_FONT_MAP(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_TYPE_WIN32_FONT_MAP))
-#define PANGO_WIN32_IS_FONT_MAP_CLASS(klass)(G_TYPE_CHECK_CLASS_TYPE ((klass), PANGO_TYPE_WIN32_FONT_MAP))
-#define PANGO_WIN32_FONT_MAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PANGO_TYPE_WIN32_FONT_MAP, PangoWin32FontMapClass))
-typedef struct _PangoWin32FamilyEntry PangoWin32FamilyEntry;
typedef struct _PangoWin32FontMap PangoWin32FontMap;
-typedef struct _PangoWin32FontMapClass PangoWin32FontMapClass;
+typedef struct _PangoWin32Family PangoWin32Family;
typedef struct _PangoWin32SizeInfo PangoWin32SizeInfo;
/* Number of freed fonts */
@@ -55,9 +51,12 @@ struct _PangoWin32FontMap
PangoWin32FontCache *font_cache;
GQueue *freed_fonts;
- /* Map Pango family names tp PangoWin32FamilyEntry structs */
+ /* Map Pango family names tp PangoWin32Family structs */
GHashTable *families;
+ /* Maps the family and style of a face to a PangoWin32Face struct */
+ GHashTable *faces;
+
/* Map LOGFONTS (taking into account only the lfFaceName, lfItalic
* and lfWeight fields) to PangoWin32SizeInfo structs.
*/
@@ -73,8 +72,10 @@ struct _PangoWin32FontMapClass
PangoFontMapClass parent_class;
};
-struct _PangoWin32FamilyEntry
+struct _PangoWin32Family
{
+ PangoFontFamily parent_instance;
+
char *family_name;
GSList *font_entries;
};
@@ -84,20 +85,26 @@ struct _PangoWin32SizeInfo
GSList *logfonts;
};
-static GType pango_win32_font_map_get_type (void);
-static void pango_win32_font_map_init (PangoWin32FontMap *fontmap);
-static void pango_win32_font_map_class_init (PangoWin32FontMapClass *class);
+#define PANGO_WIN32_TYPE_FAMILY (pango_win32_family_get_type ())
+#define PANGO_WIN32_FAMILY(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_WIN32_TYPE_FAMILY, PangoWin32Family))
+#define PANGO_WIN32_IS_FAMILY(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_WIN32_TYPE_FAMILY))
+
+#define PANGO_WIN32_TYPE_FACE (pango_win32_face_get_type ())
+#define PANGO_WIN32_FACE(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), PANGO_WIN32_TYPE_FACE, PangoWin32Face))
+#define PANGO_WIN32_IS_FACE(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), PANGO_WIN32_TYPE_FACE))
+
+GType pango_win32_family_get_type (void);
+GType pango_win32_face_get_type (void);
+
+static void pango_win32_font_map_init (PangoWin32FontMap *fontmap);
+static void pango_win32_font_map_class_init (PangoFontMapClass *class);
static void pango_win32_font_map_finalize (GObject *object);
static PangoFont *pango_win32_font_map_load_font (PangoFontMap *fontmap,
const PangoFontDescription *description);
-static void pango_win32_font_map_list_fonts (PangoFontMap *fontmap,
- const gchar *family,
- PangoFontDescription ***descs,
- int *n_descs);
static void pango_win32_font_map_list_families (PangoFontMap *fontmap,
- gchar ***families,
- int *n_families);
+ PangoFontFamily ***families,
+ int *n_families);
static void pango_win32_fontmap_cache_clear (PangoWin32FontMap *win32fontmap);
@@ -119,7 +126,7 @@ pango_win32_font_map_get_type (void)
{
static const GTypeInfo object_info =
{
- sizeof (PangoWin32FontMapClass),
+ sizeof (PangoFontMapClass),
(GBaseInitFunc) NULL,
(GBaseFinalizeFunc) NULL,
(GClassInitFunc) pango_win32_font_map_class_init,
@@ -170,21 +177,21 @@ pango_win32_font_map_init (PangoWin32FontMap *win32fontmap)
{
win32fontmap->families = g_hash_table_new (g_str_hash, g_str_equal);
win32fontmap->size_infos = g_hash_table_new (logfont_nosize_hash, logfont_nosize_equal);
+ win32fontmap->faces = g_hash_table_new ((GHashFunc)pango_font_description_hash,
+ (GEqualFunc)pango_font_description_equal);
win32fontmap->n_fonts = 0;
}
static void
-pango_win32_font_map_class_init (PangoWin32FontMapClass *class)
+pango_win32_font_map_class_init (PangoFontMapClass *class)
{
GObjectClass *object_class = G_OBJECT_CLASS (class);
- PangoFontMapClass *font_map_class = PANGO_FONT_MAP_CLASS (class);
parent_class = g_type_class_peek_parent (class);
object_class->finalize = pango_win32_font_map_finalize;
- font_map_class->load_font = pango_win32_font_map_load_font;
- font_map_class->list_fonts = pango_win32_font_map_list_fonts;
- font_map_class->list_families = pango_win32_font_map_list_families;
+ class->load_font = pango_win32_font_map_load_font;
+ class->list_families = pango_win32_font_map_list_families;
if (pango_win32_hdc == NULL)
pango_win32_hdc = CreateDC ("DISPLAY", NULL, NULL, NULL);
@@ -280,80 +287,73 @@ pango_win32_font_map_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-typedef struct
-{
- int n_found;
- PangoFontDescription **descs;
-} ListFontsInfo;
-
+/*
+ * PangoWin32Family
+ */
static void
-list_fonts_foreach (gpointer key,
- gpointer value,
- gpointer user_data)
+pango_win32_family_list_faces (PangoFontFamily *family,
+ PangoFontFace ***faces,
+ int *n_faces)
{
- PangoWin32FamilyEntry *entry = value;
- ListFontsInfo *info = user_data;
- GSList *tmp_list = entry->font_entries;
-
- while (tmp_list)
+ PangoWin32Family *win32family = PANGO_WIN32_FAMILY (family);
+
+ *n_faces = g_slist_length (win32family->font_entries);
+ if (faces)
{
- PangoWin32FontEntry *font_entry = tmp_list->data;
+ GSList *tmp_list;
+ int i = 0;
- info->descs[info->n_found++] = pango_font_description_copy (&font_entry->description);
- tmp_list = tmp_list->next;
+ *faces = g_new (PangoFontFace *, *n_faces);
+
+ tmp_list = win32family->font_entries;
+ while (tmp_list)
+ {
+ (*faces)[i++] = tmp_list->data;
+ tmp_list = tmp_list->next;
+ }
}
}
-static void
-pango_win32_font_map_list_fonts (PangoFontMap *fontmap,
- const gchar *family,
- PangoFontDescription ***descs,
- int *n_descs)
+const char *
+pango_win32_family_get_name (PangoFontFamily *family)
{
- PangoWin32FontMap *win32fontmap = (PangoWin32FontMap *)fontmap;
- ListFontsInfo info;
+ PangoWin32Family *win32family = PANGO_WIN32_FAMILY (family);
+ return win32family->family_name;
+}
- if (!n_descs)
- return;
+static void
+pango_win32_family_class_init (PangoFontFamilyClass *class)
+{
+ class->list_faces = pango_win32_family_list_faces;
+ class->get_name = pango_win32_family_get_name;
+}
- if (family)
- {
- PangoWin32FamilyEntry *entry = g_hash_table_lookup (win32fontmap->families, family);
- if (entry)
- {
- *n_descs = g_slist_length (entry->font_entries);
- if (descs)
- {
- *descs = g_new (PangoFontDescription *, *n_descs);
-
- info.descs = *descs;
- info.n_found = 0;
+GType
+pango_win32_family_get_type (void)
+{
+ static GType object_type = 0;
- list_fonts_foreach ((gpointer)family, (gpointer)entry, &info);
- }
- }
- else
- {
- *n_descs = 0;
- if (descs)
- *descs = NULL;
- }
- }
- else
+ if (!object_type)
{
- /* FIXME: (Alex) What the heck is this? I think it should just be removed */
- /* HB: I don't think so, the X version does the same ... */
- *n_descs = win32fontmap->n_fonts;
- if (descs)
- {
- *descs = g_new (PangoFontDescription *, win32fontmap->n_fonts);
-
- info.descs = *descs;
- info.n_found = 0;
-
- g_hash_table_foreach (win32fontmap->families, list_fonts_foreach, &info);
- }
+ static const GTypeInfo object_info =
+ {
+ sizeof (PangoFontFamilyClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) pango_win32_family_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (PangoWin32Family),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) NULL,
+ };
+
+ object_type = g_type_register_static (PANGO_TYPE_FONT_FAMILY,
+ "PangoWin32Family",
+ &object_info, 0);
}
+
+ return object_type;
}
static void
@@ -363,12 +363,12 @@ list_families_foreach (gpointer key,
{
GSList **list = user_data;
- *list = g_slist_prepend (*list, key);
+ *list = g_slist_prepend (*list, value);
}
static void
pango_win32_font_map_list_families (PangoFontMap *fontmap,
- gchar ***families,
+ PangoFontFamily ***families,
int *n_families)
{
GSList *family_list = NULL;
@@ -386,12 +386,12 @@ pango_win32_font_map_list_families (PangoFontMap *fontmap,
{
int i = 0;
- *families = g_new (gchar *, *n_families);
+ *families = g_new (PangoFontFamily *, *n_families);
tmp_list = family_list;
while (tmp_list)
{
- (*families)[i] = g_strdup (tmp_list->data);
+ (*families)[i] = tmp_list->data;
i++;
tmp_list = tmp_list->next;
}
@@ -400,21 +400,21 @@ pango_win32_font_map_list_families (PangoFontMap *fontmap,
g_slist_free (family_list);
}
-static PangoWin32FamilyEntry *
-pango_win32_get_family_entry (PangoWin32FontMap *win32fontmap,
- const char *family_name)
+static PangoWin32Family *
+pango_win32_get_font_family (PangoWin32FontMap *win32fontmap,
+ const char *family_name)
{
- PangoWin32FamilyEntry *family_entry = g_hash_table_lookup (win32fontmap->families, family_name);
- if (!family_entry)
+ PangoWin32Family *win32family = g_hash_table_lookup (win32fontmap->families, family_name);
+ if (!win32family)
{
- family_entry = g_new (PangoWin32FamilyEntry, 1);
- family_entry->family_name = g_strdup (family_name);
- family_entry->font_entries = NULL;
+ win32family = g_object_new (PANGO_WIN32_TYPE_FAMILY, NULL);
+ win32family->family_name = g_strdup (family_name);
+ win32family->font_entries = NULL;
- g_hash_table_insert (win32fontmap->families, family_entry->family_name, family_entry);
+ g_hash_table_insert (win32fontmap->families, win32family->family_name, win32family);
}
- return family_entry;
+ return win32family;
}
static PangoFont *
@@ -422,31 +422,29 @@ pango_win32_font_map_load_font (PangoFontMap *fontmap,
const PangoFontDescription *description)
{
PangoWin32FontMap *win32fontmap = (PangoWin32FontMap *)fontmap;
- PangoWin32FamilyEntry *family_entry;
+ PangoWin32Family *win32family;
PangoFont *result = NULL;
GSList *tmp_list;
gchar *name;
g_return_val_if_fail (description != NULL, NULL);
- g_return_val_if_fail (description->size > 0, NULL);
- name = g_strdup (description->family_name);
- g_strdown (name);
+ name = g_ascii_strdown (pango_font_description_get_family (description));
- family_entry = g_hash_table_lookup (win32fontmap->families, name);
- if (family_entry)
+ win32family = g_hash_table_lookup (win32fontmap->families, name);
+ if (win32family)
{
- PangoWin32FontEntry *best_match = NULL;
+ PangoWin32Face *best_match = NULL;
- tmp_list = family_entry->font_entries;
+ tmp_list = win32family->font_entries;
while (tmp_list)
{
- PangoWin32FontEntry *font_entry = tmp_list->data;
+ PangoWin32Face *face = tmp_list->data;
if (pango_font_description_better_match (description,
best_match ? best_match->description : NULL,
- font_entry->description))
- best_match = font_entry;
+ face->description))
+ best_match = face;
tmp_list = tmp_list->next;
}
@@ -454,11 +452,12 @@ pango_win32_font_map_load_font (PangoFontMap *fontmap,
if (best_match)
{
GSList *tmp_list = best_match->cached_fonts;
+ gint size = pango_font_description_get_size (description);
while (tmp_list)
{
PangoWin32Font *win32font = tmp_list->data;
- if (win32font->size == description->size)
+ if (win32font->size == size)
{
result = (PangoFont *)win32font;
@@ -475,7 +474,7 @@ pango_win32_font_map_load_font (PangoFontMap *fontmap,
{
PangoWin32Font *win32font;
- win32font = pango_win32_font_new (fontmap, &best_match->logfont, description->size);
+ win32font = pango_win32_font_new (fontmap, &best_match->logfont, size);
win32font->fontmap = fontmap;
win32font->entry = best_match;
best_match->cached_fonts = g_slist_prepend (best_match->cached_fonts, win32font);
@@ -494,7 +493,7 @@ static void
pango_win32_font_map_read_alias_file (PangoWin32FontMap *win32fontmap,
const char *filename)
{
- PangoWin32FontEntry *font_entry = NULL;
+ PangoWin32Face *face = NULL;
FILE *infile;
char **faces;
int lineno = 0;
@@ -509,7 +508,7 @@ pango_win32_font_map_read_alias_file (PangoWin32FontMap *win32fontmap,
while (pango_read_line (infile, line_buf))
{
- PangoWin32FamilyEntry *family_entry;
+ PangoWin32Family *family_entry;
PangoStyle style;
PangoVariant variant;
PangoWeight weight;
@@ -525,11 +524,12 @@ pango_win32_font_map_read_alias_file (PangoWin32FontMap *win32fontmap,
if (!pango_scan_string (&p, tmp_buf))
goto error;
- font_entry = g_new (PangoWin32FontEntry, 1);
- font_entry->description = pango_font_description_new ();
+ face = g_object_new g_object_new (PANGO_WIN32_TYPE_FACE, NULL);
+ face->n_fonts = 0;
+ face->description = pango_font_description_new ();
g_string_ascii_down (tmp_buf);
- pango_font_description_set_family (tmp_buf->str);
+ pango_font_description_set_family (face->description, tmp_buf->str);
if (!pango_scan_string (&p, tmp_buf))
goto error;
@@ -699,14 +699,18 @@ pango_win32_insert_font (PangoWin32FontMap *win32fontmap,
LOGFONT *lfp)
{
LOGFONT *lfp2;
- PangoFontDescription description;
+ PangoFontDescription *description;
+ char *family_name;
GSList *tmp_list;
- PangoWin32FamilyEntry *family_entry;
- PangoWin32FontEntry *font_entry;
+ PangoWin32Family *font_family;
+ PangoWin32Face *win32face;
PangoWin32SizeInfo *size_info;
+ PangoStyle style;
+ PangoVariant variant;
+ PangoWeight weight;
+ PangoStretch stretch;
PING(("lfp.face=%s,wt=%ld,ht=%ld",lfp->lfFaceName,lfp->lfWeight,lfp->lfHeight));
- description.size = 0;
/* First insert the LOGFONT into the list of LOGFONTs for the typeface name
*/
@@ -727,62 +731,71 @@ pango_win32_insert_font (PangoWin32FontMap *win32fontmap,
/* Convert the LOGFONT into a PangoFontDescription */
- description.family_name = g_strdup (lfp2->lfFaceName);
+ family_name = g_strdup (lfp2->lfFaceName);
if (!lfp2->lfItalic)
- description.style = PANGO_STYLE_NORMAL;
+ style = PANGO_STYLE_NORMAL;
else
- description.style = PANGO_STYLE_ITALIC;
+ style = PANGO_STYLE_ITALIC;
- description.variant = PANGO_VARIANT_NORMAL;
+ variant = PANGO_VARIANT_NORMAL;
/* The PangoWeight values PANGO_WEIGHT_* map exactly do Windows FW_* values.
* Is this on purpose? Quantize the weight to exact PANGO_WEIGHT_*
* values. Is this a good idea?
*/
if (lfp2->lfWeight == FW_DONTCARE)
- description.weight = PANGO_WEIGHT_NORMAL;
+ weight = PANGO_WEIGHT_NORMAL;
else if (lfp2->lfWeight <= (FW_ULTRALIGHT + FW_LIGHT) / 2)
- description.weight = PANGO_WEIGHT_ULTRALIGHT;
+ weight = PANGO_WEIGHT_ULTRALIGHT;
else if (lfp2->lfWeight <= (FW_LIGHT + FW_NORMAL) / 2)
- description.weight = PANGO_WEIGHT_LIGHT;
+ weight = PANGO_WEIGHT_LIGHT;
else if (lfp2->lfWeight <= (FW_NORMAL + FW_BOLD) / 2)
- description.weight = PANGO_WEIGHT_NORMAL;
+ weight = PANGO_WEIGHT_NORMAL;
else if (lfp2->lfWeight <= (FW_BOLD + FW_ULTRABOLD) / 2)
- description.weight = PANGO_WEIGHT_BOLD;
+ weight = PANGO_WEIGHT_BOLD;
else if (lfp2->lfWeight <= (FW_ULTRABOLD + FW_HEAVY) / 2)
- description.weight = PANGO_WEIGHT_ULTRABOLD;
+ weight = PANGO_WEIGHT_ULTRABOLD;
else
- description.weight = PANGO_WEIGHT_HEAVY;
+ weight = PANGO_WEIGHT_HEAVY;
/* XXX No idea how to figure out the stretch */
- description.stretch = PANGO_STRETCH_NORMAL;
+ stretch = PANGO_STRETCH_NORMAL;
- family_entry = pango_win32_get_family_entry (win32fontmap, description.family_name);
+ font_family = pango_win32_get_font_family (win32fontmap, family_name);
- tmp_list = family_entry->font_entries;
+ tmp_list = font_family->font_entries;
while (tmp_list)
{
- font_entry = tmp_list->data;
+ win32face = tmp_list->data;
- if (font_entry->description.style == description.style &&
- font_entry->description.variant == description.variant &&
- font_entry->description.weight == description.weight &&
- font_entry->description.stretch == description.stretch)
+ if (pango_font_description_get_style (win32face->description) == style &&
+ pango_font_description_get_weight (win32face->description) == weight &&
+ pango_font_description_get_stretch (win32face->description) == stretch &&
+ pango_font_description_get_variant (win32face->description) == variant)
return;
tmp_list = tmp_list->next;
}
- font_entry = g_new (PangoWin32FontEntry, 1);
- font_entry->description = description;
- font_entry->description.family_name = family_entry->family_name;
- font_entry->cached_fonts = NULL;
- font_entry->coverage = NULL;
- font_entry->logfont = *lfp;
- font_entry->unicode_table = NULL;
- g_strdown (font_entry->logfont.lfFaceName);
- family_entry->font_entries = g_slist_append (family_entry->font_entries, font_entry);
+ description = pango_font_description_new ();
+ pango_font_description_set_family_static (description, font_family->family_name);
+ pango_font_description_set_style (description, style);
+ pango_font_description_set_weight (description, weight);
+ pango_font_description_set_stretch (description, stretch);
+ pango_font_description_set_variant (description, variant);
+
+ /*
+ * Create the FontFace
+ */
+ win32face = g_object_new (PANGO_WIN32_TYPE_FACE, NULL);
+ win32face->description = description;
+ win32face->cached_fonts = NULL;
+ win32face->coverage = NULL;
+ win32face->logfont = *lfp;
+ win32face->unicode_table = NULL;
+ g_strdown (win32face->logfont.lfFaceName);
+ font_family->font_entries = g_slist_append (font_family->font_entries, win32face);
win32fontmap->n_fonts++;
/*
@@ -796,18 +809,18 @@ pango_win32_insert_font (PangoWin32FontMap *win32fontmap,
switch (lfp->lfPitchAndFamily & (0x0F << 4)) /* bit 4...7 */
{
case FF_MODERN : /* monospace */
- family_entry = pango_win32_get_family_entry (win32fontmap, "monospace");
- family_entry->font_entries = g_slist_append (family_entry->font_entries, font_entry);
+ font_family = pango_win32_get_font_family (win32fontmap, "monospace");
+ font_family->font_entries = g_slist_append (font_family->font_entries, win32face);
win32fontmap->n_fonts++;
break;
case FF_ROMAN : /* serif */
- family_entry = pango_win32_get_family_entry (win32fontmap, "serif");
- family_entry->font_entries = g_slist_append (family_entry->font_entries, font_entry);
+ font_family = pango_win32_get_font_family (win32fontmap, "serif");
+ font_family->font_entries = g_slist_append (font_family->font_entries, win32face);
win32fontmap->n_fonts++;
break;
case FF_SWISS : /* sans */
- family_entry = pango_win32_get_family_entry (win32fontmap, "sans");
- family_entry->font_entries = g_slist_append (family_entry->font_entries, font_entry);
+ font_family = pango_win32_get_font_family (win32fontmap, "sans");
+ font_family->font_entries = g_slist_append (font_family->font_entries, win32face);
win32fontmap->n_fonts++;
break;
}
@@ -883,29 +896,91 @@ free_coverages_foreach (gpointer key,
}
void
-pango_win32_font_entry_set_coverage (PangoWin32FontEntry *entry,
+pango_win32_font_entry_set_coverage (PangoWin32Face *face,
PangoCoverage *coverage)
{
- entry->coverage = pango_coverage_ref (coverage);
+ face->coverage = pango_coverage_ref (coverage);
+}
+
+static PangoFontDescription *
+pango_win32_face_describe (PangoFontFace *face)
+{
+ PangoWin32Face *win32face = PANGO_WIN32_FACE (face);
+
+ return pango_font_description_copy (win32face->description);
+}
+
+static const char *
+pango_win32_face_get_face_name (PangoFontFace *face)
+{
+ PangoWin32Face *win32face = PANGO_WIN32_FACE (face);
+
+ if (!win32face->face_name)
+ {
+ PangoFontDescription *desc = pango_font_face_describe (face);
+
+ pango_font_description_unset_fields (desc,
+ PANGO_FONT_MASK_FAMILY | PANGO_FONT_MASK_SIZE);
+
+ win32face->face_name = pango_font_description_to_string (desc);
+ pango_font_description_free (desc);
+ }
+
+ return win32face->face_name;
+}
+
+static void
+pango_win32_face_class_init (PangoFontFaceClass *class)
+{
+ class->describe = pango_win32_face_describe;
+ class->get_face_name = pango_win32_face_get_face_name;
+}
+
+GType
+pango_win32_face_get_type (void)
+{
+ static GType object_type = 0;
+
+ if (!object_type)
+ {
+ static const GTypeInfo object_info =
+ {
+ sizeof (PangoFontFaceClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) pango_win32_face_class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof (PangoWin32Face),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) NULL,
+ };
+
+ object_type = g_type_register_static (PANGO_TYPE_FONT_FACE,
+ "PangoWin32Face",
+ &object_info, 0);
+ }
+
+ return object_type;
}
PangoCoverage *
-pango_win32_font_entry_get_coverage (PangoWin32FontEntry *entry)
+pango_win32_font_entry_get_coverage (PangoWin32Face *face)
{
- if (entry->coverage)
+ if (face->coverage)
{
- pango_coverage_ref (entry->coverage);
- return entry->coverage;
+ pango_coverage_ref (face->coverage);
+ return face->coverage;
}
return NULL;
}
void
-pango_win32_font_entry_remove (PangoWin32FontEntry *entry,
+pango_win32_font_entry_remove (PangoWin32Face *face,
PangoFont *font)
{
- entry->cached_fonts = g_slist_remove (entry->cached_fonts, font);
+ face->cached_fonts = g_slist_remove (face->cached_fonts, font);
}
PangoWin32FontCache *
diff --git a/pango/pangowin32-private.h b/pango/pangowin32-private.h
index 2970fb49..8e3500f2 100644
--- a/pango/pangowin32-private.h
+++ b/pango/pangowin32-private.h
@@ -50,7 +50,7 @@
#endif
typedef struct _PangoWin32Font PangoWin32Font;
-typedef struct _PangoWin32FontEntry PangoWin32FontEntry;
+typedef struct _PangoWin32Face PangoWin32Face;
typedef struct _PangoWin32GlyphInfo PangoWin32GlyphInfo;
struct _PangoWin32Font
@@ -68,7 +68,7 @@ struct _PangoWin32Font
gint tm_descent;
gint tm_overhang;
- PangoWin32FontEntry *entry;
+ PangoWin32Face *entry;
/* If TRUE, font is in cache of recently unused fonts and not otherwise
* in use.
@@ -77,12 +77,16 @@ struct _PangoWin32Font
GHashTable *glyph_info;
};
-struct _PangoWin32FontEntry
+struct _PangoWin32Face
{
+ PangoFontFace parent_instance;
+
LOGFONT logfont;
- PangoFontDescription description;
+ PangoFontDescription *description;
PangoCoverage *coverage;
+ char *face_name;
+
gpointer unicode_table;
GSList *cached_fonts;
@@ -103,10 +107,10 @@ void pango_win32_make_matching_logfont (PangoFontMap *fontmap,
const LOGFONT *lfp,
int size,
LOGFONT *out);
-PangoCoverage * pango_win32_font_entry_get_coverage (PangoWin32FontEntry *entry);
-void pango_win32_font_entry_set_coverage (PangoWin32FontEntry *entry,
+PangoCoverage * pango_win32_font_entry_get_coverage (PangoWin32Face *face);
+void pango_win32_font_entry_set_coverage (PangoWin32Face *face,
PangoCoverage *coverage);
-void pango_win32_font_entry_remove (PangoWin32FontEntry *entry,
+void pango_win32_font_entry_remove (PangoWin32Face *face,
PangoFont *font);
void pango_win32_fontmap_cache_add (PangoFontMap *fontmap,
diff --git a/pango/pangowin32.c b/pango/pangowin32.c
index 169731d2..18f128f0 100644
--- a/pango/pangowin32.c
+++ b/pango/pangowin32.c
@@ -455,8 +455,8 @@ pango_win32_font_describe (PangoFont *font)
PangoFontDescription *desc;
PangoWin32Font *win32font = PANGO_WIN32_FONT (font);
- desc = pango_font_description_copy (&win32font->entry->description);
- desc->size = win32font->size;
+ desc = pango_font_description_copy (win32font->entry->description);
+ pango_font_description_set_size (desc, win32font->size);
return desc;
}
diff --git a/pango/pangowin32.h b/pango/pangowin32.h
index ead670b8..ffcc8f2a 100644
--- a/pango/pangowin32.h
+++ b/pango/pangowin32.h
@@ -25,7 +25,8 @@
#define __PANGOWIN32_H__
#include <glib.h>
-#include <pango/pango.h>
+#include <pango/pango-font.h>
+#include <pango/pango-layout.h>
G_BEGIN_DECLS
diff --git a/pango/testfonts.c b/pango/testfonts.c
index 6cb11ea3..42982fd6 100644
--- a/pango/testfonts.c
+++ b/pango/testfonts.c
@@ -72,13 +72,12 @@ calc_duration (GTimeVal *tv1, GTimeVal *tv0)
int main (int argc, char **argv)
{
PangoFontMap *fontmap = pango_win32_font_map_for_display();
- PangoFontDescription** descs;
PangoCoverage * coverage = NULL;
PangoFont* font = NULL;
+ PangoFontFamily** families;
int nb;
int i;
- gchar* family = NULL;
- gchar** families;
+ gchar* family_name = NULL;
gchar* lang = gtk_get_default_language ();
HDC hdc = NULL;
int line = 0;
@@ -119,7 +118,7 @@ int main (int argc, char **argv)
}
desc = pango_font_description_from_string(s->str);
- family = g_strdup(desc->family_name);
+ family_name = pango_font_description_get_family (desc);
font = pango_font_map_load_font (fontmap, desc);
@@ -132,22 +131,27 @@ int main (int argc, char **argv)
g_object_unref (G_OBJECT (font));
}
- pango_font_map_list_fonts (fontmap, family, &descs, &nb);
+ pango_font_map_list_families (fontmap, &families, &nb);
hdc = pre_render(my_font_size * 64, 3 * my_font_size * nb / 2);
for (i = 0; i < nb; i++)
{
+ PangoFontDescription *desc = pango_font_description_new ();
+ char *family_name = pango_font_family_get_name (families[i]);
+ PangoWeight weight = pango_font_description_get_weight (desc);
+ PangoStyle style = pango_font_description_get_style (desc);
+
g_print ("Family: %s; Style: %d; Weight: %d\n",
- descs[i]->family_name,
- descs[i]->style,
- descs[i]->weight);
+ family_name, style, weight);
+
+ pango_font_description_set_family (desc, family_name);
/* give it an arbitray size to load it */
- descs[i]->size = my_font_size * PANGO_SCALE;
+ pango_font_description_set_size (desc, my_font_size * PANGO_SCALE);
g_get_current_time (&tv0);
- font = pango_font_map_load_font (fontmap, descs[i]);
+ font = pango_font_map_load_font (fontmap, desc);
g_get_current_time (&tv1);
g_print ("\tpango_font_map_load_font took %.3f sec\n", calc_duration (&tv1, &tv0));
@@ -170,7 +174,7 @@ int main (int argc, char **argv)
context = pango_win32_get_context ();
pango_context_set_language (context, lang);
pango_context_set_base_dir (context, PANGO_DIRECTION_LTR);
- pango_context_set_font_description (context, descs[i]);
+ pango_context_set_font_description (context, desc);
glyphs = pango_glyph_string_new ();
item = pango_item_new ();
@@ -183,12 +187,12 @@ int main (int argc, char **argv)
{
/* the positioning isn't correct */
char * name = g_strdup_printf ("%s (%s%s)",
- descs[i]->family_name,
- descs[i]->weight == PANGO_WEIGHT_NORMAL ? "n" :
- (descs[i]->weight == PANGO_WEIGHT_HEAVY ? "h" :
- (descs[i]->weight > PANGO_WEIGHT_NORMAL ? "b" : "l")),
- descs[i]->style == PANGO_STYLE_OBLIQUE ? "o" :
- (descs[i]->style == PANGO_STYLE_ITALIC ? "i" : "n"));
+ family_name,
+ weight == PANGO_WEIGHT_NORMAL ? "n" :
+ (weight == PANGO_WEIGHT_HEAVY ? "h" :
+ (weight > PANGO_WEIGHT_NORMAL ? "b" : "l")),
+ style == PANGO_STYLE_OBLIQUE ? "o" :
+ (style == PANGO_STYLE_ITALIC ? "i" : "n"));
TextOut (hdc, 0, line, name, strlen(name));
g_get_current_time (&tv0);
@@ -206,20 +210,19 @@ int main (int argc, char **argv)
pango_coverage_unref (coverage);
g_object_unref (G_OBJECT (font));
}
+ pango_font_description_free (desc);
}
if (hdc)
post_render (hdc, "pango-fonts.bmp");
- pango_font_descriptions_free (descs, nb);
-
pango_font_map_list_families (fontmap, &families, &nb);
for (i = 0; i < nb; i++)
{
//g_print ("%s\n", families[i]);
}
- pango_font_map_free_families (families, nb);
+ //pango_font_map_free_families (families, nb);
return 0;
}