I noticed that it was possible to embed custom fonts whilst looking at the webcam firstlook demo source code. I'm rewriting a poorly working web cam module, replacing the old code with your new webcam control.
So I found https://docs.telerik.com/devtools/winforms/telerik-presentation-framework/custom-fonts and generated the following code
/// <summary>
/// Add all fonts to [root]\Properties as embedded resources
/// </summary>
public
static
class
FontFactory
{
private
static
FontFamily ReadFontFromManifest(
string
fontFileName,
string
fontName)
{
#region Code
try
{
var names = Assembly.GetExecutingAssembly().GetManifestResourceNames();
var root = Assembly.GetExecutingAssembly().GetName().Name;
var fontStream = Assembly.GetExecutingAssembly().GetManifestResourceStream($@
"{root}.Properties.{fontFileName}"
);
if
(fontStream ==
null
)
return
null
;
ThemeResolutionService.LoadFont(fontStream);
return
ThemeResolutionService.GetCustomFont(fontName);
}
catch
(Exception err)
{
Log4Net.Log.Error(err);
throw
;
}
#endregion
}
// function
public
static
FontFamily Font_Awesome_5_Free_Solid
=> ReadFontFromManifest(
"Font-Awesome-5-Free-Solid-900.otf"
, Font_Awsome_5_Free_Solid_FontName);
public
static
string
Font_Awsome_5_Free_Solid_FontName
=>
"Font Awesome 5 Free Solid"
;
}
I tested the code and it does seem to return a font family. But I want to ask a question about your first look please.
I was trying to find in the firstlook solution any code that matched the suggestion for embedding fonts shown in your documentation, but couldn't. The only mention of the awsome font above was in your form1.cs file for the webcam demo. So is it already part of your component source? When I removed the call to my font factory the closebutton.textelement.customfont still showed what appeared to be "Font Awesome 5 Free Solid";
Thanks. Just trying to understand what to expect :)