Wang WenRui
2005-Nov-21 08:50 UTC
[Fontconfig] How to use different fonts for different characters?
On Tue, Apr 29, 2003 at 10:20:31PM -0700, Keith Packard wrote:> > Around 12 o''clock on Apr 30, Wang WenRui wrote: > > <match target="pattern"> > <test qual="any" name="family"> > <string>sans-serif</string> > </test> > <edit name="family" mode="append" binding="strong"> > <string>Bitstream Vera Sans</string> > </edit> > </match> > > Very nicely done. That should do precisely what you want -- prefer > Bitstream Vera Sans for any characters that it does support in place of any > other fonts that are weakly substituted and overriding any language > specification from the locale or document.Could you tell me how to get this work in source code? My program broke in this way(it just render letters only, while doesn''t render any Chinese characters), but pango and mozilla works. Thanks a lot. Best regards Wang WenRui --------- my code --------- pattern = XftPatternCreate (); XftPatternAddString (pattern, "family", "monospace"); XftPatternAddString (pattern, XFT_ENCODING, "iso10646-1"); XftPatternAddString (pattern, "lang", "zh-CN"); XftPatternAddInteger (pattern, XFT_SPACING, XFT_MONO); xftFont = XftFontOpenPattern (dpy, XftFontMatch (dpy, iScreen, pattern, &result)); Then I draw the utf8 string with : XftTextExtentsUtf8 (dpy, xftFont, strOutput, strlen (strOutput), &extents); XftDrawStringUtf8 (xftDraw, &color, xftFont, x, y, strOutput, strlen (strOutput)) FC_DEBUG=1 myprogram shows: FC_DEBUG=1 Match Pattern 20 of 32 antialias: FcFalse(w) autohint: FcFalse(s) dpi: 100.037(f)(s) encoding: "iso10646-1"(s) family: "Bitstream Vera Sans Mono"(w) "SimSun"(w) "STXihei"(w) "Bitstream Vera Sans Mono"(w) "Andale Mono"(w) "Courier New"(w) "Luxi Mono"(w) "Nimbus Mono L"(w) "Kochi Gothic"(w) "AR PL KaitiM GB"(w) "Baekmuk Dotum"(w) "monospace"(s) "Bitstream Vera Sans Mono"(s) fontversion: 2147483647(i)(s) globaladvance: FcTrue(s) hinting: FcTrue(s) lang: "zh-CN"(s) maxglyphmemory: 1048576(i)(s) minspace: FcFalse(s) pixelsize: 16(i)(s) render: FcTrue(s) rgba: 0(i)(s) scale: 1(f)(s) slant: 0(i)(s) spacing: 100(i)(s) verticallayout: FcFalse(s) weight: 100(i)(s) width: 100(i)(s) Best score 0 0 12 200 0 0 0 0 0 2000 0 0 0 0 2.14735e+11Pattern 14 of 14 charset: set(s) family: "Bitstream Vera Sans Mono"(s) file: "/usr/share/fonts/truetype/ttf-bitstream-vera/VeraMono.ttf"(s) fontversion: 131072(i)(s) foundry: "bitsteam"(s) index: 0(i)(s) lang: aa|ast|ay|bi|br|ch|co|da|de|en|es|et|eu|fi|fj|fo|fr|fur|fy|gd|gl|gv|ho|ia|id|ie|io|is|it|lb|mg|nb|nl|nn|no|oc|om|pt|rm|sma|smj|so|sq|sv|sw|tn|tr|ts|vo|vot|wa|xh|yap|zu(s) outline: FcTrue(s) scalable: FcTrue(s) slant: 0(i)(s) spacing: 100(i)(s) style: "Roman"(s) weight: 80(i)(s) width: 100(i)(s)> > -keith > > > > _______________________________________________ > Fontconfig mailing list > Fontconfig@fontconfig.org > http://mail.fontconfig.org/mailman/listinfo/fontconfig
Keith Packard
2005-Nov-21 08:50 UTC
[Fontconfig] How to use different fonts for different characters?
Around 12 o''clock on Apr 30, Wang WenRui wrote: <match target="pattern"> <test qual="any" name="family"> <string>sans-serif</string> </test> <edit name="family" mode="append" binding="strong"> <string>Bitstream Vera Sans</string> </edit> </match> Very nicely done. That should do precisely what you want -- prefer Bitstream Vera Sans for any characters that it does support in place of any other fonts that are weakly substituted and overriding any language specification from the locale or document. -keith
Keith Packard
2005-Nov-21 08:50 UTC
[Fontconfig] How to use different fonts for different characters?
Around 4 o''clock on May 1, Wang WenRui wrote:> Could you tell me how to get this work in source code? My program broke > in this way(it just render letters only, while doesn''t render any > Chinese characters), but pango and mozilla works.You need to use FcFontSort instead of FcFontMatch. This returns a list of fonts in preference order; applications like pango and mozilla then search the list of fonts for the first one supporting each character and use that for drawing. Xft could use some helper APIs to make this easier for applications; right now it takes quite a bit of application code. -keith
Wang WenRui
2005-Nov-21 08:50 UTC
[Fontconfig] How to use different fonts for different characters?
On Tue, Apr 29, 2003 at 01:03:42PM -0700, Keith Packard wrote:> > Around 0 o''clock on Apr 30, Wang WenRui wrote: > > > How to use different fonts for different characters on fontconfig and > > xft? > > This requires application support for managing multiple fonts for > different languages or different parts of Unicode. Pango and Mozilla have > such support, but I''m not sure Qt can yet manage this.But when something like "XXX abcd XXX" (XXX stands for chinese characters) sent to the application, it will be handled in Chinese encoding, then it will be rendered by xft with the Chinese TTF file. The applications cannot split "XXX abcd XXX" to "XXX" + "abcd" + "XXX" for different languages.(Note that encodings like GB2312 is compatible with us-ascii). So I want to find a solution transparent to applications.> > -keith > > > > _______________________________________________ > Fontconfig mailing list > Fontconfig@fontconfig.org > http://mail.fontconfig.org/mailman/listinfo/fontconfig
Wang WenRui
2005-Nov-21 08:50 UTC
[Fontconfig] How to use different fonts for different characters?
On Tue, Apr 29, 2003 at 01:03:42PM -0700, Keith Packard wrote:> > Around 0 o''clock on Apr 30, Wang WenRui wrote: > > > How to use different fonts for different characters on fontconfig and > > xft? > > This requires application support for managing multiple fonts for > different languages or different parts of Unicode. Pango and Mozilla have > such support, but I''m not sure Qt can yet manage this.Hi, Keith: I am glad to see that this works: <match target="pattern"> <test qual="any" name="family"> <string>sans-serif</string> </test> <edit name="family" mode="append" binding="strong"> <string>Bitstream Vera Sans</string> </edit> </match> <match target="pattern"> <test qual="any" name="family"> <string>monospace</string> </test> <edit name="family" mode="append" binding="strong"> <string>Bitstream Vera Sans Mono</string> </edit> </match> Thanks to your nice fontconfig. Best regards Wang WenRui> > -keith > > > > _______________________________________________ > Fontconfig mailing list > Fontconfig@fontconfig.org > http://mail.fontconfig.org/mailman/listinfo/fontconfig
Keith Packard
2005-Nov-21 08:50 UTC
[Fontconfig] How to use different fonts for different characters?
Around 0 o''clock on Apr 30, Wang WenRui wrote:> How to use different fonts for different characters on fontconfig and > xft?This requires application support for managing multiple fonts for different languages or different parts of Unicode. Pango and Mozilla have such support, but I''m not sure Qt can yet manage this. -keith
Wang WenRui
2005-Nov-21 08:50 UTC
[Fontconfig] How to use different fonts for different characters?
Hi, How to use different fonts for different characters on fontconfig and xft? Maybe my question is vague. But I am in a situation that the English letters in my Chinese TTF font looks bad. I want the Chinese characters rendered with the Chinese TTF file, and Englist letters rendered with the cool Bitstream font. Is it possible by configuring fontconfig? Or where do I hack the code? Thanks in advance. Best regards Wang WenRui