Site Tools

RhPicture Plug-in GDI Font Object

Summary: A description of the GDI Font object as exposed through the RhPicture plug-in

GDI+ Font objects

GDI+ Font objects are required when GDI+ is drawing Text. The GDI+ Font object is quite extensive and some of its features are also available through the RhPicture plug-in:

  • Name
  • Height
  • Bold flag
  • Italic flag
  • Underline flag

Properties not available in the RhPicture font object:

  • FontFamily declaration
  • GDICharSet flag
  • GDIVerticalFont flag
  • Font Units other than points
  • StrikeOut flag

Most of these properties are self-evident and need little elaboration. Note that you do not need Font objects to draw Strings in the RhPicture plug-in. Every method that takes a Fnt object is overloaded and can be called with a font name as well:

Dim RhPicture : Set RhPicture = Rhin.GetPluginObject("RhPicture")
Call RhPicture.CreateImage(50, 50, vbWhite)
Call RhPicture.DrawString("Bacon Cheeseburger.", Array(5,5), "Courier", vbRed)

If you want to specify further properties, you'll have to use an RhPicture Font object. You can obtain a Font object by calling the Font creation method on RhPicture:

Dim RhPicture : Set RhPicture = Rhin.GetPluginObject("RhPicture")
Call RhPicture.CreateImage(50, 50, vbWhite)
Dim FontObj : Set FontObj = RhPicture.CreateFont("Courier", 15, True, True)
Call RhPicture.DrawString("Hold the pickles.", Array(5,5), FontObj, vbRed)

Note that you can store any number of Font objects in your script and you can reuse them as often as you like. Font objects are not bound to the RhPicture instance that created them and you can use them on any RhPicture object. There is only one Font creation methods available:

RhPicture.CreateFont(Optional FontName As String = "Arial", _
                     Optional FontSize As Double = 12.0, _
                     Optional Bold As Boolean = False, _
                     Optional Italic As Boolean = False, _
                     Optional Underline As Boolean = False) As GDIFont
Parameter Type Description
FontName String The name of a font which exists on the local machine. Safe bets are Arial, Courier and Times.
FontSize Double The height of the font in points.
Bold Boolean True for bold fonts.
Italic Boolean True for italic fonts.
Underline Boolean True for underlined fonts.
developer/rhpicture/gdifont.txt ยท Last modified: 2020/08/14 (external edit)