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. Visual Basic
  4. Making a font bold at runtime

Making a font bold at runtime

Scheduled Pinned Locked Moved Visual Basic
questiongraphics
4 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
    Lost User
    wrote on last edited by
    #1

    Hi, I am trying to make a font bold at runtime but I can not work it out. I am currently changing the color of the font using: lblPageStatus.ForeColor = System.Drawing.Color.Red How can I do the same to make it bold? Thanks Shawn

    J 1 Reply Last reply
    0
    • L Lost User

      Hi, I am trying to make a font bold at runtime but I can not work it out. I am currently changing the color of the font using: lblPageStatus.ForeColor = System.Drawing.Color.Red How can I do the same to make it bold? Thanks Shawn

      J Offline
      J Offline
      Just Greeky Creek
      wrote on last edited by
      #2

      u have to need creating a new font, then use that. Dont forget The Bold property of any Font is ReadOnly Dim newFont as new Font (previousFont.Name, FontStyle.Bold ) lblPageStatus.Font=newFont

      L 1 Reply Last reply
      0
      • J Just Greeky Creek

        u have to need creating a new font, then use that. Dont forget The Bold property of any Font is ReadOnly Dim newFont as new Font (previousFont.Name, FontStyle.Bold ) lblPageStatus.Font=newFont

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

        Thanks for the reply. I will give that a go. It does seem a little odd that you have to create a new font to change the bold property, when you can just set a color without having to create a new font. Oh well. Thanks again! Shawn

        D 1 Reply Last reply
        0
        • L Lost User

          Thanks for the reply. I will give that a go. It does seem a little odd that you have to create a new font to change the bold property, when you can just set a color without having to create a new font. Oh well. Thanks again! Shawn

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          It's not odd if you understand the difference between selecting a font and drawing one. When you change the type to Bold, you're actually changing the shape of the Font. If the Font includes a bold version, then you're actually selecting a new font just by changing the style. For instance, a font can include a normal version of the character outlines, italics version, bold version, italics and bold version, underline, ... Now, if you selected a bold version of a font and the font file don't have a bold version, it can be calculated, or approximated. In either case, a new set of outline coordinates are used to draw the font. This is why properties like Bold are ReadOnly. Now, changing the color doesn't change the coordinates of the outlines that are drawn, so you can change the color all you want without regenerating the coordinates again. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

          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