Re: pango fonts default aliases --> gnome fonts?



Hi Chema,

On Út, 2003-01-28 at 18:06, Chema Celorio wrote:
> On Tue, 2003-01-28 at 09:02, Radek Doulík wrote:
> > Hi,
> > 
> > I am trying to make gtkhtml work better with gnome print 2.2 and I have
> > run into the following problem.
> > 
> > When I request GnomeFont for family 'Sans' (one of three default Pango
> > aliases), I get different font from Pango one - it lacks some i18n
> > glyphs. My guess is that gnome print doesn't find the Sans font and gets
> > 1st known available font.
> > 
> > What do you recommend to use in place of the Sans font? Is there a
> > similar font alias in gnome print?
> 
> Try to get "Sans Regular" from gnome-print. The alias we have in
> gnome-print are:
> 	GPAliasInfo aliases[] = {
> 		{ "Sans Regular",          "sans-serif", FC_SLANT_ROMAN,  FC_WEIGHT_MEDIUM },
> 		{ "Sans Bold",             "sans-serif", FC_SLANT_ROMAN,  FC_WEIGHT_BOLD },
> 		{ "Sans Italic",           "sans-serif", FC_SLANT_ITALIC, FC_WEIGHT_MEDIUM },
> 		{ "Sans Bold Italic",      "sans-serif", FC_SLANT_ITALIC, FC_WEIGHT_BOLD },
> 		{ "Serif Regular",         "serif",      FC_SLANT_ROMAN,  FC_WEIGHT_MEDIUM },
> 		{ "Serif Bold",            "serif",      FC_SLANT_ROMAN,  FC_WEIGHT_BOLD },
> 		{ "Serif Italic",          "serif",      FC_SLANT_ITALIC, FC_WEIGHT_MEDIUM },
> 		{ "Serif Bold Italic",     "serif",      FC_SLANT_ITALIC, FC_WEIGHT_BOLD },
> 		{ "Monospace Regular",     "monospace",  FC_SLANT_ROMAN,  FC_WEIGHT_MEDIUM },
> 		{ "Monospace Bold",        "monospace",  FC_SLANT_ROMAN,  FC_WEIGHT_BOLD },
> 		{ "Monospace Italic",      "monospace",  FC_SLANT_ITALIC, FC_WEIGHT_MEDIUM },
> 		{ "Monospace Bold Italic", "monospace",  FC_SLANT_ITALIC, FC_WEIGHT_BOLD },
> 		{ NULL }
> 	};

I must be blind that I didn't see it.

> The second, third and fourth element of each row are the parameters to fontconfig in:
> 
> match_pattern = FcPatternBuild (NULL,
> 				FC_FAMILY, FcTypeString,  aliases[i].family,
> 				FC_SLANT,  FcTypeInteger, aliases[i].slant,
> 				FC_WEIGHT, FcTypeInteger, aliases[i].weight,
> 				NULL);
> 
> hope this helps,

These aliases works, but only for font names. I am attaching patch which
enables these aliases as family aliases.

It does 2 things:
      * it renames sans-serif family to sans which works as well with
        fontconfig and is "compatible" with gtk's 'Sans'
      * replaces familyname in GPFontEntry with alias name, so that
        gnome_font_find_closest_from_weight_slant knows these aliases

With this patch applied gtkhtml will work nicely.
May I commit?

Cheers
Radek

Index: gnome-fontmap.c
===================================================================
RCS file: /cvs/gnome/libgnomeprint/libgnomeprint/gnome-fontmap.c,v
retrieving revision 1.35
diff -u -p -r1.35 gnome-fontmap.c
--- gnome-fontmap.c	19 Jan 2003 23:39:37 -0000	1.35
+++ gnome-fontmap.c	28 Jan 2003 18:03:14 -0000
@@ -220,7 +220,7 @@ fcpattern_to_gp_font_entry (FcPattern *f
 }
 
 static GPFontEntry *
-fcpattern_to_gp_font_entry_alias (FcPattern *font, const gchar *name)
+fcpattern_to_gp_font_entry_alias (FcPattern *font, const gchar *name, const gchar *family)
 {
 	GPFontEntry *e;
 
@@ -230,6 +230,8 @@ fcpattern_to_gp_font_entry_alias (FcPatt
 
 	my_g_free (e->name);
 	e->name   = g_strdup (name);
+	my_g_free (e->familyname);
+	e->familyname = g_strdup (family);
 	e->is_alias = TRUE;
 	   
 	return e;
@@ -254,10 +256,10 @@ gp_fontmap_add_aliases (GPFontMap *map)
 	FcPattern *match_pattern, *result_pattern;
 	GPFontEntry *e;
 	GPAliasInfo aliases[] = {
-		{ "Sans Regular",          "sans-serif", FC_SLANT_ROMAN,  FC_WEIGHT_MEDIUM },
-		{ "Sans Bold",             "sans-serif", FC_SLANT_ROMAN,  FC_WEIGHT_BOLD },
-		{ "Sans Italic",           "sans-serif", FC_SLANT_ITALIC, FC_WEIGHT_MEDIUM },
-		{ "Sans Bold Italic",      "sans-serif", FC_SLANT_ITALIC, FC_WEIGHT_BOLD },
+		{ "Sans Regular",          "sans", FC_SLANT_ROMAN,  FC_WEIGHT_MEDIUM },
+		{ "Sans Bold",             "sans", FC_SLANT_ROMAN,  FC_WEIGHT_BOLD },
+		{ "Sans Italic",           "sans", FC_SLANT_ITALIC, FC_WEIGHT_MEDIUM },
+		{ "Sans Bold Italic",      "sans", FC_SLANT_ITALIC, FC_WEIGHT_BOLD },
 		{ "Serif Regular",         "serif",      FC_SLANT_ROMAN,  FC_WEIGHT_MEDIUM },
 		{ "Serif Bold",            "serif",      FC_SLANT_ROMAN,  FC_WEIGHT_BOLD },
 		{ "Serif Italic",          "serif",      FC_SLANT_ITALIC, FC_WEIGHT_MEDIUM },
@@ -293,7 +295,7 @@ gp_fontmap_add_aliases (GPFontMap *map)
 			continue;
 		}
 		
-		e = fcpattern_to_gp_font_entry_alias (result_pattern, aliases[i].name);
+		e = fcpattern_to_gp_font_entry_alias (result_pattern, aliases[i].name, aliases[i].family);
 		if (e) {
 			g_hash_table_insert (map->fontdict, e->name, e);
 			map->num_fonts++;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]