Hi Thomas,
I am doing this now, but I get an error message in a popup: "Value differs from information retrieved from font image."
I have never really come across an error like this whilst using PdfSharp/MigraDoc.
The font I am trying to add to my private fonts is "SimHei". I am loading it in using the following function:
Code:
public void LoadFonts(Boolean isEmbedded)
{
Stream fontStream;
PrivateFonts = new XPrivateFontCollection();
if (isEmbedded)
{
Assembly a = Assembly.GetExecutingAssembly();
string[] resNames = a.GetManifestResourceNames();
int streamLen = 0;
int i = 0;
foreach (string s in resNames)
{
if (s.EndsWith(".ttf"))
{
fontStream = a.GetManifestResourceStream(s);
streamLen = Convert.ToInt32(fontStream.Length);
byte[] fontData = new byte[fontStream.Length];
fontStream.Read(fontData, 0, streamLen);
fontStream.Close();
PrivateFonts.AddMemoryFont(fontData, fontData.Length, resNames[i], false, false);
}
i++;
}
}
else
{
}
}
and I am ying to use it here:
Code:
Font _font = MigFont.Clone();
if (Utils.CheckIsChinese(element.text))
{
_font = new Font(PrivateFonts.PrivateFontCollection.Families[0].Name); // Here specifically
}
_font.Bold = element.format.bold;
_font.Italic = element.format.italic;
_font.Size = element.format.size;
_font.Underline = element.format.underlined;
I dont really understand why this is occuring? The font is fine when accessed from my machine (i.e. it is installed, rather than loading it in at run time through the PrivateFonts)
any ideas?
Mike