meyerweb.com

Skip to: site navigation/presentation
Skip to: Thoughts From Eric

Defining ‘ch’

I’m working my way through a rewrite of Two Salmon (more on that anon), and I just recently came to the ch unit.  Its definition in the latest CSS Values and Units module is as follows:

ch unit

Equal to the advance measure of the “0″ (ZERO, U+0030) glyph found in the font used to render it.

…and that’s it.  I had never heard the term “advance measure” before, and a bit of Googling for font "advance measure" only led me to copies of the CSS Values and Units module and some configuration files for the Panda 3D game engine.  So I asked the editor and it turns out that “advance measure” is a CSS-ism that corresponds to the term “advance width”, which I had also never heard before but which yielded way more Google results.  Wikipedia’s entry for “Font” has this definition:

Glyph-level metrics include … the advance width (the proper distance between the glyph’s initial pen position and the next glyph’s initial pen position)…

My question for the font geeks in the room is this:  is that the generally accepted definition for “advance width”?  If not, is there a better definition out there; and if so, where?  I’d like to be able to recommend the best known definition for inclusion in the specification; or, if there’s no agreement as to the best, then at least a good one.  The Wikipedia definition certainly sounds good, assuming it’s accurate.  Is it?

In CSS terms, if I’ve understood things correctly, 1ch is equal to the width of the character box for the glyph for “0”.  In other words, if I were to create a floated element with just a “0” and no whitespace between it and the element’s open and close tags, then the float’s width would be precisely 1ch.  But that’s if I’ve understood things correctly.  If I haven’t, I hope I’ll be corrected soon!

19 Responses»

    • #1
    • Comment
    • Tue 15 May 2012
    • 0956
    Moob wrote in to say...

    As I understand it the ‘advance width’ is the sum of the width of the glyph itself plus the space before (its left bearing) and the space after (its right bearing). Any kerning does not affect the advance width but will offset the character.

    I’m guessing that CSS line-spacing will not affect the ch unit value?

    • #2
    • Comment
    • Tue 15 May 2012
    • 1027
    Michael Zajac wrote in to say...

    Also, what are the letters CH supposed to stand for?

    • #3
    • Comment
    • Tue 15 May 2012
    • 1032
    FremyCompany wrote in to say...

    I worked on font metrics in a custom Math renderer application. The “advance width” is a very important feature of font glyphs, which indicate how far from the current glyph you should draw the next one.

    My definition of the “advance width” would be the following one: the “advance width” of a glyph is the horizontal space reserved by that glyph for its drawing. It’s equal to the width of the glyph which don’t interesect with previous and follwing glyphs reserved space. Its value equals the width of the glyph black box + its eventual left and right bearing (which can be negative).

    An illustration can be found on this page (scroll down until the picture show up) : http://msdn.microsoft.com/en-us/library/system.windows.media.glyphtypeface.aspx

    • #4
    • Comment
    • Tue 15 May 2012
    • 1033
    MikeNGarrett wrote in to say...

    Ch unit = Character Unit.
    I may have found something

    So this really means it’s for spacing braille.

    • #5
    • Comment
    • Tue 15 May 2012
    • 1037
    Matthew Douglass wrote in to say...

    FreeType’s docs at http://www.freetype.org/freetype2/docs/glyphs/glyphs-3.html cover this well. The image in that page also explains it visually (sorry, no way to get that URL on the iPad)

    Advance width is how far the pen moves between drawing characters. This does not correspond directly with how wide the character is, though I’m not 100% certain of CSS’ definition of character box width.

    Also, advance width is usually where kerning comes in (strictly speaking, kerning modifies the default advance width of a character). I’m assuming, though, that the CSS ch does not have kerning taken into account, since it’s the default advance width of a 0, not its advance width in relation to another character.

    • #6
    • Comment
    • Tue 15 May 2012
    • 1038
    Joshua wrote in to say...

    How do you even pronounce this unit? Same as with “church” or “chew”?

    “This element should be 10 tʃ wide.”

    • #7
    • Comment
    • Tue 15 May 2012
    • 1055
    Dusty wrote in to say...

    In practical terms, how would using ch differ from em?

    • #8
    • Comment
    • Tue 15 May 2012
    • 1100
    MikeNGarrett wrote in to say...

    As far as I can tell there’s no difference if it’s used for the intended purpose, ie spacing monospace and braille type.

    • #9
    • Comment
    • Tue 15 May 2012
    • 1312
    hoops wrote in to say...

    The Wikipedia entry is the best so far. The advance is simply a magnitude specified per glyph in the font. It is not a derived property. It is independent of the glyph contents. No two rendering engines will position glyphs in exactly the same location so the exact relationship between advance and position (if any) is a complex one. So…

    this is wrong
    > As I understand it the ‘advance width’ is the sum of the width of the glyph itself plus the space before (its left bearing) and the space after (its right bearing)

    as is this
    > the “advance width” of a glyph is the horizontal space reserved by that glyph for its drawing

    this might be true some of the time, depending on engine implementation
    > Advance width is how far the pen moves between drawing characters

    this might be true, but i don’t see anything requiring that it must be true
    > if I were to create a floated element with just a “0” and no whitespace between it and the element’s open and close tags, then the float’s width would be precisely 1ch

    • #10
    • Comment
    • Tue 15 May 2012
    • 1438
    Tab Atkins Jr wrote in to say...

    @MikeNGarrett: There is a difference – monospace fonts (of which braille fonts are a subset) all have the quality that their character widths are equal, but the ratio of character width to em box is *not* consistent between all such fonts.

    The ch unit lets you ignore the ratio and just use the width directly, so you know that exactly 40 characters will fit in a “width: 40ch;” box.

    • #11
    • Comment
    • Tue 15 May 2012
    • 1501
    MikeNGarrett wrote in to say...

    @Tab Atkins Jr Very interesting. I had no idea.

    • #12
    • Comment
    • Wed 16 May 2012
    • 0542
    Moob wrote in to say...

    @hoops please can you provide a link. http://en.wikipedia.org/wiki/Font defines the advance width as the proper distance between the glyph’s initial pen position and the next glyph’s initial pen position it makes no mention of this being independent of the glyph contents.

    This page about fontforge has some pertinent info but I’ve yet to find a clear definition.

    • #13
    • Pingback
    • Fri 18 May 2012
    • 0921
    Received from [Friday Links] The Move Edition

    [...] Defining ‘ch’ [...]

    • #14
    • Comment
    • Tue 22 May 2012
    • 1424
    Joe Clark wrote in to say...

    ch can also be used to produce a standard feature of typography that has been absent by definition all this time: Tab stops. Try laying out a screenplay without them.

    • #15
    • Comment
    • Tue 22 May 2012
    • 1821
    John Hudson wrote in to say...

    ‘Advance measure’ = ‘advance width’ = distance from the left sidebearing of a glyph to the right sidebearing of a glyph.

    As Tab notes, this is most useful in dealing with monospaced, ‘fixed width’ fonts, and I presume CSS defines ‘ch’ in terms of the width of the zero glyph arbitrarily so that for any font — at least, any font containing a glyph mapped to the zero character — a ‘ch’ value could be determined. Personally, I can’t see any use for ‘ch’ outside of the context of a monospaced font though, since outside of that context it doesn’t relate to much in the design space.

    • #16
    • Comment
    • Tue 22 May 2012
    • 1834
    Antonio Cavedoni wrote in to say...

    If you don’t just want to go by Wikipedia, another document that mentions the term “advance width” is the TrueType spec.

    • #17
    • Comment
    • Thu 24 May 2012
    • 0354
    Smylers wrote in to say...

    John Hudson:

    I presume CSS defines ‘ch’ in terms of the width of the zero glyph arbitrarily … Personally, I can’t see any use for ‘ch’ outside of the context of a monospaced font though

    There are several variable-width typefaces in which the digits 0 to 9 all have the same width as each other, so this could be useful in laying out numerical data in many fonts.

    • #18
    • Comment
    • Tue 29 May 2012
    • 0413
    Bert Vanderveen wrote in to say...

    Maybe using ch is THE way to ensure proper display of tabular material. You would define the lay-out in ch and it would be font-independent (some people and some browsers override css-font specs).

    • #19
    • Comment
    • Fri 15 Jun 2012
    • 1430
    A Nobody on the Internet wrote in to say...

    Personally, I can’t see any use for ‘ch’ outside of the context of a monospaced font though, since outside of that context it doesn’t relate to much in the design space.

    “ch” is a very handy unit when one is working with CJK entities (or any language that uses fullwidth form, for that matter).

Leave a Comment

Line and paragraph breaks automatic, e-mail address required but never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>



Remember to encode character entities if you're posting markup examples! Management reserves the right to edit or remove any comment—especially those that are abusive, irrelevant to the topic at hand, or made by anonymous posters—although honestly, most edits are a matter of fixing mangled markup. Thus the note about encoding your entities. If you're satisfied with what you've written, then go ahead...


May 2012
SMTWTFS
April June
 12345
6789101112
13141516171819
20212223242526
2728293031  

Sidestep

Feeds

Extras