1

I want to display (a WIDE-HEADED LEFTWARDS HEAVY BARB ARROW Symbol) in a PrintDocument. It does not render correctly; it only shows a box. Using Windows Forms with vb.net 4.6; Visual Studio 2017.

I know I have the correct character and font because it displays in a button just fine on the form. Yet in the PrintPreviewDialog it won't render correctly. What do I need to do?

Public WithEvents Doc As New PrintDocument

Public Sub ShowDialog()

    'page settings
    Me.Doc.DefaultPageSettings = ... set letter size, default printer, margins
    Me.Doc.PrinterSettings = ...default printer
    Me.Doc.DefaultPageSettings.PaperSize.RawKind = PaperKind.Letter
    
    'show dialog
    Dim dlgPreview As New PrintPreviewDialog
    dlgPreview.Document = Me.Doc
    dlgPreview.WindowState = FormWindowState.Maximized
    dlgPreview.ShowDialog()

End Sub

Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs) Handles Doc.PrintPage

    Dim arrow As String = Char.ConvertFromUtf32(&H1F87A)
    Dim f As New System.Drawing.Font("Microsoft Sans Serif", 11, FontStyle.Regular)
    e.Graphics.DrawString(arrow, f, Brushes.Black, 100, 100)

End Sub
D_Bester
  • 5,723
  • 5
  • 35
  • 77
  • 1
    Read about the Font Fallback feature here: [How can a Label control display Japanese characters properly when the Font used doesn't support this language?](https://stackoverflow.com/a/51612395/7444103) -- This applies to Controls, printing text as graphic doesn't cause a font fallback. – Jimi Nov 30 '21 at 00:56
  • Use the [Wingdings](https://en.wikipedia.org/wiki/Wingdings) font. Char `&HE7`. – dr.null Nov 30 '21 at 03:09
  • 1
    Or the `Segoe MDL2 Assets`, char `&HF0D5`. – dr.null Nov 30 '21 at 03:24

1 Answers1

1

By looping through all my installed fonts I was able to find a font that displays the correct character. In my case it was "Segoe UI Symbol".

D_Bester
  • 5,723
  • 5
  • 35
  • 77