Announcement

Collapse
No announcement yet.

charwidth not working for proportional strings

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • charwidth not working for proportional strings

    Hello,

    Been trying to write a function that centers text in a given area. To do this, I obviously need to know the number of pixels being used by the string being printed. I was hoping strwidth() would do this, but it doesn't. So I was writing my own, and was hoping charwidth() would give me the pixel values, but it doesn't either. They both say that they'll return the pixel number for proportional or monospaced strings/chars, but they always just return the max value (monospaced). I'm guessing this is a bug? Is there a workaround?

    I've been able to get a function working, but I have to supply it with a lot of the specific data, which is found in the font include file. Basically I ended up writing my own strwidth() function, the way it is supposed to work based on the values listed at the front of the BYTE array for the font.

    Am I wrong about how charwidth() and strwidth() are supposed to work? In the font.inc file, each character is preceded by the pixel width, however, calling charwidth() always returns the max value, found at font[3], similarly, strwidth() just returns that charwidth() value multiplied by the number of the characters in the string, which can be found with strlen().

  • #2


    whoops, just read this in the Font Tool manual :

    Output Format 2 must be selected for string-width or character-width functions on the GFX configured processor to work properly.

    I'll try that, probably the fix I'm looking for.

    Comment

    Working...
    X