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

Bug solved for style font Bold, Italic and BoldItalic!!!
https://forum.pdfsharp.net/viewtopic.php?f=3&t=277
Page 1 of 1

Author:  Vyacheslav Popov [ Mon Dec 17, 2007 6:04 pm ]
Post subject:  Bug solved for style font Bold, Italic and BoldItalic!!!

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;
      }

Author:  Thomas Hoevel [ Tue Dec 18, 2007 10:39 am ]
Post subject:  Re: Bug solved for style font Bold, Italic and BoldItalic!!!

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"?

Author:  Vyacheslav Popov [ Tue Dec 18, 2007 11:21 am ]
Post subject: 

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

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