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. Get Font width in windows form

Get Font width in windows form

Scheduled Pinned Locked Moved C#
graphicsjsontutorialquestion
3 Posts 2 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
    Leo Smith
    wrote on last edited by
    #1

    I am working on a printing a report and need to know how to calculate the font width by device. Height is easy (font.GetHeight(graphics);), but there is not a similar setting for width. There used to be an API call (I think it was something like GetTextMatrix) that I used to determine the average width (letters like M and W were wider than letters like I and l). Is there something I can do to check before I start printing? or is there a way that if I ireate through the arrays I can tell what the maximum width are for each column before I start the print page routine. Thanks,

    Leo T. Smith Program/Analyst Supervisor

    E 1 Reply Last reply
    0
    • L Leo Smith

      I am working on a printing a report and need to know how to calculate the font width by device. Height is easy (font.GetHeight(graphics);), but there is not a similar setting for width. There used to be an API call (I think it was something like GetTextMatrix) that I used to determine the average width (letters like M and W were wider than letters like I and l). Is there something I can do to check before I start printing? or is there a way that if I ireate through the arrays I can tell what the maximum width are for each column before I start the print page routine. Thanks,

      Leo T. Smith Program/Analyst Supervisor

      E Offline
      E Offline
      Ennis Ray Lynch Jr
      wrote on last edited by
      #2

      Use the graphics context for the device and call MeasureString.

      Need a C# Consultant? I'm available.
      Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway

      L 1 Reply Last reply
      0
      • E Ennis Ray Lynch Jr

        Use the graphics context for the device and call MeasureString.

        Need a C# Consultant? I'm available.
        Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway

        L Offline
        L Offline
        Leo Smith
        wrote on last edited by
        #3

        Thanks, Leo

        Leo T. Smith Program/Analyst Supervisor

        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