On ?ro 16. lipca 2003 14:51, Tomasz Grobelny wrote:> value.type=FcTypeString; > value.u.s=_family.ascii(); > FcPatternAdd(pat, FC_FAMILY, value, true); >This certainly could be done better: I''ve just discovered FcPatterAdd<Type> functions. But this shouldn''t have inpact on this:> // and now result contains FcResultNoMatch - why? >Tomek
On sob 19. lipca 2003 21:17, Keith Packard wrote:> Around 20 o''clock on Jul 19, Tomasz Grobelny wrote: > > But in the application menu only scalable font should be shown (ex. word > > processor). > > Why is that? While some of us would never again consider using bitmap > fonts on the screen, there are still people who prefer them in some > applications, especially applications which are presenting information that > isn''t intended for printing (mail readers, terminal emulators, web > browers). >It is a word processor so printing is necessary and so are scalable fonts.> If your application wants to display only scalable fonts in it''s menu, > then the fontconfig listing functions can be directed to supply only > scalable names. >But sometimes the font family is just written to a file.> > No, I want only my app to use vector fonts. Everything else should remain > > untouched. > > Then we need to find a way to have your application ask for scalable > fonts; in particular, if it asks for Times, it''s going to get Times with > the current architecture. Is there some particular reason you want to use > this family name? >Yes. For example one user has Times as Type1 font (scalable) so on another computer we want to get a similar family (giving Times should give us TTF Times New Roman because this user doesn''t have Type1 Times).> > What about a possbility to provide parametrical match. The developer > > could provide priority for each font property (the order of font > > properties should be necessary). > > The match is already ordered, but the priority order is fixed within the > library. I''d like to avoid further complexity in the library interface ifUsing FcObjectSet could be considered...> possible; perhaps you can explain how your application managed to get the > ''Times'' name in the first place so we can figure out a way to get the > desired result. >As mentioned above: from a file. Tomek PS For now I use FcFontSort and l look up the returned list until I find first scalable font. But this doesn''t seem to be The Right Thing.
On ?ro 16. lipca 2003 19:25, Tomasz Grobelny wrote:> On ?ro 16. lipca 2003 14:51, Tomasz Grobelny wrote: > > value.type=FcTypeString; > > value.u.s=_family.ascii(); > > FcPatternAdd(pat, FC_FAMILY, value, true); > > This certainly could be done better: I''ve just discovered FcPatterAdd<Type> >Now the code looks like this: pat=FcPatternCreate(); FcPatternAddString(pat, FC_FAMILY, _family.ascii()); FcPatternAddBool(pat, FC_SCALABLE, FcTrue); FcPatternAddBool(pat, FC_OUTLINE, FcTrue); FcPatternAddInteger(pat, FC_WEIGHT, _weight); FcPatternAddInteger(pat, FC_SLANT, _slant); FcPatternAddDouble(pat, FC_SIZE, _size); FcDefaultSubstitute(pat); FcConfigSubstitute(FcConfigGetCurrent(), pat, FcMatchPattern); FcResult result; font=FcFontMatch(FcConfigGetCurrent(), pat, &result); FcValue v; FcPatternGet(font, FC_FILE, 0, &v); cout<<v.u.s<<endl; But the output is (for "Times"): /usr/share/fonts/75dpi/timR24.pcf.gz so it is a non scalable, non outline font (I was requesting quite the opposite). Why is that so? Tomek
On sob 19. lipca 2003 19:59, Keith Packard wrote:> Around 1 o''clock on Jul 18, Tomasz Grobelny wrote: > > But the output is (for "Times"): > > /usr/share/fonts/75dpi/timR24.pcf.gz > > so it is a non scalable, non outline font (I was requesting quite the > > opposite). Why is that so? > > Because the family match is "more important" than the scalable match -- > applications which explicitly ask for ''Times'' are going to get it if you > have it. The alternative is quite confusing when selecting font families > from an application menu (ask for Times, get Times New Roman). >But in the application menu only scalable font should be shown (ex. word processor).> To make the system never provide ''Times'', you need to remove it from > consideration entirely.No, I want only my app to use vector fonts. Everything else should remain untouched.> Yes, this is a kludge, and perhaps we should (instead) have a way to > eliminate fonts based on their characteristics instead. Syntax and > semantics suggestions for that would be welcome. >What about a possbility to provide parametrical match. The developer could provide priority for each font property (the order of font properties should be necessary). For example if I want only scalable fonts I would place FC_SCALABLE in the first place and then the rest (family, weight, slant, etc.). Tomek
Around 1 o''clock on Jul 18, Tomasz Grobelny wrote:> But the output is (for "Times"): > /usr/share/fonts/75dpi/timR24.pcf.gz > so it is a non scalable, non outline font (I was requesting quite the > opposite). Why is that so?Because the family match is "more important" than the scalable match -- applications which explicitly ask for ''Times'' are going to get it if you have it. The alternative is quite confusing when selecting font families from an application menu (ask for Times, get Times New Roman). To make the system never provide ''Times'', you need to remove it from consideration entirely. With fontconfig 2.2, you have to change the font path to not include the directories full of bitmap fonts. With current CVS, you can exclude files based on filename patterns: <selectfont> <rejectfont> <glob>/usr/X11R6/lib/X11/fonts/misc*</glob> <glob>*.pcf*</glob> <glob>*.bdf*</glob> </rejectfont> </selectfont> Yes, this is a kludge, and perhaps we should (instead) have a way to eliminate fonts based on their characteristics instead. Syntax and semantics suggestions for that would be welcome. -keith
Around 20 o''clock on Jul 19, Tomasz Grobelny wrote:> But in the application menu only scalable font should be shown (ex. word > processor).Why is that? While some of us would never again consider using bitmap fonts on the screen, there are still people who prefer them in some applications, especially applications which are presenting information that isn''t intended for printing (mail readers, terminal emulators, web browers). If your application wants to display only scalable fonts in it''s menu, then the fontconfig listing functions can be directed to supply only scalable names.> No, I want only my app to use vector fonts. Everything else should remain > untouched.Then we need to find a way to have your application ask for scalable fonts; in particular, if it asks for Times, it''s going to get Times with the current architecture. Is there some particular reason you want to use this family name?> What about a possbility to provide parametrical match. The developer could > provide priority for each font property (the order of font properties > should be necessary).The match is already ordered, but the priority order is fixed within the library. I''d like to avoid further complexity in the library interface if possible; perhaps you can explain how your application managed to get the ''Times'' name in the first place so we can figure out a way to get the desired result. -keith
I was writing such a code but it doesn''t work as expected: //construct a pattern pat=FcPatternCreate(); FcValue value; value.type=FcTypeString; value.u.s=_family.ascii(); FcPatternAdd(pat, FC_FAMILY, value, true); value.type=FcTypeInteger; value.u.i=_weight; FcPatternAdd(pat, FC_WEIGHT, value, true); value.type=FcTypeInteger; value.u.i=_slant; FcPatternAdd(pat, FC_SLANT, value, true); value.type=FcTypeDouble; value.u.d=_size; FcPatternAdd(pat, FC_SIZE, value, true); value.type=FcTypeDouble; value.u.d=_size; FcPatternAdd(pat, FC_PIXEL_SIZE, value, true); //check if constructed - ok FcValue* v; FcPatternGet(pat, FC_FAMILY, 0, v); cout<<"get family: "<<v->u.s<<endl; // (...) FcConfig* config=FcInitLoadConfig(); FcDefaultSubstitute(pat); FcConfigSubstitute(config, pat, FcMatchPattern); FcResult* result=new FcResult; font=FcFontMatch(config, pat, result); // and now result contains FcResultNoMatch - why? I tried to get Helvetica, Times, or Times New Roman - none of these worked. What''s wrong with this code? Tomek