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 a list of System Font Sizes

Get a list of System Font Sizes

Scheduled Pinned Locked Moved C#
csharp
8 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.
  • H Offline
    H Offline
    hardsoft
    wrote on last edited by
    #1

    I want to have a dropdown combo box with a list of font sizes(point size) for the user to select from. The combo box is to be like that used in MS word etc. Is there a way to do this for any c# built in call or should I create the list myself by supplying the values to the combo box. Regards Jeff.

    H OriginalGriffO C 3 Replies Last reply
    0
    • H hardsoft

      I want to have a dropdown combo box with a list of font sizes(point size) for the user to select from. The combo box is to be like that used in MS word etc. Is there a way to do this for any c# built in call or should I create the list myself by supplying the values to the combo box. Regards Jeff.

      H Offline
      H Offline
      Henry Minute
      wrote on last edited by
      #2

      You could at least search the CP articles before asking, even if you do nothing else!! FontComboBox - a font listing combo box for .NET[^]

      Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

      C 1 Reply Last reply
      0
      • H Henry Minute

        You could at least search the CP articles before asking, even if you do nothing else!! FontComboBox - a font listing combo box for .NET[^]

        Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        Does this article somehow work out what font sizes are valid tho ? I googled, and it seemed to me that you couldn't work that out, so I didn't reply ( because I figured that someone else may know a way that I could not find )

        Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

        H 1 Reply Last reply
        0
        • H hardsoft

          I want to have a dropdown combo box with a list of font sizes(point size) for the user to select from. The combo box is to be like that used in MS word etc. Is there a way to do this for any c# built in call or should I create the list myself by supplying the values to the combo box. Regards Jeff.

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #4

          There is no "list of system font sizes" A font is size independant - you can use it at anny size you want 8, 8.25, 400, 73. You list box should just contain common sizes, and allow the user to select uncommon ones.

          No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          H X 2 Replies Last reply
          0
          • C Christian Graus

            Does this article somehow work out what font sizes are valid tho ? I googled, and it seemed to me that you couldn't work that out, so I didn't reply ( because I figured that someone else may know a way that I could not find )

            Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

            H Offline
            H Offline
            Henry Minute
            wrote on last edited by
            #5

            :-O It was late, I was tired, what can I say. My eyes totally skipped the size part of the question.

            Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

            1 Reply Last reply
            0
            • OriginalGriffO OriginalGriff

              There is no "list of system font sizes" A font is size independant - you can use it at anny size you want 8, 8.25, 400, 73. You list box should just contain common sizes, and allow the user to select uncommon ones.

              No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

              H Offline
              H Offline
              hardsoft
              wrote on last edited by
              #6

              Thank you for this info. I know what I need to do now.

              1 Reply Last reply
              0
              • H hardsoft

                I want to have a dropdown combo box with a list of font sizes(point size) for the user to select from. The combo box is to be like that used in MS word etc. Is there a way to do this for any c# built in call or should I create the list myself by supplying the values to the combo box. Regards Jeff.

                C Offline
                C Offline
                carlecomm
                wrote on last edited by
                #7

                it's very easy. C# code //get system fonts InstalledFontCollection MyFont=new InstalledFontCollection(); FontFamily[] MyFontFamilies=MyFont.Families; int Count=MyFontFamilies.Length; for(int i=0;i <Count;i++) { string FontName=MyFontFamilies[i].Name; this.comboBox1.Items.Add(FontName); } of course,I remember Win32 API have the funcation to get them.

                1 Reply Last reply
                0
                • OriginalGriffO OriginalGriff

                  There is no "list of system font sizes" A font is size independant - you can use it at anny size you want 8, 8.25, 400, 73. You list box should just contain common sizes, and allow the user to select uncommon ones.

                  No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced. This message is made of fully recyclable Zeros and Ones

                  X Offline
                  X Offline
                  xirisjohn
                  wrote on last edited by
                  #8

                  What that would appear true in theory, not all fonts can be rendered at all point sizes. For example, consider a Label "label1" with initial font "Microsoft Sans Serif" at point size 8.25.

                          Font f = new Font(label1.Font.FontFamily, label1.Font.SizeInPoints + 0.5f);
                          label1.Font = f;
                          label1.Text = label1.Font.SizeInPoints.ToString();
                  

                  Execute that code a few times (at least on my WinXP machine) via a button click or whatever, and the font's appearance at 9.25 and 9.75 are identical, as are 10.75 and 11.25, etc. Also, there is obviously some mapping going on, setting the font size to 8.0 results in 8.25, 10.0 to 9.75, etc. Is there any way of knowing, short of trial and error, if changing the point size by some amount will actually have impact on what is rendered?

                  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