PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Sun Jun 30, 2024 10:19 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
PostPosted: Mon Nov 04, 2013 1:05 pm 
Offline

Joined: Mon Nov 04, 2013 12:58 pm
Posts: 8
hello,

getting on well with pdfsharp but have hit a problem - how do i access the light cut of a font?!

Code:
var fontMiso30 = new XFont("miso", 30, XFontStyle.Regular);


the 'XFontStyle' enum only has regular, bold, italic, bolditalic, underline and strikeout...

i've got miso.ttf, miso-bold.ttf and miso-light.ttf insatlled on the machine - i can hit regular and bold, but no light!

any clues? my thinking is i need to get into the guts of the code, add light as an option in the 'XFontStyle' enum, update any related code?

cheers,

jake


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 04, 2013 2:07 pm 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3100
Location: Cologne, Germany
Hi!

I tried the three fonts with WordPad and MS Word.
WordPad doesn't show the light version at all.
With MS Word I see all three version, but I can use only 2 of them.

Word can't use them, therefore I'm afraid it won't be simple to make PDFsharp use them. Changing the enum is less than the tip of the ice cube.

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
PostPosted: Wed Nov 06, 2013 4:27 pm 
Offline

Joined: Mon Nov 04, 2013 12:58 pm
Posts: 8
interesting... just tried and got the same issue... seems windows just cant access that cut of the font. weird.

i'll keep digging and post back if i find an answer.

thanks for the reply!


Top
 Profile  
Reply with quote  
PostPosted: Mon Nov 11, 2013 12:53 pm 
Offline

Joined: Mon Nov 04, 2013 12:58 pm
Posts: 8
ok, did some more digging - the solution was to add a 'PrivateFontCollection'.

Code:
var globalFontCollection = XPrivateFontCollection.Global;
var uri = new Uri("file:///C:/pathToYourFont/miso.ttf");
const string name = "./#Miso Light";
globalFontCollection.Add(uri, name);


this allows me to access the light cut of the font using this for PdfSharp using a DrawString:

Code:
new XFont("Miso Light", 12, XFontStyle.Regular);


and this for MigraDoc:

Code:
var doc = new Document();
var sec = doc.AddSection();
var para = sec.AddParagraph();
para.Format.Alignment = ParagraphAlignment.Right;
para.Format.Font.Name = "Miso Light";
para.Format.Font.Size = 11;
para.Format.Font.Color = MigraDoc.DocumentObjectModel.Colors.DarkGray;


hope this helps someone out there ;)

cheers,

jake


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: Google [Bot] and 68 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:  
cron
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group