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

Support for simulated bold
https://forum.pdfsharp.net/viewtopic.php?f=4&t=778
Page 1 of 1

Author:  robert_baumann [ Tue Jul 07, 2009 12:26 am ]
Post subject:  Support for simulated bold

When will support for simulated bold be available? How might this be accomplished?

PdfContentWriter.cs (235):
//if (bold && !descriptor.IsBoldFace)
//{
// // TODO: emulate bold by thicker outline
//}

//if (italic && !descriptor.IsBoldFace)
//{
// // TODO: emulate italic by shearing transformation
//}

Author:  robert_baumann [ Tue Jul 07, 2009 11:43 pm ]
Post subject:  Re: Support for simulated bold

Update: Here's the code in XGraphicsPdfRenderer which will simulate bold, because windows will create the font simulation when it generates the path:

if (bold && !descriptor.IsBoldFace)
{
// TODO: emulate bold by thicker outline --- DONE!
XGraphicsPath path = new XGraphicsPath();
path.AddString(s, font.FontFamily, font.Style,
font.Size, rect,
format);
XSolidBrush fontBrush = (XSolidBrush)brush;

gfx.DrawPath(brush, path);
return;
}

Author:  zanadar [ Tue Apr 23, 2013 6:32 am ]
Post subject:  Re: Support for simulated bold

If you want to keep the text as selectable text instead of a graphic you can also do the following:

//XGraphicsPdfRenderer.cs line 504
if (bold && !descriptor.IsBoldFace)
{
byte[] bytes = PdfEncoders.WinAnsiEncoding.GetBytes( s );
XPoint pos = new XPoint( x + 0.5, y );
AdjustTextMatrix( ref pos );
AppendFormat(
"{0:0.####} {1:0.####} Td {2} Tj\n", pos.x, pos.y,
PdfEncoders.ToStringLiteral( bytes, false, null ) );
}

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