Erik
2008-Aug-05 01:06 UTC
[Fontconfig] Forcing Artificial Italics on Fonts That *DO* Have One Available?
I understand that this bit of code in .fonts.conf will enable italics for fonts that do not have an italic face available: <!-- Artificial oblique for fonts without an italic or oblique version --> <match target="font" > <!-- check to see if the font is roman --> <test name="slant" > <const>roman</const> </test> <!-- check to see if the pattern requested non-roman --> <test target="pattern" compare="not_eq" name="slant" > <const>roman</const> </test> <!-- multiply the matrix to slant the font --> <edit mode="assign" name="matrix" > <times> <name>matrix</name> <matrix> <double>1</double> <double>0.2</double> <double>0</double> <double>1</double> </matrix> </times> </edit> <!-- pretend the font is oblique now --> <edit mode="assign" name="slant" > <const>oblique</const> </edit> </match> I am interested in *forcing* this behavior on fonts that *do* have an italic face available, because I like the way the artificial rendering looks. I have been unable to make it work however. It seems that once an existing italic font has been selected, fontconfig will not give it up. One of my approaches was to have a piece of XML prior to the above which "undoes" any existing italic: <!-- Artificial oblique for fonts WITH an italic or oblique version --> <match target="font" > <!-- check to see if the font is NOT roman --> <test name="slant" compare="not_eq"> <const>roman</const> </test> <!-- check to see if the pattern requested non-roman --> <test target="pattern" compare="not_eq" name="slant" > <const>roman</const> </test> <edit mode="append" binding="same" name="slant"> <const>roman</const> </edit> </match> But, the end effect is to do double italics, i.e. it slants it twice. Does anybody have an idea on how to force it to first select the regular font, then apply artificial slanting to it? Thanks, Erik
Behdad Esfahbod
2008-Aug-05 04:22 UTC
[Fontconfig] Forcing Artificial Italics on Fonts That *DO* Have One Available?
On Mon, 2008-08-04 at 20:06 -0500, Erik wrote:> > But, the end effect is to do double italics, i.e. it slants it twice.This is because the italic face has already been selected.> Does anybody have an idea on how to force it to first select the regular > font, then apply artificial slanting to it?I have a couple of ideas: - Ban all Italic fonts so fontconfig does not see them at all. (may use target=scan for this, not sure). - This one should be easier: * In target=pattern, copy the slant value to a temp variable (say, saved_slant), * In target=pattern reset slant to roman, * In target=font, use saved_slant to decide whether to do artificial slanting. HTH, -- behdad http://behdad.org/ "Those who would give up Essential Liberty to purchase a little Temporary Safety, deserve neither Liberty nor Safety." -- Benjamin Franklin, 1759
Vasile Gaburici
2008-Aug-05 05:39 UTC
[Fontconfig] Forcing Artificial Italics on Fonts That *DO* Have One Available?
On Tue, Aug 5, 2008 at 7:22 AM, Behdad Esfahbod <behdad at behdad.org> wrote:> > I have a couple of ideas: > > - Ban all Italic fonts so fontconfig does not see them at all. (may > use target=scan for this, not sure).This one is bad. Fonts have italic versions for a reason: some have different glyph shapes, which aren''t simply oblique versions of the regular upright font. Also, some fonts like Latin Modern Serif even have an upright italic version.> - This one should be easier: > > * In target=pattern, copy the slant value to a temp variable (say, > saved_slant), > * In target=pattern reset slant to roman, > * In target=font, use saved_slant to decide whether to do artificial > slanting. > > HTH, > > -- > behdad > http://behdad.org/ > > "Those who would give up Essential Liberty to purchase a little > Temporary Safety, deserve neither Liberty nor Safety." > -- Benjamin Franklin, 1759 > > _______________________________________________ > Fontconfig mailing list > Fontconfig at lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/fontconfig > >
Behdad Esfahbod
2008-Aug-05 05:57 UTC
[Fontconfig] Forcing Artificial Italics on Fonts That *DO* Have One Available?
On Tue, 2008-08-05 at 08:39 +0300, Vasile Gaburici wrote:> > On Tue, Aug 5, 2008 at 7:22 AM, Behdad Esfahbod <behdad at behdad.org> > wrote: > > > > I have a couple of ideas: > > > > - Ban all Italic fonts so fontconfig does not see them at all. (may > > use target=scan for this, not sure). > > This one is bad. Fonts have italic versions for a reason: some have > different glyph shapes, which aren''t simply oblique versions of the > regular upright font. Also, some fonts like Latin Modern Serif even > have an upright italic version.If a user wants to configure his fontconfig to do that, why do *you* care? -- behdad http://behdad.org/ "Those who would give up Essential Liberty to purchase a little Temporary Safety, deserve neither Liberty nor Safety." -- Benjamin Franklin, 1759
Keith Packard
2008-Aug-05 06:27 UTC
[Fontconfig] Forcing Artificial Italics on Fonts That *DO* Have One Available?
On Mon, 2008-08-04 at 20:06 -0500, Erik wrote:> Does anybody have an idea on how to force it to first select the regular > font, then apply artificial slanting to it?Not to condone this kind of typographical abuse, but it seemed an interesting problem. The key is to switch to a roman font for the match, but then patch up the returned roman font to perform the artificial oblique effect. I think fontconfig provides too much flexibility some days. <match target="pattern"> <!-- match requests for non-roman face --> <test name="slant" compare="not_eq"> <const>roman</const> </test> <!-- remember that this should be slanted --> <edit name="fake_slant"> <bool>true</bool> </edit> <!--- change to match a roman face instead --> <edit name="slant"> <const>roman</const> </edit> </match> <match target="font"> <!-- check to see if the font is roman --> <test name="slant"> <const>roman</const> </test> <!-- look for fonts which were marked for fake obliquing --> <test name="fake_slant"> <bool>true</bool> </test> <!-- multiply the matrix to slant the font --> <edit name="matrix" mode="assign"> <times> <name>matrix</name> <matrix><double>1</double><double>0.2</double> <double>0</double><double>1</double> </matrix> </times> </edit> <!-- mark the font as oblique now --> <edit name="slant"> <const>oblique</const> </edit> </match> -- keith.packard at intel.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part Url : http://lists.freedesktop.org/archives/fontconfig/attachments/20080804/8ae75874/attachment.pgp
Erik
2008-Aug-05 23:53 UTC
[Fontconfig] Forcing Artificial Italics on Fonts That *DO* Have One Available?
If it makes you guys feel any better, I didn''t actually want this for every italic font, just those that I am doing BCI full hinting on (mainly MS ones). Otherwise the stems on letters look like a field of grass waving in the wind. So, I''m simply doing glyph abuse to fix glyph abuse! After posting, I played around a bit more and got the below code to work, but I wasn''t able to figure out how to insert multiple fonts within this code; it had to be duplicated for every font. Keith''s solution is more elegant and lets me put multiple fonts in the code. Thanks for the help! <selectfont> <rejectfont> <pattern> <patelt name="family" > <string>Courier New</string> </patelt> <patelt name="slant" > <const>italic</const> </patelt> </pattern> </rejectfont> </selectfont>