[WASTE-list] monospace text

Chinh Nguyen cnguyen at stata.com
Mon May 21 19:14:44 EDT 2007



> Is using a monospaced font like Courier not sufficient to get

> uniform (and non-fractional) character widths?


No, and I only allow monospaced fonts.

As a test, I measured several lines of text using WEGetLineWidth().

For example, with a 12 point Monaco font, I get

a linewidth=7 charwidth=7.00
ab linewidth=14 charwidth=7.00
abcd linewidth=29 charwidth=7.25
aaaa linewidth=29 charwidth=7.25
1234 linewidth=29 charwidth=7.25
abcdefgh linewidth=58 charwidth=7.25
abcdefghijklmnopqrstuvwxyz0123456789!. linewidth=274 charwidth=7.22
abcdefghijklmnopqrstuvwxyz0123456789!.abcdefghijklmnopqrstuvwxyz01234567
89!. linewidth=547 charwidth=7.20

So you can see why my constraining logic no longer works.

I had a similar problem with my output engine which uses Core
Graphics for monospace text output and pixel relative drawing. I
solved it by using CGContextSetCharacterSpacing() so that all my
text lined up in uniform columns. I think I need something similar
in WASTE 3. For now, I think I'll just measure a bunch of characters
to get a decent char width stored as a float and use that for
calculating the constraint.

Thanks for the reply.

-Chinh Nguyen
cnguyen at stata.com



More information about the WASTE-list mailing list