diff options
author | Owen Taylor <otaylor@redhat.com> | 2000-02-25 20:06:45 +0000 |
---|---|---|
committer | Owen Taylor <otaylor@src.gnome.org> | 2000-02-25 20:06:45 +0000 |
commit | abacca30f29df84d9818cd1395449eff0e4ee171 (patch) | |
tree | 4541c04064b0b00416a76d7408d777f6b47b4963 | |
parent | 3c1ef3b659b2ffdb9613c8d2d330b64dc1fd0963 (diff) | |
download | pango-abacca30f29df84d9818cd1395449eff0e4ee171.tar.gz |
Add size to the font description structure instead of continually passing
Fri Feb 25 15:04:21 2000 Owen Taylor <otaylor@redhat.com>
* libpango/{fonts.c,pango-font.h,pango-context.[ch],pangox.c,
pango-attributes.c,examples/viewer.c: Add size to the
font description structure instead of continually passing
it around as an extra argument.
* libpango/pangox.c: Take screen resolution into account when
choosing fonts, instead of assumming point == pixel.
-rw-r--r-- | ChangeLog | 20 | ||||
-rw-r--r-- | ChangeLog.pre-1-0 | 20 | ||||
-rw-r--r-- | ChangeLog.pre-1-10 | 20 | ||||
-rw-r--r-- | ChangeLog.pre-1-2 | 20 | ||||
-rw-r--r-- | ChangeLog.pre-1-4 | 20 | ||||
-rw-r--r-- | ChangeLog.pre-1-6 | 20 | ||||
-rw-r--r-- | ChangeLog.pre-1-8 | 20 | ||||
-rw-r--r-- | Makefile.am | 7 | ||||
-rw-r--r-- | configure.in | 32 | ||||
-rw-r--r-- | examples/Makefile.am | 5 | ||||
-rw-r--r-- | examples/viewer.c | 8 | ||||
-rw-r--r-- | pango.spec.in | 4 | ||||
-rw-r--r-- | pango/Makefile.am | 2 | ||||
-rw-r--r-- | pango/fonts.c | 7 | ||||
-rw-r--r-- | pango/pango-attributes.c | 3 | ||||
-rw-r--r-- | pango/pango-context.c | 53 | ||||
-rw-r--r-- | pango/pango-context.h | 6 | ||||
-rw-r--r-- | pango/pango-font.h | 13 | ||||
-rw-r--r-- | pango/pangox.c | 51 |
19 files changed, 233 insertions, 98 deletions
@@ -1,3 +1,23 @@ +Fri Feb 25 15:04:21 2000 Owen Taylor <otaylor@redhat.com> + + * libpango/{fonts.c,pango-font.h,pango-context.[ch],pangox.c, + pango-attributes.c,examples/viewer.c: Add size to the + font description structure instead of continually passing + it around as an extra argument. + + * libpango/pangox.c: Take screen resolution into account when + choosing fonts, instead of assumming point == pixel. + +Fri Feb 25 12:32:01 2000 Owen Taylor <otaylor@redhat.com> + + * configure.in examples/Makefile.am: If GTK+ test fails, + just skip the example program. + + * pango-config.in pango.spec.in: Add a simple pango-config + script to the build. (pango-config --libs pangox really + should add the X libraries, but we'll omit that for the + moment.) + Sat Feb 19 18:51:35 2000 Owen Taylor <otaylor@redhat.com> * libpango/pangox.c (pango_x_make_matching_xlfd): Fix problem diff --git a/ChangeLog.pre-1-0 b/ChangeLog.pre-1-0 index e8192d7c..a0254f17 100644 --- a/ChangeLog.pre-1-0 +++ b/ChangeLog.pre-1-0 @@ -1,3 +1,23 @@ +Fri Feb 25 15:04:21 2000 Owen Taylor <otaylor@redhat.com> + + * libpango/{fonts.c,pango-font.h,pango-context.[ch],pangox.c, + pango-attributes.c,examples/viewer.c: Add size to the + font description structure instead of continually passing + it around as an extra argument. + + * libpango/pangox.c: Take screen resolution into account when + choosing fonts, instead of assumming point == pixel. + +Fri Feb 25 12:32:01 2000 Owen Taylor <otaylor@redhat.com> + + * configure.in examples/Makefile.am: If GTK+ test fails, + just skip the example program. + + * pango-config.in pango.spec.in: Add a simple pango-config + script to the build. (pango-config --libs pangox really + should add the X libraries, but we'll omit that for the + moment.) + Sat Feb 19 18:51:35 2000 Owen Taylor <otaylor@redhat.com> * libpango/pangox.c (pango_x_make_matching_xlfd): Fix problem diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10 index e8192d7c..a0254f17 100644 --- a/ChangeLog.pre-1-10 +++ b/ChangeLog.pre-1-10 @@ -1,3 +1,23 @@ +Fri Feb 25 15:04:21 2000 Owen Taylor <otaylor@redhat.com> + + * libpango/{fonts.c,pango-font.h,pango-context.[ch],pangox.c, + pango-attributes.c,examples/viewer.c: Add size to the + font description structure instead of continually passing + it around as an extra argument. + + * libpango/pangox.c: Take screen resolution into account when + choosing fonts, instead of assumming point == pixel. + +Fri Feb 25 12:32:01 2000 Owen Taylor <otaylor@redhat.com> + + * configure.in examples/Makefile.am: If GTK+ test fails, + just skip the example program. + + * pango-config.in pango.spec.in: Add a simple pango-config + script to the build. (pango-config --libs pangox really + should add the X libraries, but we'll omit that for the + moment.) + Sat Feb 19 18:51:35 2000 Owen Taylor <otaylor@redhat.com> * libpango/pangox.c (pango_x_make_matching_xlfd): Fix problem diff --git a/ChangeLog.pre-1-2 b/ChangeLog.pre-1-2 index e8192d7c..a0254f17 100644 --- a/ChangeLog.pre-1-2 +++ b/ChangeLog.pre-1-2 @@ -1,3 +1,23 @@ +Fri Feb 25 15:04:21 2000 Owen Taylor <otaylor@redhat.com> + + * libpango/{fonts.c,pango-font.h,pango-context.[ch],pangox.c, + pango-attributes.c,examples/viewer.c: Add size to the + font description structure instead of continually passing + it around as an extra argument. + + * libpango/pangox.c: Take screen resolution into account when + choosing fonts, instead of assumming point == pixel. + +Fri Feb 25 12:32:01 2000 Owen Taylor <otaylor@redhat.com> + + * configure.in examples/Makefile.am: If GTK+ test fails, + just skip the example program. + + * pango-config.in pango.spec.in: Add a simple pango-config + script to the build. (pango-config --libs pangox really + should add the X libraries, but we'll omit that for the + moment.) + Sat Feb 19 18:51:35 2000 Owen Taylor <otaylor@redhat.com> * libpango/pangox.c (pango_x_make_matching_xlfd): Fix problem diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4 index e8192d7c..a0254f17 100644 --- a/ChangeLog.pre-1-4 +++ b/ChangeLog.pre-1-4 @@ -1,3 +1,23 @@ +Fri Feb 25 15:04:21 2000 Owen Taylor <otaylor@redhat.com> + + * libpango/{fonts.c,pango-font.h,pango-context.[ch],pangox.c, + pango-attributes.c,examples/viewer.c: Add size to the + font description structure instead of continually passing + it around as an extra argument. + + * libpango/pangox.c: Take screen resolution into account when + choosing fonts, instead of assumming point == pixel. + +Fri Feb 25 12:32:01 2000 Owen Taylor <otaylor@redhat.com> + + * configure.in examples/Makefile.am: If GTK+ test fails, + just skip the example program. + + * pango-config.in pango.spec.in: Add a simple pango-config + script to the build. (pango-config --libs pangox really + should add the X libraries, but we'll omit that for the + moment.) + Sat Feb 19 18:51:35 2000 Owen Taylor <otaylor@redhat.com> * libpango/pangox.c (pango_x_make_matching_xlfd): Fix problem diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6 index e8192d7c..a0254f17 100644 --- a/ChangeLog.pre-1-6 +++ b/ChangeLog.pre-1-6 @@ -1,3 +1,23 @@ +Fri Feb 25 15:04:21 2000 Owen Taylor <otaylor@redhat.com> + + * libpango/{fonts.c,pango-font.h,pango-context.[ch],pangox.c, + pango-attributes.c,examples/viewer.c: Add size to the + font description structure instead of continually passing + it around as an extra argument. + + * libpango/pangox.c: Take screen resolution into account when + choosing fonts, instead of assumming point == pixel. + +Fri Feb 25 12:32:01 2000 Owen Taylor <otaylor@redhat.com> + + * configure.in examples/Makefile.am: If GTK+ test fails, + just skip the example program. + + * pango-config.in pango.spec.in: Add a simple pango-config + script to the build. (pango-config --libs pangox really + should add the X libraries, but we'll omit that for the + moment.) + Sat Feb 19 18:51:35 2000 Owen Taylor <otaylor@redhat.com> * libpango/pangox.c (pango_x_make_matching_xlfd): Fix problem diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8 index e8192d7c..a0254f17 100644 --- a/ChangeLog.pre-1-8 +++ b/ChangeLog.pre-1-8 @@ -1,3 +1,23 @@ +Fri Feb 25 15:04:21 2000 Owen Taylor <otaylor@redhat.com> + + * libpango/{fonts.c,pango-font.h,pango-context.[ch],pangox.c, + pango-attributes.c,examples/viewer.c: Add size to the + font description structure instead of continually passing + it around as an extra argument. + + * libpango/pangox.c: Take screen resolution into account when + choosing fonts, instead of assumming point == pixel. + +Fri Feb 25 12:32:01 2000 Owen Taylor <otaylor@redhat.com> + + * configure.in examples/Makefile.am: If GTK+ test fails, + just skip the example program. + + * pango-config.in pango.spec.in: Add a simple pango-config + script to the build. (pango-config --libs pangox really + should add the X libraries, but we'll omit that for the + moment.) + Sat Feb 19 18:51:35 2000 Owen Taylor <otaylor@redhat.com> * libpango/pangox.c (pango_x_make_matching_xlfd): Fix problem diff --git a/Makefile.am b/Makefile.am index c8386c7f..d277a3d8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,8 +2,11 @@ SUBDIRS=libpango modules examples docs tools fonts -EXTRA_DIST = \ - pango.spec.in +bin_SCRIPTS = pango-config + +EXTRA_DIST = \ + pango.spec.in \ + pango-config.in dist-hook: pango.spec cp pango.spec $(distdir) diff --git a/configure.in b/configure.in index 734ebb47..1ec15e12 100644 --- a/configure.in +++ b/configure.in @@ -17,20 +17,40 @@ if test "x$GCC" = "xyes"; then fi changequote([,])dnl +gtk_works=no AM_PATH_GTK(1.2.0, - [CFLAGS="$GTK_CFLAGS $CFLAGS"], - AC_MSG_ERROR(pango requires GTK+ 1.2 or better)) + [CFLAGS="$GTK_CFLAGS $CFLAGS"; gtk_works=yes], + AC_MSG_WARN("Disabling GTK+-based tests")) + +AM_CONDITIONAL(BUILD_TESTS, test x$gtk_works = xyes) AC_CHECK_LIB(fribidi, fribidi_map_range, :, AC_MSG_ERROR([*** libfribidi not found.])) + +# We run glib-config separately to get the gmodule cflags so we +# can add them to pango-config + +AC_PATH_PROG(GLIB_CONFIG, glib-config, no) +if test x$GLIB_CONFIG = xno ; then + AC_MSG_ERROR([*** glib-config not found]) +fi +GLIB_CFLAGS="`glib-config --cflags gmodule`" +CFLAGS="$CFLAGS $GLIB_CFLAGS" +GLIB_LIBS="`glib-config --libs gmodule`" +AC_SUBST(GLIB_LIBS) +AC_SUBST(GLIB_CFLAGS) + + AC_PATH_PROG(UNICODE_CONFIG, unicode-config, no) if test x$UNICODE_CONFIG = xno ; then AC_MSG_ERROR([*** unicode-config not found]) fi -CFLAGS="$CFLAGS `unicode-config --cflags`" +UNICODE_CFLAGS="`unicode-config --cflags`" +CFLAGS="$CFLAGS $UNICODE_CFLAGS" UNICODE_LIBS="`unicode-config --libs`" AC_SUBST(UNICODE_LIBS) +AC_SUBST(UNICODE_CFLAGS) AC_CHECK_FUNCS(flockfile) @@ -52,4 +72,8 @@ docs/Makefile tools/Makefile fonts/Makefile pango.spec -]) +pango-config +],[case "$CONFIG_FILES" in +*pango-config*)chmod +x pango-config;; +esac]) + diff --git a/examples/Makefile.am b/examples/Makefile.am index 467ce4dc..b794125f 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -1,13 +1,16 @@ ## Process this file with automake to create Makefile.in. -bin_PROGRAMS = pango-viewer aliasdir = $(sysconfdir)/pango INCLUDES = -I$(top_srcdir)/libpango/ +if BUILD_TESTS +bin_PROGRAMS = pango-viewer + pango_viewer_SOURCES = \ viewer.c pango_viewer_LDADD = ../libpango/libpango.la ../libpango/libpangox.la $(GTK_LIBS) -lfribidi $(UNICODE_LIBS) +endif all-local: pango.modules diff --git a/examples/viewer.c b/examples/viewer.c index 4670454b..5d0877b2 100644 --- a/examples/viewer.c +++ b/examples/viewer.c @@ -61,7 +61,6 @@ struct _Line { }; static PangoFontDescription font_description; -static double font_size = 16000; static Paragraph *highlight_para; static int highlight_offset; @@ -835,7 +834,6 @@ static void reload_font () { pango_context_set_font_description (context, &font_description); - pango_context_set_size (context, font_size); if (layout) gtk_widget_queue_resize (layout); @@ -862,7 +860,7 @@ set_style (GtkWidget *entry, gpointer data) void font_size_changed (GtkAdjustment *adj) { - font_size = (int)(adj->value * 1000 + 0.5); + font_description.size = (int)(adj->value * 1000 + 0.5); reload_font(); } @@ -1146,7 +1144,7 @@ make_font_selector (void) gtk_box_pack_start (GTK_BOX (hbox), util_hbox, FALSE, FALSE, 0); adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (spin_button)); - adj->value = font_size / 1000.; + adj->value = font_description.size / 1000.; adj->lower = 0; adj->upper = 1024; adj->step_increment = 1; @@ -1196,9 +1194,9 @@ main (int argc, char **argv) font_description.variant = PANGO_VARIANT_NORMAL; font_description.weight = 500; font_description.stretch = PANGO_STRETCH_NORMAL; + font_description.size = 16000; pango_context_set_font_description (context, &font_description); - pango_context_set_size (context, font_size); /* Create the user interface */ diff --git a/pango.spec.in b/pango.spec.in index d2172689..087c3371 100644 --- a/pango.spec.in +++ b/pango.spec.in @@ -59,13 +59,15 @@ fi %doc README AUTHORS COPYING ChangeLog TODO %doc examples/HELLO.utf8 %{prefix}/lib/libpango*-*.so -%{prefix}/bin/* +%{prefix}/bin/pango-querymodules +%{prefix}/bin/pango-viewer %{prefix}/lib/pango/modules/* %config /etc/pango/pangox_aliases %files devel %defattr(-, root, root) %{prefix}/lib/libpango*.so +%{prefix}/bin/pango-config %{prefix}/lib/libpango*.a %{prefix}/include/* diff --git a/pango/Makefile.am b/pango/Makefile.am index b89cfd9e..3a7803f0 100644 --- a/pango/Makefile.am +++ b/pango/Makefile.am @@ -44,5 +44,5 @@ include_HEADERS = \ pango_querymodules_SOURCES = \ querymodules.c -pango_querymodules_LDADD = libpango.la $(GTK_LIBS) -lfribidi $(UNICODE_LIBS) +pango_querymodules_LDADD = libpango.la $(GLIB_LIBS) -lfribidi $(UNICODE_LIBS) diff --git a/pango/fonts.c b/pango/fonts.c index a66fde54..45f1dcac 100644 --- a/pango/fonts.c +++ b/pango/fonts.c @@ -65,6 +65,7 @@ pango_font_description_compare (const PangoFontDescription *desc1, desc1->variant == desc2->variant && desc1->weight == desc2->weight && desc1->stretch == desc2->stretch && + desc1->size == desc2->size && g_strcasecmp (desc1->family_name, desc2->family_name)); } @@ -297,7 +298,6 @@ pango_font_map_unref (PangoFontMap *fontmap) * pango_font_map_load_font: * @fontmap: a #PangoFontMap * @desc: a #PangoFontDescription describing the font to load - * @size: the size at which to load the font (in points) * * Load the font in the fontmap that is the closest match for @desc. * @@ -305,12 +305,11 @@ pango_font_map_unref (PangoFontMap *fontmap) **/ PangoFont * pango_font_map_load_font (PangoFontMap *fontmap, - const PangoFontDescription *desc, - double size) + const PangoFontDescription *desc) { g_return_val_if_fail (fontmap != NULL, NULL); - return fontmap->klass->load_font (fontmap, desc, size); + return fontmap->klass->load_font (fontmap, desc); } /** diff --git a/pango/pango-attributes.c b/pango/pango-attributes.c index cdbbbbbb..e75a56f7 100644 --- a/pango/pango-attributes.c +++ b/pango/pango-attributes.c @@ -908,6 +908,9 @@ pango_attr_iterator_get_font (PangoAttrIterator *iterator, if ((attr = pango_attr_iterator_get (iterator, PANGO_ATTR_STRETCH))) current->stretch = ((PangoAttrInt *)attr)->value; + + if ((attr = pango_attr_iterator_get (iterator, PANGO_ATTR_SIZE))) + current->size = ((PangoAttrInt *)attr)->value; } diff --git a/pango/pango-context.c b/pango/pango-context.c index 7341f3a8..30902c47 100644 --- a/pango/pango-context.c +++ b/pango/pango-context.c @@ -33,7 +33,6 @@ struct _PangoContext char *lang; PangoDirection base_dir; PangoFontDescription *font_desc; - int size; GSList *font_maps; }; @@ -322,7 +321,6 @@ pango_context_list_families (PangoContext *context, * pango_context_load_font: * @context: a #PangoContext * @desc: a #PangoFontDescription describing the font to load - * @size: the size at which to load the font (in points) * * Loads the font in one of the fontmaps in the context * that is the closest match for @desc. @@ -331,8 +329,7 @@ pango_context_list_families (PangoContext *context, **/ PangoFont * pango_context_load_font (PangoContext *context, - const PangoFontDescription *desc, - gdouble size) + const PangoFontDescription *desc) { GSList *tmp_list; @@ -343,7 +340,7 @@ pango_context_load_font (PangoContext *context, { PangoFont *font; - font = pango_font_map_load_font (tmp_list->data, desc, size); + font = pango_font_map_load_font (tmp_list->data, desc); if (font) return font; @@ -424,38 +421,6 @@ pango_context_get_lang (PangoContext *context) } /** - * pango_context_get_size: - * @context: a #PangoContext - * - * Retrieves the default font size for the context. - * - * Return value: the default font size in 1000ths of a point. - **/ -int -pango_context_get_size (PangoContext *context) -{ - g_return_val_if_fail (context != NULL, 0); - - return context->size; -} - -/** - * pango_context_set_size: - * @context: a #PangoContext - * @size: the new default font size in points in 1000ths of a point. - * - * Sets the default font size for the context. - **/ -void -pango_context_set_size (PangoContext *context, - int size) -{ - g_return_if_fail (context != NULL); - - context->size = size; -} - -/** * pango_context_set_base_dir: * @context: a #PangoContext * @direction: the new base direction @@ -657,8 +622,6 @@ add_engines (PangoContext *context, PangoMap *shape_map = NULL; PangoMap *lang_map = NULL; PangoFontDescription current_desc = { 0 }; - int current_size = 0; - int next_size = 0; /* FIXME: Remove this artificial limit */ @@ -708,20 +671,12 @@ add_engines (PangoContext *context, pango_attr_iterator_get_font (iterator, context->font_desc, &next_desc); - attr = pango_attr_iterator_get (iterator, PANGO_ATTR_SIZE); - if (attr) - next_size = ((PangoAttrInt *)attr)->value; - else - next_size = context->size; - if (i == 0 || - !pango_font_description_compare (¤t_desc, &next_desc) || - current_size != next_size) + !pango_font_description_compare (¤t_desc, &next_desc)) { char **families; current_desc = next_desc; - current_size = next_size; for (j=0; j<n_families; j++) { @@ -743,7 +698,7 @@ add_engines (PangoContext *context, for (j=0; j<n_families; j++) { next_desc.family_name = families[j]; - current_fonts[j] = pango_context_load_font (context, &next_desc, next_size / 1000.); + current_fonts[j] = pango_context_load_font (context, &next_desc); if (current_fonts[j]) current_coverages[j] = pango_font_get_coverage (current_fonts[j], lang); diff --git a/pango/pango-context.h b/pango/pango-context.h index bc8badf9..8aa0d0bf 100644 --- a/pango/pango-context.h +++ b/pango/pango-context.h @@ -47,8 +47,7 @@ void pango_context_list_families (PangoContext *context gchar ***families, int *n_families); PangoFont * pango_context_load_font (PangoContext *context, - const PangoFontDescription *desc, - gdouble size); + const PangoFontDescription *desc); void pango_context_set_font_description (PangoContext *context, const PangoFontDescription *desc); @@ -56,9 +55,6 @@ PangoFontDescription *pango_context_get_font_description (PangoContext char * pango_context_get_lang (PangoContext *context); void pango_context_set_lang (PangoContext *context, const char *lang); -int pango_context_get_size (PangoContext *context); -void pango_context_set_size (PangoContext *context, - int size); void pango_context_set_base_dir (PangoContext *context, PangoDirection direction); PangoDirection pango_context_get_base_dir (PangoContext *context); diff --git a/pango/pango-font.h b/pango/pango-font.h index 1c262609..d6d67d0e 100644 --- a/pango/pango-font.h +++ b/pango/pango-font.h @@ -62,13 +62,16 @@ typedef enum { PANGO_STRETCH_ULTRA_EXPANDED } PangoStretch; -struct _PangoFontDescription { - gchar *family_name; +struct _PangoFontDescription +{ + char *family_name; PangoStyle style; PangoVariant variant; PangoWeight weight; PangoStretch stretch; + + int size; }; PangoFontDescription *pango_font_description_copy (const PangoFontDescription *desc); @@ -133,8 +136,7 @@ struct _PangoFontMapClass { void (*destroy) (PangoFontMap *fontmap); PangoFont *(*load_font) (PangoFontMap *fontmap, - const PangoFontDescription *desc, - double size); + const PangoFontDescription *desc); void (*list_fonts) (PangoFontMap *fontmap, const gchar *family, PangoFontDescription ***descs, @@ -148,8 +150,7 @@ void pango_font_map_init (PangoFontMap *fontmap); void pango_font_map_ref (PangoFontMap *fontmap); void pango_font_map_unref (PangoFontMap *fontmap); PangoFont *pango_font_map_load_font (PangoFontMap *fontmap, - const PangoFontDescription *desc, - double size); + const PangoFontDescription *desc); void pango_font_map_list_fonts (PangoFontMap *fontmap, const gchar *family, diff --git a/pango/pangox.c b/pango/pangox.c index 7fe21994..1adf0603 100644 --- a/pango/pangox.c +++ b/pango/pangox.c @@ -73,7 +73,7 @@ struct _PangoXFont char **fonts; int n_fonts; - double size; + int size; /* hash table mapping from charset-name to array of PangoXSubfont ids, * of length n_fonts @@ -98,6 +98,8 @@ struct _PangoXFontMap GHashTable *size_infos; int n_fonts; + + double resolution; /* (points / pixel) * 1000 */ }; /* This is the largest field length we will accept. If a fontname has a field @@ -162,8 +164,7 @@ const struct { static void pango_x_font_map_destroy (PangoFontMap *fontmap); static PangoFont *pango_x_font_map_load_font (PangoFontMap *fontmap, - const PangoFontDescription *desc, - double size); + const PangoFontDescription *desc); static void pango_x_font_map_list_fonts (PangoFontMap *fontmap, const gchar *family, PangoFontDescription ***descs, @@ -195,14 +196,15 @@ static XFontStruct * pango_x_get_font_struct (PangoFont *font, static PangoFont *pango_x_load_font_with_size (Display *display, char *spec, - double size); + int size); static gboolean pango_x_is_xlfd_font_name (const char *fontname); static char * pango_x_get_xlfd_field (const char *fontname, FontField field_num, char *buffer); static char * pango_x_get_identifier (const char *fontname); -static gint pango_x_get_size (const char *fontname); +static gint pango_x_get_size (PangoXFontMap *fontmap, + const char *fontname); static void pango_x_insert_font (PangoXFontMap *fontmap, const char *fontname); @@ -229,6 +231,7 @@ pango_x_font_map_for_display (Display *display) GList *tmp_list = fontmaps; char **xfontnames; int num_fonts, i; + int screen; while (tmp_list) { @@ -272,6 +275,12 @@ pango_x_font_map_for_display (Display *display) fontmaps = g_list_prepend (fontmaps, xfontmap); + /* This is a little screwed up, since different screens might have different resolutions + */ + screen = DefaultScreen (xfontmap->display); + xfontmap->resolution = (1000. * 72. / 25.4) * ((double) DisplayWidthMM (xfontmap->display, screen) / + DisplayHeight (xfontmap->display, screen)); + return (PangoFontMap *)xfontmap; } @@ -302,8 +311,7 @@ pango_x_get_family_entry (PangoXFontMap *xfontmap, static PangoFont * pango_x_font_map_load_font (PangoFontMap *fontmap, - const PangoFontDescription *description, - double size) + const PangoFontDescription *description) { PangoXFontMap *xfontmap = (PangoXFontMap *)fontmap; PangoXFamilyEntry *family_entry; @@ -311,7 +319,8 @@ pango_x_font_map_load_font (PangoFontMap *fontmap, GSList *tmp_list; gchar *name; - g_return_val_if_fail (size > 0, NULL); + 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); @@ -349,7 +358,7 @@ pango_x_font_map_load_font (PangoFontMap *fontmap, while (tmp_list) { PangoXFont *xfont = tmp_list->data; - if (xfont->size == size) + if (xfont->size == description->size) { result = (PangoFont *)xfont; pango_font_ref (result); @@ -360,7 +369,7 @@ pango_x_font_map_load_font (PangoFontMap *fontmap, if (!result) { - result = pango_x_load_font_with_size (xfontmap->display, best_match->xlfd, size); + result = pango_x_load_font_with_size (xfontmap->display, best_match->xlfd, description->size); ((PangoXFont *)result)->entry = best_match; best_match->cached_fonts = g_slist_prepend (best_match->cached_fonts, result); } @@ -950,7 +959,7 @@ pango_x_is_xlfd_font_name (const char *fontname) } static int -pango_x_get_size (const char *fontname) +pango_x_get_size (PangoXFontMap *xfontmap, const char *fontname) { char size_buffer[XLFD_MAX_FIELD_LEN]; int size; @@ -960,7 +969,9 @@ pango_x_get_size (const char *fontname) size = atoi (size_buffer); if (size != 0) - return size * 10; + { + return (int)(0.5 + size * xfontmap->resolution); + } else { /* We use the trick that scaled bitmaps have a non-zero RESOLUTION_X, while @@ -1250,7 +1261,7 @@ pango_x_load_font (Display *display, static PangoFont * pango_x_load_font_with_size (Display *display, char *spec, - double size) + int size) { PangoXFont *result; @@ -1577,9 +1588,8 @@ name_for_charset (char *xlfd, char *charset) * The XLFD must be a full XLFD (14 fields) */ static char * -pango_x_make_matching_xlfd (PangoXFontMap *xfontmap, char *xlfd, const char *charset, double size) +pango_x_make_matching_xlfd (PangoXFontMap *xfontmap, char *xlfd, const char *charset, int size) { - int size_decipoints = floor (size*10 + 0.5); GSList *tmp_list; PangoXSizeInfo *size_info; char *identifier; @@ -1615,18 +1625,18 @@ pango_x_make_matching_xlfd (PangoXFontMap *xfontmap, char *xlfd, const char *cha if (match_end (tmp_xlfd, dash_charset)) { - int size = pango_x_get_size (tmp_xlfd); + int font_size = pango_x_get_size (xfontmap, tmp_xlfd); if (size != -1) { - int new_distance = (size == 0) ? 0 : abs (size - size_decipoints); + int new_distance = (font_size == 0) ? 0 : abs (font_size - size); if (!closest_match || new_distance < match_distance || - (new_distance == 0 && match_scaleable && size != 0)) + (new_distance == 0 && match_scaleable && font_size != 0)) { closest_match = tmp_xlfd; - match_scaleable = (size == 0); + match_scaleable = (font_size == 0); match_distance = new_distance; } } @@ -1664,8 +1674,9 @@ pango_x_make_matching_xlfd (PangoXFontMap *xfontmap, char *xlfd, const char *cha if (match_scaleable) { + int target_size = (int)((double)size / xfontmap->resolution + 0.5); char *prefix = g_strndup (closest_match, prefix_end - closest_match); - result = g_strdup_printf ("%s--*-%d-*-*-*-*-%s", prefix, size_decipoints, charset); + result = g_strdup_printf ("%s--%d-*-*-*-*-*-%s", prefix, target_size, charset); g_free (prefix); } else |