lout-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: @Font trumps @B & @I (which is a pity)


From: Ludovic Courtès
Subject: Re: @Font trumps @B & @I (which is a pity)
Date: Mon, 11 Oct 2010 22:41:55 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Hi Mark,

Mark Summerfield <address@hidden> 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 address@hidden @Char{five}}
> @I{{Helvetica address@hidden @Char{five}}

Technically, it makes sense: address@hidden sets the current font for its body,
‘5’, and address@hidden sets the current font for its body, which precisely 
starts
with an address@hidden symbol that changes the current font for its body.

Similarly, address@hidden @I { body ... }’ is different from address@hidden { 
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’.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]