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

Embedded Fonts
https://forum.pdfsharp.net/viewtopic.php?f=2&t=1050
Page 1 of 1

Author:  KEVINAKI [ Thu Feb 11, 2010 1:04 am ]
Post subject:  Embedded Fonts

I am trying to use uninstalled fonts i) from a TTF file and ii) from a resource file
I am using VS2005 (C# Version 2);
I cannot understand what is going on in the sourcecode of PrivateFonts
Can you explain how to do this, with some sample code?
Thanks a lot!
Kevin(aki)

Author:  Thomas Hoevel [ Tue Feb 16, 2010 10:32 am ]
Post subject:  Re: Embedded Fonts

Look at the PDFsharp PrivateFonts sample.
http://www.pdfsharp.net/wiki/PrivateFonts-sample.ashx

viewtopic.php?f=2&t=832

Author:  Thomas Hoevel [ Tue Feb 16, 2010 11:00 am ]
Post subject:  Re: Embedded Fonts

Fonts must be added to XPrivateFontCollection.Global and will be used automatically.

Author:  KEVINAKI [ Thu Feb 18, 2010 9:22 pm ]
Post subject:  Re: Embedded Fonts

I tried to use PrivateFonts: I think you have some VS2008 specific code (does not compile in 2005);
I tried substituting 'var' and calling AddFont and it crashed at runtime;
Do you have a sample in VS2005: I am not really sure what is happening in the code;
Thanks

Author:  Thomas Hoevel [ Mon Feb 22, 2010 9:09 am ]
Post subject:  Re: Embedded Fonts

The sample uses WPF - and WPF requires AFAIK VS 2008.

For a GDI+ sample, please download PDFsharp 1.2 (the sample is not included in the sample solution, but it's in the samples folder).

Author:  ganpp [ Fri Feb 26, 2010 11:20 pm ]
Post subject:  Re: Embedded Fonts

Thomas,

I am trying to add private fonts. sample code

PdfDocument doc = new PdfDocument();
PdfPage page = doc.AddPage();
XGraphics gfx = XGraphics.FromPdfPage(page);
XPrivateFontCollection fnt = XPrivateFontCollection.Global;
fnt.Add(new Uri("C:\\Windows\\Fonts\\CCHSYM2.TTF"), "#CCHSymbolTwo");
XFontStyle styleToUse = XFontStyle.Regular;
XColor glyphColor = XColor.FromArgb(000);
XBrush glyphBrush = new XSolidBrush(glyphColor);
XStringFormat textFormat = XStringFormats.Default;
XPdfFontOptions fontOptions = new XPdfFontOptions(PdfFontEncoding.WinAnsi, PdfFontEmbedding.Default);
XFont fontToUse = new XFont("CCHSymbolTwo", 1, styleToUse, fontOptions);
gfx.DrawString("d", fontToUse,
glyphBrush, 140, 140,
XStringFormats.Default);
doc.Save("c:\\xaml\\sharp.pdf");


I am getting Assertion from the file opentypedescriptor.cs (193)

Err: Pdf Sharp internal: Ascender should be less than 0

Author:  Thomas Hoevel [ Mon Mar 01, 2010 9:13 am ]
Post subject:  Re: Embedded Fonts

ganpp wrote:
I am getting Assertion from the file opentypedescriptor.cs (193)

If it works, ignore (or comment) the assertion.

Author:  ganpp [ Mon Mar 01, 2010 11:20 pm ]
Post subject:  Re: Embedded Fonts

Thomas,

These are special fonts like checkbox. Yes, I ignored the assertion and it works. I add it XForm and add it to a page.


Thx,
Ganesh

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