12

I'm having difficulty accessing font ornaments from ConTeXt. I'm using mkiv. I have a font and I know it has fancy ornaments in it because I see them in the spec sheet. I don't understand what to do beyond this point to find them in the font or get them into the document, and I'd like to know what to do to discover what ornaments there are in the font.

For instance, I know Arno has several leaf-style glyphs intended for decoration. Minion has several heart-shaped bullets. Knowing just these facts, I don't see what to do to get the glyph onto the page.

1 Answer 1

15

You can access the glyphs contained in a font with the fnt-10 module:

\usemodule [fnt-10]
\starttext
  \ShowCompleteFont{name:minionproregular}{10pt}{1}
\stoptext

This outputs a list of the glyphs, the Unicode values and the glyph names. You get the font name on the console with

mtxrun -script fonts -list -all

When you have the font and the glyph name you can use

\getnamedglyphdirect{font}{glyph}, e.g.
\getnamedglyphdirect{name:minionproregular}{bullet.010}

to obtain a single glyph from a different font. If the document is already using the font, use

\fontchar{glyph}, e.g.
\fontchar{bullet.010}

to obtain the symbol. Accessing the glyphs directly from the font is a kind of low-level interface (see ConTeXt wiki - fontchar). To make it more usable, you can define a symbol (see ConTeXt wiki - definesymbol). Here is a complete example demonstrating that.

\definefontsynonym
  [minion]
  [name:minionproregular]

\definesymbol
  [leaf]
  [\getnamedglyphdirect
    {minion}
    {bullet.010}]

\starttext

Foo \symbol[leaf] Bar

\stoptext

result

3
  • Out of curiosity, do you know why \getnamedglyphdirect{FontName}{GlyphName} and \getnamedglyphdirect{FontName}{char_no} don't use square brackets? It seems inconsistent with usual Context conventions. Commented Feb 18, 2013 at 19:56
  • 1
    @C The idea is to use brackets for options and braces for typeset material, e.g. \in{section}[sec:foobar]. Though, many internal commands use braces because those macros are simpler to write (\def\foo#1#2#3{…}) and a little faster. Furthermore, braced arguments are more robust since they can be nested. Regarding this example if \getnamedglyphdirect would have used brackets for the font name, additional braces would be necessary since otherwise they would interfere with the brackets from \definesymbol. And, last but not least, sometimes it's just inconsistent and there's no real reason.
    – Marco
    Commented Feb 18, 2013 at 20:21
  • Thanks - the 2nd reason (nesting), in particular, is compelling. (And there was an error in my comment above: the 2nd example was meant to be \getglyph). Commented Feb 19, 2013 at 10:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .