Thread: GetCharWidth32() - does not support localized characters?

  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    34

    GetCharWidth32() - does not support localized characters?

    Hi,

    I am having trouble with GetCharWidth32() when I input a localized character like 'Ø' GetCharWith32() returns some redicilously large number. Also the character '¤' makes it go crazy. Is this a known problem, and is there any way to work around this? (An equivalent function, etc.)

    Thanks,
    Eirik

  2. #2
    Registered User
    Join Date
    Oct 2008
    Posts
    34
    Or am I running into a UNICODE vs ASCII problem here? (Yes, I am using ASCII, shame on me...)

  3. #3
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    It's not a TrueType font, by any chance?

    Is your character that you give to GetCharWidth32 an unsigned - if not, you may end up with a ridiculous character instead of what you expected.

    Also, you may want to try with the Unicode version (using the proper unicode character code of course). It is possible that you get some other character if you use ANSI.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  4. #4
    Registered User
    Join Date
    Oct 2008
    Posts
    34
    Hmm.. Arial is a TTF, right? If so, then yes. I have tried with the GetCharABCWidths() function too, but it didn't do any better. I'll try with the Unicode version, first.

  5. #5
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Depending on what you want to do....

    Have you looked at GetTextExtentPoint32() [and family].

    Calcs the actual width of a given string on a given HDC (with the enclosed font, style etc)
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Counting the characters from each word from a text file
    By flipguy_ph in forum C Programming
    Replies: 6
    Last Post: 04-27-2009, 05:56 PM
  2. problem with reading characters
    By csvraju in forum C Programming
    Replies: 4
    Last Post: 03-31-2009, 07:59 AM
  3. Removing Specific Characters from Strings
    By gfmartin05 in forum C++ Programming
    Replies: 4
    Last Post: 02-09-2009, 09:53 AM
  4. Counting characters
    By tay_highfield in forum C Programming
    Replies: 3
    Last Post: 01-29-2003, 12:54 PM
  5. printing non-ASCII characters (in unicode)
    By dbaryl in forum C Programming
    Replies: 1
    Last Post: 10-25-2002, 01:00 PM