No announcement yet.

DXF, Glyphs, and everything...

  • Filter
  • Time
  • Show
Clear All
new posts

  • DXF, Glyphs, and everything...

    I'm not sure anyone's into writing translators, but here goes. With everyone's help, I've managed to write some code that spits out the XY coordinates for the outline that describes a particular character in a particular typeface. So, in a nutshell, I've got the 'font to XY points' part of my app working.

    In terms of the other part - the looking at a dxf file part - I've pretty much got the 'what font was used for this text entity' part working. Also note that each text entity has a 'height' associated with it.

    Now here's the mind boggling part. No matter how many ways I've combined character cell, Glyph, etc. metrics, I can't seem to mathematically relate a Glyph to what's shown on the CAD screen. For example, if I put an Arial 'A' and a Times New Roman 'a' on the screen using the same font size, I get a height of 0.15972 and 0.15, respectively, in the dxf file. If I scale these by 10000 for use in a CreateFont call, I get a character cell of 953 x 1597 for the 'A', and 601 x 1500 for the 'a'. All is fine so far because the heights are essentially 10000 times what was shown in the dxf file. However, this is just the character cell - what I'm interested in is the glyph within the cell. So, when I look at the Glyph metrics, I get a blackbox of 956 x 1023 for the 'A', and 550 x 637 for the 'a'. Here's where the first problem occurs:

    When I go into the CAD app, and bound the 'A' with a rectangle, I get an aspect ratio of 1.0463. The glyph blackbox reported above is 1.0700, however. If I do the same for the 'a', I get 1.1583 vs 1.1582, which is in much better agreement. So, what's up with the 'A'? Beats me.

    There's more, but as you can see, if something as simple as the aspect ratio of the blackbox can't even agree with what's shown on the screen, I probably have little chance of getting placement as well as other things correct.

    So, any thoughts on the puzzle?