Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. GetCharABCWidthsFloat returns different values on XP, Vista and Windows 7

GetCharABCWidthsFloat returns different values on XP, Vista and Windows 7

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
13 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    transoft
    wrote on last edited by
    #1

    Hi, GetCharABCWidthsFloat returns different values on XP, Vista and Windows 7. How can I solve this problem? Is there a workaround method to handle this? Best,

    C M 2 Replies Last reply
    0
    • T transoft

      Hi, GetCharABCWidthsFloat returns different values on XP, Vista and Windows 7. How can I solve this problem? Is there a workaround method to handle this? Best,

      C Offline
      C Offline
      Code o mat
      wrote on last edited by
      #2

      The size of characters can depend on a lot of things, how the given system renders the fonts, the DPI settings, what font you use of course, display drivers probably, and who knows what else. I supose the GetCharABCWidthsFloat is made to give the sizes based on the current "configuration", which is probalby not the exact same on those systems. Why is that a problem for you?

      > The problem with computers is that they do what you tell them to do and not what you want them to do. < > If it doesn't matter, it's antimatter.<

      T 2 Replies Last reply
      0
      • C Code o mat

        The size of characters can depend on a lot of things, how the given system renders the fonts, the DPI settings, what font you use of course, display drivers probably, and who knows what else. I supose the GetCharABCWidthsFloat is made to give the sizes based on the current "configuration", which is probalby not the exact same on those systems. Why is that a problem for you?

        > The problem with computers is that they do what you tell them to do and not what you want them to do. < > If it doesn't matter, it's antimatter.<

        T Offline
        T Offline
        transoft
        wrote on last edited by
        #3

        I used same "configuration." GetCharABCWidthsFloat returns different values on XP, Vista and Windows. You can have a test run. You will see it. Is there any GDI function call can do the same job? Thanks,

        1 Reply Last reply
        0
        • C Code o mat

          The size of characters can depend on a lot of things, how the given system renders the fonts, the DPI settings, what font you use of course, display drivers probably, and who knows what else. I supose the GetCharABCWidthsFloat is made to give the sizes based on the current "configuration", which is probalby not the exact same on those systems. Why is that a problem for you?

          > The problem with computers is that they do what you tell them to do and not what you want them to do. < > If it doesn't matter, it's antimatter.<

          T Offline
          T Offline
          transoft
          wrote on last edited by
          #4

          Just have a test run, you will see it. It will be a problem for you also. Thanks

          C 1 Reply Last reply
          0
          • T transoft

            Just have a test run, you will see it. It will be a problem for you also. Thanks

            C Offline
            C Offline
            Code o mat
            wrote on last edited by
            #5

            I don't doubt that it returns different sizes, i don't understand why you say it is a problem. I don't see the documentation stating that it will return the very same values "everywhere", it might return different values on the same operating system in different DPI settings. It is kind of like saying that GetVersionEx has a problem because it returns different values under different operating systems. Or i am completely missing your point here...

            > The problem with computers is that they do what you tell them to do and not what you want them to do. < > If it doesn't matter, it's antimatter.<

            T 1 Reply Last reply
            0
            • C Code o mat

              I don't doubt that it returns different sizes, i don't understand why you say it is a problem. I don't see the documentation stating that it will return the very same values "everywhere", it might return different values on the same operating system in different DPI settings. It is kind of like saying that GetVersionEx has a problem because it returns different values under different operating systems. Or i am completely missing your point here...

              > The problem with computers is that they do what you tell them to do and not what you want them to do. < > If it doesn't matter, it's antimatter.<

              T Offline
              T Offline
              transoft
              wrote on last edited by
              #6

              Yes, you completely miss my point here. Forget it.

              1 Reply Last reply
              0
              • T transoft

                Hi, GetCharABCWidthsFloat returns different values on XP, Vista and Windows 7. How can I solve this problem? Is there a workaround method to handle this? Best,

                M Offline
                M Offline
                MicroVirus
                wrote on last edited by
                #7

                First off, I agree with Code-o-mat. Actually the function isn't the problem here. It does exactly what it is supposed to do, namely (from MSDN): "[..] retrieves the widths, in logical units, of consecutive characters in a specified range from the current font." Now this value logically varies with different fonts, but also with different settings and different draw APIs. So what exactly is the problem you are having? You only say that you think the function is supposed to work differently. What do you think it should do then? That's where your problem lies: the function and what you are expecting of it are not in tandem.

                T 1 Reply Last reply
                0
                • M MicroVirus

                  First off, I agree with Code-o-mat. Actually the function isn't the problem here. It does exactly what it is supposed to do, namely (from MSDN): "[..] retrieves the widths, in logical units, of consecutive characters in a specified range from the current font." Now this value logically varies with different fonts, but also with different settings and different draw APIs. So what exactly is the problem you are having? You only say that you think the function is supposed to work differently. What do you think it should do then? That's where your problem lies: the function and what you are expecting of it are not in tandem.

                  T Offline
                  T Offline
                  transoft
                  wrote on last edited by
                  #8

                  "You only say that you think the function is supposed to work differently." I did not say "I think". I actually tried the function and got the results. I tried on different machine (XP, VISTA, WIN 7). I used exact same configuration. But I got different results. Thank you for your time to answer the question. If you want to know what I mean you might need to try this function call on different machine. Then you will get what I got. My question is very simple "GetCharABCWidthsFloat returns different values on XP, Vista and Windows 7, why?". You guy make it complicate. Best,

                  J C enhzflepE 3 Replies Last reply
                  0
                  • T transoft

                    "You only say that you think the function is supposed to work differently." I did not say "I think". I actually tried the function and got the results. I tried on different machine (XP, VISTA, WIN 7). I used exact same configuration. But I got different results. Thank you for your time to answer the question. If you want to know what I mean you might need to try this function call on different machine. Then you will get what I got. My question is very simple "GetCharABCWidthsFloat returns different values on XP, Vista and Windows 7, why?". You guy make it complicate. Best,

                    J Offline
                    J Offline
                    jeron1
                    wrote on last edited by
                    #9

                    Maybe this[^]link will help?

                    T 1 Reply Last reply
                    0
                    • J jeron1

                      Maybe this[^]link will help?

                      T Offline
                      T Offline
                      transoft
                      wrote on last edited by
                      #10

                      Thank you for the link. I found the link before I post my question. I am thinking is there a workaround method instead of changing the Windows' setting. It looks like it is only solution. MS should design a new function call like GetCharABCWidthsFloatEx to allow user to specify it is a standard or ClearType font and with a default value "standard". Best,

                      1 Reply Last reply
                      0
                      • T transoft

                        "You only say that you think the function is supposed to work differently." I did not say "I think". I actually tried the function and got the results. I tried on different machine (XP, VISTA, WIN 7). I used exact same configuration. But I got different results. Thank you for your time to answer the question. If you want to know what I mean you might need to try this function call on different machine. Then you will get what I got. My question is very simple "GetCharABCWidthsFloat returns different values on XP, Vista and Windows 7, why?". You guy make it complicate. Best,

                        C Offline
                        C Offline
                        Charles Oppermann
                        wrote on last edited by
                        #11

                        transoft wrote:

                        I did not say "I think". I actually tried the function and got the results. I tried on different machine (XP, VISTA, WIN 7). I used exact same configuration. But I got different results.

                        But it's not the same configuration - it's a different platform and there is no way it can be the same video drivers. Windows is constantly changing how text is drawn. ClearType, NTDDI, and changes to the fonts themselves mean that there might be different values. Are we talking about large differences in the return values? Maybe as a test, you can write a string, and measure the bounding rectangle and see if it's different on each platform.

                        /* Charles Oppermann */ http://weblogs.asp.net/chuckop

                        1 Reply Last reply
                        0
                        • T transoft

                          "You only say that you think the function is supposed to work differently." I did not say "I think". I actually tried the function and got the results. I tried on different machine (XP, VISTA, WIN 7). I used exact same configuration. But I got different results. Thank you for your time to answer the question. If you want to know what I mean you might need to try this function call on different machine. Then you will get what I got. My question is very simple "GetCharABCWidthsFloat returns different values on XP, Vista and Windows 7, why?". You guy make it complicate. Best,

                          enhzflepE Offline
                          enhzflepE Offline
                          enhzflep
                          wrote on last edited by
                          #12

                          I saw this question about a minute after you posted it. Having never heard of the function before I started looking into it, finding as others have mentioned that the values are supposed to depend on a number of different things. Immediately, I set to work whipping up an application to test the function. No matter what I thought of to try,I couldn't get the vales returned to change. I ran the app both under XP 32 bit and Win7 64 bit. Each OS returned the same values, as did each font I tried (only tried 2) as did each font-size and weight I tried. Win7 has clear-type enabled, XP doesn't. Win7 running on my laptop, XP running in a virtual machine on the same laptop. This made it clear to me that I wasn't qualified to even begin to answer your question. Though, still I couldn't help wondering why it was such a problem. Surely different conditions would mean that the mapping between logical width and number of pixels would change. Take for example, the dialog units that are used. (on dialogs, oddly enough) These vary based upon the size of the chosen dialog font. This allows an app to continue to look right whether your default text size is 11pt and you use it as a desktop 1 foot in front of you, or if you have text-size set to 30pt and you use it as a media-pc, hooked up to your telly. This is one of the differences between regular windows and media-center edition - the default text size. I would suggest that you mention why it matters to you if the function returns different values. There is after all, a transformation that happens to these values before they are ultimately used, so why can't you also do this transformation before you do your calculations? The clearer you make your problem, the more likely you are to get a solution that's a good fit!

                          T 1 Reply Last reply
                          0
                          • enhzflepE enhzflep

                            I saw this question about a minute after you posted it. Having never heard of the function before I started looking into it, finding as others have mentioned that the values are supposed to depend on a number of different things. Immediately, I set to work whipping up an application to test the function. No matter what I thought of to try,I couldn't get the vales returned to change. I ran the app both under XP 32 bit and Win7 64 bit. Each OS returned the same values, as did each font I tried (only tried 2) as did each font-size and weight I tried. Win7 has clear-type enabled, XP doesn't. Win7 running on my laptop, XP running in a virtual machine on the same laptop. This made it clear to me that I wasn't qualified to even begin to answer your question. Though, still I couldn't help wondering why it was such a problem. Surely different conditions would mean that the mapping between logical width and number of pixels would change. Take for example, the dialog units that are used. (on dialogs, oddly enough) These vary based upon the size of the chosen dialog font. This allows an app to continue to look right whether your default text size is 11pt and you use it as a desktop 1 foot in front of you, or if you have text-size set to 30pt and you use it as a media-pc, hooked up to your telly. This is one of the differences between regular windows and media-center edition - the default text size. I would suggest that you mention why it matters to you if the function returns different values. There is after all, a transformation that happens to these values before they are ultimately used, so why can't you also do this transformation before you do your calculations? The clearer you make your problem, the more likely you are to get a solution that's a good fit!

                            T Offline
                            T Offline
                            transoft
                            wrote on last edited by
                            #13

                            Thank you so much for spending so much time on this. I really appreciate it. Actually, I have a solution (Don't use clear-type font) for it now. The reason I post my question here is that I want to find a workaround for this. I hate to change Windows setting every time when I start to use my software. Right now it looks like it is impossible without changing Windows setting. Best regards,

                            1 Reply Last reply
                            0
                            Reply
                            • Reply as topic
                            Log in to reply
                            • Oldest to Newest
                            • Newest to Oldest
                            • Most Votes


                            • Login

                            • Don't have an account? Register

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • World
                            • Users
                            • Groups