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. Font Size Problem in Edit Control [SOLVED]

Font Size Problem in Edit Control [SOLVED]

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
9 Posts 3 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.
  • V Offline
    V Offline
    vishalgpt
    wrote on last edited by
    #1

    Hi to all, I am facing a strange problem, i had asked for help in the forum few days before. But due to certain delays i was unable to show the code. Here is the code. My Problem is with hindi fonts. When i substitute the the LOGFONT.lfHeight with 0(Zero) then everything works fine, But when i change the size of lfHeight to anything greater or lesser than zero, the Hindi fonts is displayed very small. How to solve this issue.

    case WM_INITDIALOG:
    LOGFONT lf;

    HFONT cFont;
    HWND target = GetDlgItem(hwnd,IDC\_STATIC1);
    HFONT hFont = (HFONT)GetStockObject(DEFAULT\_GUI\_FONT);
    GetObject(hFont, sizeof(LOGFONT), &lf);
    
    lf.lfHeight = 0;
    cFont = CreateFontIndirect(&lf);
    SendMessage(target,WM\_SETFONT,(WPARAM)cFont,MAKELPARAM(TRUE,0));
    SetWindowText(target,\_T("C:\\\\Program Files\\\\অভিধান: ইংরেজী\\\\सरकारी &&"));
    break;
    

    sorry for posting twice.

    Regards, Vishal

    modified on Thursday, June 9, 2011 1:32 PM

    L 1 Reply Last reply
    0
    • V vishalgpt

      Hi to all, I am facing a strange problem, i had asked for help in the forum few days before. But due to certain delays i was unable to show the code. Here is the code. My Problem is with hindi fonts. When i substitute the the LOGFONT.lfHeight with 0(Zero) then everything works fine, But when i change the size of lfHeight to anything greater or lesser than zero, the Hindi fonts is displayed very small. How to solve this issue.

      case WM_INITDIALOG:
      LOGFONT lf;

      HFONT cFont;
      HWND target = GetDlgItem(hwnd,IDC\_STATIC1);
      HFONT hFont = (HFONT)GetStockObject(DEFAULT\_GUI\_FONT);
      GetObject(hFont, sizeof(LOGFONT), &lf);
      
      lf.lfHeight = 0;
      cFont = CreateFontIndirect(&lf);
      SendMessage(target,WM\_SETFONT,(WPARAM)cFont,MAKELPARAM(TRUE,0));
      SetWindowText(target,\_T("C:\\\\Program Files\\\\অভিধান: ইংরেজী\\\\सरकारी &&"));
      break;
      

      sorry for posting twice.

      Regards, Vishal

      modified on Thursday, June 9, 2011 1:32 PM

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You need to convert the point height of your font into device units with the following formula:

      lFont.lfHeight = MulDiv(nFontHeight, GetDeviceCaps(hDC, LOGPIXELSY), 72);// height of font

      See the MSDN page for CreateFont()[^] for more information.

      The best things in life are not things.

      V 1 Reply Last reply
      0
      • L Lost User

        You need to convert the point height of your font into device units with the following formula:

        lFont.lfHeight = MulDiv(nFontHeight, GetDeviceCaps(hDC, LOGPIXELSY), 72);// height of font

        See the MSDN page for CreateFont()[^] for more information.

        The best things in life are not things.

        V Offline
        V Offline
        vishalgpt
        wrote on last edited by
        #3

        i am using

        -MulDiv(iPointSize,GetDeviceCaps(GetDC(target),LOGPIXELSY),72);

        Where iPointSize is the size of font; But, the results are not up-to mark. If i specify the

        lFont.lfHeight = 14

        then, the text in english font is ok but the text in hindi font seems like the lfHeight is 8. But if i specify the

        lFont.lfHeight = 0

        Whether hindi or bengali or chinese every font is in same height and looks good, but their sizes are big. I am using default MS Shell Dlg Font.

        Regards, Vishal

        L 1 Reply Last reply
        0
        • V vishalgpt

          i am using

          -MulDiv(iPointSize,GetDeviceCaps(GetDC(target),LOGPIXELSY),72);

          Where iPointSize is the size of font; But, the results are not up-to mark. If i specify the

          lFont.lfHeight = 14

          then, the text in english font is ok but the text in hindi font seems like the lfHeight is 8. But if i specify the

          lFont.lfHeight = 0

          Whether hindi or bengali or chinese every font is in same height and looks good, but their sizes are big. I am using default MS Shell Dlg Font.

          Regards, Vishal

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Try the positive value returned by MulDiv() and/or one of the other fonts, if possible one that was designed for Hindi characters.

          The best things in life are not things.

          V 1 Reply Last reply
          0
          • L Lost User

            Try the positive value returned by MulDiv() and/or one of the other fonts, if possible one that was designed for Hindi characters.

            The best things in life are not things.

            V Offline
            V Offline
            vishalgpt
            wrote on last edited by
            #5

            Yes sir, i had tried. Mangal gives positive result for hindi fonts. And Trebuchet MS for others. Sir, i have one small doubt. Do we have to distribute these fonts with application or these are system default fonts available on windows. and (negative) -MulDiv() gives good result instead of (postive) MulDiv(). Is it OK. Please guide.

            Regards, Vishal

            L I 2 Replies Last reply
            0
            • V vishalgpt

              Yes sir, i had tried. Mangal gives positive result for hindi fonts. And Trebuchet MS for others. Sir, i have one small doubt. Do we have to distribute these fonts with application or these are system default fonts available on windows. and (negative) -MulDiv() gives good result instead of (postive) MulDiv(). Is it OK. Please guide.

              Regards, Vishal

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              vishalgpt wrote:

              Please guide.

              I'm afraid I don't have the answer to these questions, you will have to investigate the rest for yourself.

              The best things in life are not things.

              V 1 Reply Last reply
              0
              • L Lost User

                vishalgpt wrote:

                Please guide.

                I'm afraid I don't have the answer to these questions, you will have to investigate the rest for yourself.

                The best things in life are not things.

                V Offline
                V Offline
                vishalgpt
                wrote on last edited by
                #7

                :) thanx.

                Regards, Vishal

                1 Reply Last reply
                0
                • V vishalgpt

                  Yes sir, i had tried. Mangal gives positive result for hindi fonts. And Trebuchet MS for others. Sir, i have one small doubt. Do we have to distribute these fonts with application or these are system default fonts available on windows. and (negative) -MulDiv() gives good result instead of (postive) MulDiv(). Is it OK. Please guide.

                  Regards, Vishal

                  I Offline
                  I Offline
                  Iain Clarke Warrior Programmer
                  wrote on last edited by
                  #8

                  From memory, a negative lfHeight means "points" as opposed to pixels, but you'd have to check the definitions on msdn for LOGFONT. Iain.

                  I am one of "those foreigners coming over here and stealing our jobs". Yay me!

                  V 1 Reply Last reply
                  0
                  • I Iain Clarke Warrior Programmer

                    From memory, a negative lfHeight means "points" as opposed to pixels, but you'd have to check the definitions on msdn for LOGFONT. Iain.

                    I am one of "those foreigners coming over here and stealing our jobs". Yay me!

                    V Offline
                    V Offline
                    vishalgpt
                    wrote on last edited by
                    #9

                    Iain Clarke, Warrior Programmer wrote:

                    From memory, a negative lfHeight means "points" as opposed to pixels

                    Thanx for the point. I will check the definitions :thumbsup:

                    Regards, Vishal

                    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