View previous topic :: View next topic |
Author |
Message |
Vyacheslav Popov
Joined: 23 Nov 2007 Posts: 18
|
Posted: 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
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;
}
|
|
|
Back to top |
|
|
Thomas Hoevel
Joined: 16 Oct 2006 Posts: 387 Location: Cologne, Germany
|
Posted: 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"? _________________ Regards
Thomas Hoevel
PDFsharp Team |
|
Back to top |
|
|
Vyacheslav Popov
Joined: 23 Nov 2007 Posts: 18
|
Posted: 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 |
|
Back to top |
|
|
|