faking smallcaps font with font features and fallbacks
Hello list, i'm trying to add a smallcaps variant to the MyriadPro font, since it does not implement the smcp opentype feature. My strategy: - "transplant" the uppercase letters of the MyriadPro-Regular into the lowercase letters of the same font with a font fallback that scales down the glyphs ("FakeSansCaps" in the following source) - since the scaled down glyphs get also thinner traits, embolden them with a font feature effect ("emboldened" in the following source) to make them consistent with the "real" uppercase letters What is not working: i don't know how to map the uppercase letters to the lowercase range; i tried to specify an offset of -32 in \definefontfallback[FakeSansCaps][SansEmboldened][0x61-0x7a][rscale=.8,force=yes,offset=-32] but it does not work. Here's the minimal (not) working example: \starttypescriptcollection [myriadpro] \definefontfeature[emboldened][effect={width=0.1,delta=0.4,factor=0.3}] \starttypescript [sans] [myriadpro] \definefontsynonym [Sans] [file:MyriadPro-Regular.otf] [features=default] \definefontsynonym [SansItalic] [file:MyriadPro-It.otf] [features=default] \definefontsynonym [SansBold] [file:MyriadPro-Bold.otf] [features=default] \definefontsynonym [SansBoldItalic] [file:MyriadPro-BoldIt.otf] [features=default] \definefontsynonym [SansSlanted] [file:MyriadPro-It.otf] [features=default] \definefontsynonym [SansBoldSlanted] [file:MyriadPro-BoldIt.otf] [features=default] \definefontsynonym [SansEmboldened] [Sans] [features=emboldened] \definefontfallback[FakeSansCaps] [SansEmboldened] [0x61-0x7a] [rscale=.8,force=yes] % offset? \definefontsynonym [SansCaps] [file:MyriadPro-Regular.otf] [fallbacks=FakeSansCaps] \stoptypescript \starttypescript [myriadpro] \definetypeface [myriadpro] [ss] [sans] [myriadpro] [default] \stoptypescript \stoptypescriptcollection \usetypescript[myriadpro] \setupbodyfont[myriadpro,ss] \starttext % scaled up 4 times to appreciate the thickness compensation \scale[sx=4,sy=4]{\sc SoMe CaMeLcAsE TeXt.}\par \stoptext
On 10/3/2018 12:33 PM, mf wrote:
Hello list, i'm trying to add a smallcaps variant to the MyriadPro font, since it does not implement the smcp opentype feature.
My strategy:
- "transplant" the uppercase letters of the MyriadPro-Regular into the lowercase letters of the same font with a font fallback that scales down the glyphs ("FakeSansCaps" in the following source)
- since the scaled down glyphs get also thinner traits, embolden them with a font feature effect ("emboldened" in the following source) to make them consistent with the "real" uppercase letters
What is not working: i don't know how to map the uppercase letters to the lowercase range; i tried to specify an offset of -32 in
\definefontfallback[FakeSansCaps][SansEmboldened][0x61-0x7a][rscale=.8,force=yes,offset=-32]
but it does not work.
Here's the minimal (not) working example:
\starttypescriptcollection [myriadpro]
\definefontfeature[emboldened][effect={width=0.1,delta=0.4,factor=0.3}]
\starttypescript [sans] [myriadpro] \definefontsynonym [Sans] [file:MyriadPro-Regular.otf] [features=default] \definefontsynonym [SansItalic] [file:MyriadPro-It.otf] [features=default] \definefontsynonym [SansBold] [file:MyriadPro-Bold.otf] [features=default] \definefontsynonym [SansBoldItalic] [file:MyriadPro-BoldIt.otf] [features=default] \definefontsynonym [SansSlanted] [file:MyriadPro-It.otf] [features=default] \definefontsynonym [SansBoldSlanted] [file:MyriadPro-BoldIt.otf] [features=default]
\definefontsynonym [SansEmboldened] [Sans] [features=emboldened] \definefontfallback[FakeSansCaps] [SansEmboldened] [0x61-0x7a] [rscale=.8,force=yes] % offset?
\definefontsynonym [SansCaps] [file:MyriadPro-Regular.otf] [fallbacks=FakeSansCaps] \stoptypescript \starttypescript [myriadpro] \definetypeface [myriadpro] [ss] [sans] [myriadpro] [default] \stoptypescript
\stoptypescriptcollection
\usetypescript[myriadpro]
\setupbodyfont[myriadpro,ss]
\starttext % scaled up 4 times to appreciate the thickness compensation \scale[sx=4,sy=4]{\sc SoMe CaMeLcAsE TeXt.}\par \stoptext 'offset' offsets the original, i'll add 'target' so that you can do
\definefontfallback[FakeSansCaps] [SansEmboldened] [0x61-0x7a] [rscale=.8,force=yes,target=0x41] ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On 10/3/2018 3:29 PM, Hans Hagen wrote:
On 10/3/2018 12:33 PM, mf wrote:
Hello list, i'm trying to add a smallcaps variant to the MyriadPro font, since it does not implement the smcp opentype feature.
My strategy:
- "transplant" the uppercase letters of the MyriadPro-Regular into the lowercase letters of the same font with a font fallback that scales down the glyphs ("FakeSansCaps" in the following source)
- since the scaled down glyphs get also thinner traits, embolden them with a font feature effect ("emboldened" in the following source) to make them consistent with the "real" uppercase letters
What is not working: i don't know how to map the uppercase letters to the lowercase range; i tried to specify an offset of -32 in
\definefontfallback[FakeSansCaps][SansEmboldened][0x61-0x7a][rscale=.8,force=yes,offset=-32]
but it does not work.
Here's the minimal (not) working example:
\starttypescriptcollection [myriadpro]
\definefontfeature[emboldened][effect={width=0.1,delta=0.4,factor=0.3}]
\starttypescript [sans] [myriadpro] \definefontsynonym [Sans] [file:MyriadPro-Regular.otf] [features=default] \definefontsynonym [SansItalic] [file:MyriadPro-It.otf] [features=default] \definefontsynonym [SansBold] [file:MyriadPro-Bold.otf] [features=default] \definefontsynonym [SansBoldItalic] [file:MyriadPro-BoldIt.otf] [features=default] \definefontsynonym [SansSlanted] [file:MyriadPro-It.otf] [features=default] \definefontsynonym [SansBoldSlanted] [file:MyriadPro-BoldIt.otf] [features=default]
\definefontsynonym [SansEmboldened] [Sans] [features=emboldened] \definefontfallback[FakeSansCaps] [SansEmboldened] [0x61-0x7a] [rscale=.8,force=yes] % offset?
\definefontsynonym [SansCaps] [file:MyriadPro-Regular.otf] [fallbacks=FakeSansCaps] \stoptypescript \starttypescript [myriadpro] \definetypeface [myriadpro] [ss] [sans] [myriadpro] [default] \stoptypescript
\stoptypescriptcollection
\usetypescript[myriadpro]
\setupbodyfont[myriadpro,ss]
\starttext % scaled up 4 times to appreciate the thickness compensation \scale[sx=4,sy=4]{\sc SoMe CaMeLcAsE TeXt.}\par \stoptext 'offset' offsets the original, i'll add 'target' so that you can do
\definefontfallback[FakeSansCaps] [SansEmboldened] [0x61-0x7a] [rscale=.8,force=yes,target=0x41] ok, even nicer:
\definefontfallback[FakeSansCaps] [SansEmboldened] [0x0000-0xFFFF] [rscale=.8,method=uppercase] which will remap all lowercase in the font so that you also get accented characters Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
Il 03/10/18 16:02, Hans Hagen ha scritto:
ok, even nicer:
\definefontfallback[FakeSansCaps] [SansEmboldened] [0x0000-0xFFFF] [rscale=.8,method=uppercase]
which will remap all lowercase in the font so that you also get accented characters
Yes, for this case it makes more sense using method=uppercase. But "target=" is a more general solution (remapping old dingbats fonts on the dingbats section of unicode makes sense as an example?) Would the range 0x0000-0xFFFF overwrite also capital letters? In that case i'm afraid we'd have a scaled down, embolded, uppercase version of the font, not a small-caps variant with a consistent thickess of the glyphs. I think i should specify only the lower case letters' ranges. Massimiliano
On 10/3/2018 4:20 PM, mf wrote:
Il 03/10/18 16:02, Hans Hagen ha scritto:
ok, even nicer:
\definefontfallback[FakeSansCaps] [SansEmboldened] [0x0000-0xFFFF] [rscale=.8,method=uppercase]
which will remap all lowercase in the font so that you also get accented characters
Yes, for this case it makes more sense using method=uppercase.
But "target=" is a more general solution (remapping old dingbats fonts on the dingbats section of unicode makes sense as an example?)
Would the range 0x0000-0xFFFF overwrite also capital letters?
it checks for the lowercase / uippercase unicode properties so it's safe
In that case i'm afraid we'd have a scaled down, embolded, uppercase version of the font, not a small-caps variant with a consistent thickess of the glyphs.
no, it more 'clever'
I think i should specify only the lower case letters' ranges. no, it does that itself
btw, make sure that you also apply default features to the emboldened ... Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
\starttypescriptcollection [myriadpro] \definefontfeature[emboldened][effect={width=0.18,delta=0.4,factor=0.3}] \starttypescript [sans] [myriadpro] \definefontsynonym [Sans] [file:MyriadPro-Regular.otf] [features=default] \definefontsynonym [SansItalic] [file:MyriadPro-It.otf] [features=default] \definefontsynonym [SansBold] [file:MyriadPro-Bold.otf] [features=default] \definefontsynonym [SansBoldItalic] [file:MyriadPro-BoldIt.otf] [features=default] \definefontsynonym [SansSlanted] [file:MyriadPro-It.otf] [features=default] \definefontsynonym [SansBoldSlanted] [file:MyriadPro-BoldIt.otf] [features=default] \definefontsynonym [SansEmboldened] [Sans] [features={default,emboldened}] \definefontfallback[FakeSansCaps] [SansEmboldened] [0x0000-0xFFFF] [rscale=.8,method=uppercase] \definefontsynonym [SansCaps] [file:MyriadPro-Regular.otf] [fallbacks=FakeSansCaps] \stoptypescript \starttypescript [myriadpro] \definetypeface [myriadpro] [ss] [sans] [myriadpro] [default] \stoptypescript \stoptypescriptcollection \usetypescript[myriadpro] \setupbodyfont[myriadpro,ss] \starttext % scaled up 4 times to appreciate the thickness equalization \scale[sx=4,sy=4]{\sc RoLlErCoAsTeR TeXt.}\par \blank \scale[sx=4,sy=4]{\sc ÀàÉéÎîÖöÜü.}\par \blank \scale[sx=4,sy=4]{\sc ŁłĄąĞğŘřŻż.}\par \stoptext
Hi, better shift a bit up to compensate for the line width relative to the bbox:
\starttypescriptcollection [myriadpro]
\definefontfeature[emboldened][effect={width=0.18,delta=0.4,factor=0.3}]
\definefontfeature[emboldened][effect={width=0.18,delta=0.4,factor=0.3,vshift=.4}]
\starttypescript [sans] [myriadpro] \definefontsynonym [Sans] [file:MyriadPro-Regular.otf] [features=default] \definefontsynonym [SansItalic] [file:MyriadPro-It.otf] [features=default] \definefontsynonym [SansBold] [file:MyriadPro-Bold.otf] [features=default] \definefontsynonym [SansBoldItalic] [file:MyriadPro-BoldIt.otf] [features=default] \definefontsynonym [SansSlanted] [file:MyriadPro-It.otf] [features=default] \definefontsynonym [SansBoldSlanted] [file:MyriadPro-BoldIt.otf] [features=default]
\definefontsynonym [SansEmboldened] [Sans] [features={default,emboldened}] \definefontfallback[FakeSansCaps] [SansEmboldened] [0x0000-0xFFFF] [rscale=.8,method=uppercase]
\definefontsynonym [SansCaps] [file:MyriadPro-Regular.otf] [fallbacks=FakeSansCaps] \stoptypescript \starttypescript [myriadpro] \definetypeface [myriadpro] [ss] [sans] [myriadpro] [default] \stoptypescript
\stoptypescriptcollection
\usetypescript[myriadpro]
\setupbodyfont[myriadpro,ss]
\starttext % scaled up 4 times to appreciate the thickness equalization \scale[sx=4,sy=4]{\sc RoLlErCoAsTeR TeXt.}\par \blank \scale[sx=4,sy=4]{\sc ÀàÉéÎîÖöÜü.}\par \blank \scale[sx=4,sy=4]{\sc ŁłĄąĞğŘřŻż.}\par \stoptext
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________
-- ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
Hi,
ok, even nicer:
\definefontfallback[FakeSansCaps] [SansEmboldened] [0x0000-0xFFFF] [rscale=.8,method=uppercase]
which will remap all lowercase in the font so that you also get accented characters
I do not like ‘emboldened’ as it results in a very ugly screen preview for me. But the new ‘uppercase’ feature is really neat, since it makes something that I had in mind for IBM Plex very easy to implement. Here is the demo: \starttypescriptcollection [plextest] \starttypescript [sans] [plextest] \setups[font:fallback:sans] \definefontsynonym [Sans] [file:IBMPlexSans-regular] [features=default] \definefontsynonym [SansDarker] [file:IBMPlexSans-text] [features=default] \definefontfallback[FakeSansCaps] [SansDarker] [0x0000-0xFFFF] [rscale=0.75,method=uppercase] \definefontsynonym [SansCaps] [file:IBMPlexSans-regular] [fallbacks=FakeSansCaps] \stoptypescript \starttypescript [plextest] \definetypeface [plextest] [ss] [sans] [plextest] [default] [features=default] \stoptypescript \stoptypescriptcollection \usetypescript[plextest] \setupbodyfont[plextest] \starttext \startTEXpage Some camelcase and number and {\sc SoMe CaMeLcAsE TeXt with Numbers and also EA\"e\'a\ae\AE\ and whatever has lowercase, like Effe Flink} but also different stuff \stopTEXpage \stoptext This only works for font families with many weights (IBM Plex has eight), but there are more of those around these days. With a bit of tweaking to the rscale, it should be possible to get visually correct greyness values for all of the family's fonts except for the most bold one (bold smallcaps is generally ugly anyway). Best wishes, Taco
On 10/4/2018 1:44 PM, Taco Hoekwater wrote:
Hi,
ok, even nicer:
\definefontfallback[FakeSansCaps] [SansEmboldened] [0x0000-0xFFFF] [rscale=.8,method=uppercase]
which will remap all lowercase in the font so that you also get accented characters
I do not like ‘emboldened’ as it results in a very ugly screen preview for me.
But the new ‘uppercase’ feature is really neat, since it makes something that I had in mind for IBM Plex very easy to implement. Here is the demo:
hm, here it actually looks quote ok ... apple preview issue? ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On 4 Oct 2018, at 14:11, Hans Hagen
wrote: On 10/4/2018 1:44 PM, Taco Hoekwater wrote:
Hi,
ok, even nicer:
\definefontfallback[FakeSansCaps] [SansEmboldened] [0x0000-0xFFFF] [rscale=.8,method=uppercase]
which will remap all lowercase in the font so that you also get accented characters I do not like ‘emboldened’ as it results in a very ugly screen preview for me. But the new ‘uppercase’ feature is really neat, since it makes something that I had in mind for IBM Plex very easy to implement. Here is the demo:
hm, here it actually looks quote ok ... apple preview issue?
Probably, but that also means I will not trust an unknown device at some printshop to do the ‘right thing’. Best wishes, Taco
On 10/4/2018 3:19 PM, Taco Hoekwater wrote:
On 4 Oct 2018, at 14:11, Hans Hagen
wrote: On 10/4/2018 1:44 PM, Taco Hoekwater wrote:
Hi,
ok, even nicer:
\definefontfallback[FakeSansCaps] [SansEmboldened] [0x0000-0xFFFF] [rscale=.8,method=uppercase]
which will remap all lowercase in the font so that you also get accented characters I do not like ‘emboldened’ as it results in a very ugly screen preview for me. But the new ‘uppercase’ feature is really neat, since it makes something that I had in mind for IBM Plex very easy to implement. Here is the demo:
hm, here it actually looks quote ok ... apple preview issue?
Probably, but that also means I will not trust an unknown device at some printshop to do the ‘right thing’.
hm, so then you can't trust linewidths either because that is what it does Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
Hi,
On 4 Oct 2018, at 15:46, Hans Hagen
wrote: On 10/4/2018 3:19 PM, Taco Hoekwater wrote:
On 4 Oct 2018, at 14:11, Hans Hagen
wrote: On 10/4/2018 1:44 PM, Taco Hoekwater wrote:
Hi,
ok, even nicer:
\definefontfallback[FakeSansCaps] [SansEmboldened] [0x0000-0xFFFF] [rscale=.8,method=uppercase]
which will remap all lowercase in the font so that you also get accented characters I do not like ‘emboldened’ as it results in a very ugly screen preview for me. But the new ‘uppercase’ feature is really neat, since it makes something that I had in mind for IBM Plex very easy to implement. Here is the demo:
hm, here it actually looks quote ok ... apple preview issue? Probably, but that also means I will not trust an unknown device at some printshop to do the ‘right thing’. hm, so then you can't trust linewidths either because that is what it does
Modifying the text rendering mode (Tr operator) is not quite the same as altering the line width in the page stream. Typically, renderers have separate code paths for text rendering and font rendering. Anyway, to add to the list: mupdf-gl also appears to do fine. Best wishes, Taco
Il 04/10/18 14:11, Hans Hagen ha scritto:
On 10/4/2018 1:44 PM, Taco Hoekwater wrote:
Hi,
ok, even nicer:
\definefontfallback[FakeSansCaps] [SansEmboldened] [0x0000-0xFFFF] [rscale=.8,method=uppercase]
which will remap all lowercase in the font so that you also get accented characters
I do not like ‘emboldened’ as it results in a very ugly screen preview for me.
But the new ‘uppercase’ feature is really neat, since it makes something that I had in mind for IBM Plex very easy to implement. Here is the demo:
hm, here it actually looks quote ok ... apple preview issue?
In Debian, evince has the same problem (ugly preview); instead qpdfview preview is OK.
On 10/4/2018 3:35 PM, mf wrote:
Il 04/10/18 14:11, Hans Hagen ha scritto:
On 10/4/2018 1:44 PM, Taco Hoekwater wrote:
Hi,
ok, even nicer:
\definefontfallback[FakeSansCaps] [SansEmboldened] [0x0000-0xFFFF] [rscale=.8,method=uppercase]
which will remap all lowercase in the font so that you also get accented characters
I do not like ‘emboldened’ as it results in a very ugly screen preview for me.
But the new ‘uppercase’ feature is really neat, since it makes something that I had in mind for IBM Plex very easy to implement. Here is the demo:
hm, here it actually looks quote ok ... apple preview issue?
In Debian, evince has the same problem (ugly preview); instead qpdfview preview is OK. maybe some aliasing option?
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
In Debian, evince has the same problem (ugly preview); instead qpdfview preview is OK. maybe some aliasing option?
evince (ugly) uses cairo, qpdfview (good) uses qt. Zooming out the preview becomes uglier, but - evince emboldens too much - qpdfview shifts the emboldened glyphs downward
In Debian, evince has the same problem (ugly preview); instead qpdfview preview is OK. maybe some aliasing option?
evince (ugly) uses cairo, qpdfview (good) uses qt.
Zooming out the preview becomes uglier, but - evince emboldens too much - qpdfview shifts the emboldened glyphs downward
On 10/4/2018 4:10 PM, mf wrote: that why i suggested a vshift \definefontfeature[emboldened][effect={width=0.18,delta=0.4,factor=0.3,vshift=.4}] ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On Thu, Oct 4, 2018 at 3:35 PM mf
In Debian, evince has the same problem (ugly preview); instead qpdfview preview is OK.
qpdfview -> Edit->Settings->Graphics General/PDF/PS Several "antialias like" option, plus backend. -- luigi
participants (4)
-
Hans Hagen
-
luigi scarso
-
mf
-
Taco Hoekwater