John Ellson
2005-Nov-21 08:50 UTC
[Fontconfig] What are the possible font family names? Why no "Helvetica" ?
Keith Packard wrote:>>Why is "Helvetica" not matched to a sans-serif font? >> >> > >it probably should be; your /etc/fonts/fonts.conf file should map >''Helvetica'' to ''sans-serif'' and then ''sans-serif'' to a list of possible >sans-serif faces. > >It was already in there. The problem was that I was missing the FcConfigSubstitute(0,pattern,FcPatternMatch); statement. I was thinking it was unnecessary if I was setting the pattern Thanks for fontconfig. This is exactly what I needed. John
Keith Packard
2005-Nov-21 08:50 UTC
[Fontconfig] What are the possible font family names? Why no "Helvetica" ?
Around 0 o''clock on Mar 17, John Ellson wrote:> FcConfigSubstitute(0,pattern,FcPatternMatch);This is the step which performs the various editing manipulations described in the configuration. Drop this and you won''t get any of the customization specified therein before the match occurs.> Thanks for fontconfig. This is exactly what I needed.Thanks for giving it a try; every app that adopts fontconfig is one fewer app with a private font configuration mechanism. If you report any troubles you find, future fontconfig releases can be even more useful. -keith
John Ellson
2005-Nov-21 08:50 UTC
[Fontconfig] What are the possible font family names? Why no "Helvetica" ?
OK, Progress. I now have a working "fam2font" program which is short enough to post here: ---------------------fam2font.c------------------------------------------------ #include <stdio.h> #include <fontconfig/fontconfig.h> int main (int argc, char *argv[]) { FcPattern *pattern = 0, *match = 0; FcChar8 *file = 0; if ((argc < 2) || !(FcInit())) return -1; pattern = FcPatternBuild(0,FC_FAMILY,FcTypeString,argv[1],0); FcDefaultSubstitute(pattern); if (!(match = FcFontMatch(0,pattern,0))) return -1; if (FcPatternGetString(match,FC_FILE,0,&file) != FcResultMatch) return -1; fprintf(stdout,"%s\n",file); return 0; } ------------------------------------------------------------------------------------- Compile with: gcc -Wall fam2font.c -lfontconfig -o fam2font Example usage: gnome-font-viewer `./fam2font fixed` gnome-font-viewer `./fam2font Times` Those worked OK for me, but I was expecting to get a sans-serif font with: gnome-font-viewer `./fam2font Helvetica` instead I got the same serif font as "Times" What are the possible font family names? Why is "Helvetica" not matched to a sans-serif font? John Ellson
Keith Packard
2005-Nov-21 08:50 UTC
[Fontconfig] font pattern -> font file : without X11 dependencies?
Around 13 o''clock on Mar 16, John Ellson wrote:> Is there any example code for converting a font-pattern to a font > filename *without* any X11 dependencies?I don''t know of any examples, but certainly Xft itself has code which does that that you can rip out of the library and use. The basic routine is something like: if (!FcInit (0)) return 0; FcConfigSubstitute (0, pattern, FcMatchPattern); FcDefaultSubstitute (pattern) match = FcFontMatch (0, pattern, result); return match; ''match'' now contains all of the information needed to access the font file. If you want to find a list of fonts, you use FcFontSort instead; that''s useful if you need to do glyph fill-in to handle glyphs not present in the best matching font. -keith
Keith Packard
2005-Nov-21 08:50 UTC
[Fontconfig] What are the possible font family names? Why no "Helvetica" ?
Around 20 o''clock on Mar 16, John Ellson wrote:> What are the possible font family names?fc-list will show the available font names> Why is "Helvetica" not matched to a sans-serif font?it probably should be; your /etc/fonts/fonts.conf file should map ''Helvetica'' to ''sans-serif'' and then ''sans-serif'' to a list of possible sans-serif faces. -keith
John Ellson
2005-Nov-21 08:50 UTC
[Fontconfig] font pattern -> font file : without X11 dependencies?
Please excuse me if this is a FAQ. I''ve just started looking at fontconfig. Is there any example code for converting a font-pattern to a font filename *without* any X11 dependencies? John Ellson