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#
  4. How to get true Font size?

How to get true Font size?

Scheduled Pinned Locked Moved C#
helptutorialquestionlearning
3 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.
  • L Offline
    L Offline
    Libor Tinka
    wrote on last edited by
    #1

    Hello everyone, I'm back again... I'm working on some printing dialog with integrated preview. The problem is how to determine corrent font size (height) for the preview. Of course, the preview image size is measured in pixels, so for the A4 you have e.g 176x140 px large image. When I want to draw something on it with font of user-defined size in px, the preview size must be some N-times smaller. The key problem is how to get the N. Images are printed correctly, because I can convert its sizes in some useful units, like inches or percents, so they can be drawn with knowledge of document size in hundreths-per-inch units correctly. But with fonts, I can use only some Font.GetHeight(...) method, which returns (for my printer resolution) value of 186.8591 (inches or what :mad:?) for the 10px font.

    G C 2 Replies Last reply
    0
    • L Libor Tinka

      Hello everyone, I'm back again... I'm working on some printing dialog with integrated preview. The problem is how to determine corrent font size (height) for the preview. Of course, the preview image size is measured in pixels, so for the A4 you have e.g 176x140 px large image. When I want to draw something on it with font of user-defined size in px, the preview size must be some N-times smaller. The key problem is how to get the N. Images are printed correctly, because I can convert its sizes in some useful units, like inches or percents, so they can be drawn with knowledge of document size in hundreths-per-inch units correctly. But with fonts, I can use only some Font.GetHeight(...) method, which returns (for my printer resolution) value of 186.8591 (inches or what :mad:?) for the 10px font.

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      Specify the font size in points instead of pixels. One point is 1/72 of an inch. --- b { font-weight: normal; }

      1 Reply Last reply
      0
      • L Libor Tinka

        Hello everyone, I'm back again... I'm working on some printing dialog with integrated preview. The problem is how to determine corrent font size (height) for the preview. Of course, the preview image size is measured in pixels, so for the A4 you have e.g 176x140 px large image. When I want to draw something on it with font of user-defined size in px, the preview size must be some N-times smaller. The key problem is how to get the N. Images are printed correctly, because I can convert its sizes in some useful units, like inches or percents, so they can be drawn with knowledge of document size in hundreths-per-inch units correctly. But with fonts, I can use only some Font.GetHeight(...) method, which returns (for my printer resolution) value of 186.8591 (inches or what :mad:?) for the 10px font.

        C Offline
        C Offline
        Curtis Schlak
        wrote on last edited by
        #3

        You can use the Graphics.MeasureString( ... ) function to get the pixel height of a Font's output. "we must lose precision to make significant statements about complex systems." -deKorvin on uncertainty

        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