PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Fri Feb 28, 2020 3:46 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Dec 17, 2007 6:04 pm 
Offline

Joined: Fri Nov 23, 2007 12:10 pm
Posts: 18
Bug solved for style font Bold, Italic and BoldItalic!!!

File: PdfFontTable.cs
Class: PdfSharp.Pdf.Advanced.PdfFontTable.FontSelector
Method: Constructor
Line: 208

UPDATED :D
Code:
      public FontSelector(XFont font)
      {
        this.name = font.Name;
        // Ignore Strikeout and Underline
        if (font.FontFamily.IsStyleAvailable(XFontStyle.Bold & XFontStyle.Italic))
            this.style = XFontStyle.Regular;
        else if (font.FontFamily.IsStyleAvailable(XFontStyle.Bold))
            this.style = XFontStyle.Bold;
        else if (font.FontFamily.IsStyleAvailable(XFontStyle.Italic))
            this.style = XFontStyle.Italic;
        else
            this.style = XFontStyle.BoldItalic;

        this.fontType = font.Unicode ? FontType.Type0 : FontType.TrueType;
      }


ORIGINAL WITH BUG :(
Code:
      public FontSelector(XFont font)
      {
        this.name = font.Name;
        // Ignore Strikeout and Underline
        this.style = font.Style & (XFontStyle.Bold | XFontStyle.Italic);
        // Clear styles that are not available to prevent embedding of identical font files
        if ((this.style & XFontStyle.Bold) == XFontStyle.Bold && !font.FontFamily.IsStyleAvailable(XFontStyle.Bold))
          this.style &= ~XFontStyle.Bold;
        if ((this.style & XFontStyle.Italic) == XFontStyle.Italic && !font.FontFamily.IsStyleAvailable(XFontStyle.Italic))
          this.style &= ~XFontStyle.Italic;

        this.fontType = font.Unicode ? FontType.Type0 : FontType.TrueType;
      }


Top
 Profile  
Reply with quote  
PostPosted: Tue Dec 18, 2007 10:39 am 
Offline
PDFsharp Guru
User avatar

Joined: Mon Oct 16, 2006 8:16 am
Posts: 3027
Location: Cologne, Germany
Vyacheslav Popov wrote:
Bug solved for style font Bold, Italic and BoldItalic!!!
Code:
[...]
        if (font.FontFamily.IsStyleAvailable(XFontStyle.Bold & XFontStyle.Italic))
            this.style = XFontStyle.Regular;
[...]


Is it a bug or a feature? You set Regular if Bold and Italic are available? Or is there a "!" missing? Or do we have to swap "Regular" and "BoldItalic"?

_________________
Regards
Thomas Hoevel
PDFsharp Team


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Dec 18, 2007 11:21 am 
Offline

Joined: Fri Nov 23, 2007 12:10 pm
Posts: 18
Yes, Is bug... but, this bug is of GDI+ framework or Microsoft example error
I check state of diferent fonts family, and result is:


Font1: Regular
FontStyle.Bold = true
FontStyle.Italic = true
FontStyle.Regular = true

Font2: Bold
FontStyle.Bold = true
FontStyle.Italic = false
FontStyle.Regular = false

Font3: Italic
FontStyle.Bold = false
FontStyle.Italic = true
FontStyle.Regular = false

Font4: BoldItalic
FontStyle.Bold = false
FontStyle.Italic = false
FontStyle.Regular = false

Therefore, the condition changes and example of microsoft is FAIL
http://msdn2.microsoft.com/en-us/library/y505zzfw(VS.80).aspx


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 9 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