Re: @Font trumps @B & @I (which is a pity)
[email protected] (Ludovic Courtès)
| Newsgroups | gmane.comp.type-setting.lout |
|---|---|
| Message-ID | <[email protected]> |
Hi Mark, Mark Summerfield <[email protected]> writes: > This tiny document prints the last three 5s in Helvetica Base whereas > I'd hoped it would print the last one in Helvetica Slope and the one > from last in Helvetica Bold. > > I guess this is a feature rather than a bug? [...] > @B{{Helvetica Base}@Font @Char{five}} > @I{{Helvetica Base}@Font @Char{five}} Technically, it makes sense: ‘@Font’ sets the current font for its body, ‘5’, and ‘@B’ sets the current font for its body, which precisely starts with an ‘@Font’ symbol that changes the current font for its body. Similarly, ‘@B @I { body ... }’ is different from ‘@BI { body ... }’. To achieve why you want, i.e., inheritance of bold/italics, you could use “contexts”, which were introduced, ahem, “recently”: --8<---------------cut here---------------start------------->8--- @SysInclude { doc } def @ScopedBold right body { { boldicity @Yield yes } @SetContext { { @GetContext italicity } @Case { yes @Yield @BI { body } no @Yield @B { body } } } } def @ScopedItalics right body { { italicity @Yield yes } @SetContext { { @GetContext boldicity } @Case { yes @Yield @BI { body } no @Yield @I { body } } } } def @ScopedThing right thing { { boldicity @Yield no } @SetContext { { italicity @Yield no } @SetContext { thing } } } @Doc @Text @Begin @ScopedThing @ScopedItalics { @ScopedBold { hey } there! } @End @Text --8<---------------cut here---------------end--------------->8--- And voilà, you have “dynamically scoped” bold and italics! Thanks, Ludo’.