PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Using Fonts in PDFSharp
https://forum.pdfsharp.net/viewtopic.php?f=2&t=3619
Page 1 of 1

Author:  Wfaz [ Mon Jul 03, 2017 11:19 pm ]
Post subject:  Using Fonts in PDFSharp

I have the font "Lucida Console Regular" installed on my system. It is a monospaced font. It shows up as a monospaced font in the Visual Studio IDE text boxes when it is used. For example, the txtWorkNote1 text box referenced below clearly shows a monospaced font used.
I have the following statement in my code ...
Dim FontC11R As XFont = New XFont("Lucida Console Regular", 11, XFontStyle.Regular)
I try to use the font as follows ...
tfmt.DrawString(txtWorkNote1.Text, FontC11R, XBrushes.Black, New XRect(iColNote, iLoc, iColPic - iMarginLeft - 1, page.Height.Point - iLoc - 20), XStringFormats.TopLeft)
No errors are thrown and everything seems to works fine except the pdf document does not use the font. The pdf document shows Arial; Arial,Bold; and MicrosoftSansSerif used in the Document Properties, and the printed text field uses proportional spacing.
Any ideas as to what I doing wrong?
Thanks, Bill

Author:  Wfaz [ Mon Jul 03, 2017 11:28 pm ]
Post subject:  Re: Using Fonts in PDFSharp

Hi all,
I figured out how to fix this ... the name of the font is "Lucida Console", not "Lucida Console Regular". Apparently PDFSharp just substitutes the wrong font instead of throwing an error. The document is now printing correctly.
Bill

Author:  TH-Soft [ Tue Jul 04, 2017 6:09 am ]
Post subject:  Re: Using Fonts in PDFSharp

Hi!
Wfaz wrote:
Apparently PDFSharp just substitutes the wrong font instead of throwing an error.
Some Windows functions always return a default font when asking for a non-existing font.
Do not guess font names, use them as shown in the Font applet (Control Panel) or e.g. Word.

Author:  Wfaz [ Tue Jul 04, 2017 12:18 pm ]
Post subject:  Re: Using Fonts in PDFSharp

Thanks, Thomas. All working now. Bill

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/