PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 11:36 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Using Fonts in PDFSharp
PostPosted: Mon Jul 03, 2017 11:19 pm 
Offline

Joined: Mon Jul 03, 2017 11:06 pm
Posts: 3
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


Top
 Profile  
Reply with quote  
PostPosted: Mon Jul 03, 2017 11:28 pm 
Offline

Joined: Mon Jul 03, 2017 11:06 pm
Posts: 3
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


Top
 Profile  
Reply with quote  
PostPosted: Tue Jul 04, 2017 6:09 am 
Offline
PDFsharp Expert
User avatar

Joined: Sat Mar 14, 2015 10:15 am
Posts: 909
Location: CCAA
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.

_________________
Best regards
Thomas
(Freelance Software Developer with several years of MigraDoc/PDFsharp experience)


Top
 Profile  
Reply with quote  
PostPosted: Tue Jul 04, 2017 12:18 pm 
Offline

Joined: Mon Jul 03, 2017 11:06 pm
Posts: 3
Thanks, Thomas. All working now. Bill


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 156 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group