Search code examples
openxmlopenxml-sdk

Can someone break down the Panose property for me?


I'm working with PowerPoint and I've got an element like this:

<a:latin typeface="Arial" panose="020B0604020202020204" pitchFamily="34" charset="0"/>

I understand conceptually that the panose property rolls up a bunch of properties in a coded string, but all the docs have this in a format that is not hex, like this value here. I tried converting this to decimal, but it yielded results that didn't line up with the panose domain, as far as I could tell.


Solution

  • Okay, I hammered on this for a while and figured it out, I think. That hex string in the panose property needs to be converted to a ten-byte array. I stole this answer to do that:

    Enumerable.Range(0, hex.Length)
                                 .Where(x => x % 2 == 0)
                                 .Select(x => Convert.ToByte(hex.Substring(x, 2), 16))
                                 .ToArray();
    

    Once you have that byte array, each position represents a different aspect of the custom font:

    1. Family Kind
    2. Serif Style
    3. Weight
    4. Proportion
    5. Contrast
    6. Stroke Variation
    7. Arm Style
    8. Letterform
    9. Midline
    10. X-height

    Keep in mind indexes, positions, and off-by-one errors there. Each has a value from 0 to 15 (natch), indicating different values for each font quality, which are enumerated here.

    The particular aspect I was focused on was font-weight, which is represented at position 3, index 2.