Writing Varying-Font Text to an RTF File

  • Thread starter Thread starter Phil Galey
  • Start date Start date
P

Phil Galey

From VB.NET, I need to write text to an RTF file, where most of it is words
in one font like arial, but a couple of individual characters along the way
are of a different font, e.g. a solid diamond from the ZapfDingbats font or
a square from the GeographicSymbols font. So it needs to switch fonts four
times along the way.

Does anyone know how this can be done in VB.NET? Thanks.
 
Here's a quick example:

Dim rtb As New RichTextBox
rtb.Text = "This is alpha - a."
rtb.SelectAll()
rtb.SelectionFont = New Font(New FontFamily("Arial"), 12, FontStyle.Regular,
GraphicsUnit.Pixel)
rtb.Select(16, 1)
rtb.SelectionFont = New Font(New FontFamily("Symbol"), 12,
FontStyle.Regular, GraphicsUnit.Pixel)
rtb.SaveFile("test.rtf")


Brian Davis
http://www.knowdotnet.com
 
Back
Top