The help is little bit scarce on registering a font: see http://docs.telerik.com/devtools/wpf/controls/radpdfprocessing/concepts/fonts
There is a data parameter at the end, which should contain the raw data for the font. Looking for more information about the subject I came across https://github.com/telerik/xaml-sdk/blob/f5002a15eb1def98405472bee700f20ad8b65cc9/SpreadProcessing/RegisterAndExportPdfFonts.Web/PdfFontsService.svc.cs where
public class FontData {
public bool IsValid { get; set; }
public byte[] Bytes { get; set; }
public string FontFamilyName { get; set; }
public bool IsItalic { get; set; }
public bool IsBold { get; set; }
}
is defined. Which is used from https://github.com/telerik/xaml-sdk/blob/f5002a15eb1def98405472bee700f20ad8b65cc9/SpreadProcessing/RegisterAndExportPdfFonts/MainPage.xaml.cs to get the Bytes property of the above class to register a font:
PdfFontsServiceFontData result = e.Result;
FontFamily fontFamily = new FontFamily(result.FontFamilyName); FontStyle fontStyle = GetFontStyle(result.IsItalic); FontWeight fontWeight = GetFontWeight(result.IsBold);
FontsRepository.RegisterFont(fontFamily, fontStyle, fontWeight, result.Bytes);
So is this the right way to create the font data:
FontFamily fontFamily = new FontFamily(fontFamilyName);
FontStyle fontStyle = isItalic ? FontStyles.Italic : FontStyles.Normal;
FontWeight fontWeight = isBold ? FontWeights.Bold : FontWeights.Normal;
Typeface typeface = new Typeface(fontFamily, fontStyle, fontWeight, FontStretches.Normal);
GlyphTypeface glyphTypeface;
if (typeface.TryGetGlyphTypeface(out glyphTypeface)) {
using (var memoryStream = new MemoryStream()) {
glyphTypeface.GetFontStream().CopyTo(memoryStream);
data.Bytes = memoryStream.ToArray();
data.IsValid = true;
}
}
Thanks
Mike
There is a data parameter at the end, which should contain the raw data for the font. Looking for more information about the subject I came across https://github.com/telerik/xaml-sdk/blob/f5002a15eb1def98405472bee700f20ad8b65cc9/SpreadProcessing/RegisterAndExportPdfFonts.Web/PdfFontsService.svc.cs where
public class FontData {
public bool IsValid { get; set; }
public byte[] Bytes { get; set; }
public string FontFamilyName { get; set; }
public bool IsItalic { get; set; }
public bool IsBold { get; set; }
}
is defined. Which is used from https://github.com/telerik/xaml-sdk/blob/f5002a15eb1def98405472bee700f20ad8b65cc9/SpreadProcessing/RegisterAndExportPdfFonts/MainPage.xaml.cs to get the Bytes property of the above class to register a font:
PdfFontsServiceFontData result = e.Result;
FontFamily fontFamily = new FontFamily(result.FontFamilyName); FontStyle fontStyle = GetFontStyle(result.IsItalic); FontWeight fontWeight = GetFontWeight(result.IsBold);
FontsRepository.RegisterFont(fontFamily, fontStyle, fontWeight, result.Bytes);
So is this the right way to create the font data:
FontFamily fontFamily = new FontFamily(fontFamilyName);
FontStyle fontStyle = isItalic ? FontStyles.Italic : FontStyles.Normal;
FontWeight fontWeight = isBold ? FontWeights.Bold : FontWeights.Normal;
Typeface typeface = new Typeface(fontFamily, fontStyle, fontWeight, FontStretches.Normal);
GlyphTypeface glyphTypeface;
if (typeface.TryGetGlyphTypeface(out glyphTypeface)) {
using (var memoryStream = new MemoryStream()) {
glyphTypeface.GetFontStream().CopyTo(memoryStream);
data.Bytes = memoryStream.ToArray();
data.IsValid = true;
}
}
Thanks
Mike