Specified Font not showing up
Posted: 12 Oct 2019, 03:34
I have some xaml that works correctly in WPF but doesn't in Noesis. Working off of IntegrationGLUT from the SDK.
Simple control:
C++ code:
Should have a character that looks like a little eye, but I get the "character not found" square instead:
In the xaml, I tried putting a full path like:
and other relative path combinations to no avail. Shows up in VS blend, not in Noesis.
No errors in the output window or console window .
Worth noting I tried not using LocalFontProvider and instead use this:
which yields the same results.
Edit: using LocalFontProvider fails because FamilyExists always returns false, no matter how I try to reference the font. I tried every type of URI available and not having a URI as well to no avail. ScanFolder successfully calls RegisterFont with "Fonts" as the folder and "fa-brands-900.ttf" as the filename (among others of the same family). There's no visibility in the Noesis library to see how these things are stored internally. EmbeddedFontProvider also returns false for FamilyExists.
eg:
return false
Both LocalFontProvider and EmbeddedFontProvider call CachedFontProvider and I can't debug any further since that code is not visible (.cpp not provided)
EDIT2:
I got a version working by extending LocalFontProvider and hardcoding the base file directory to the Windows absolute path. Then in my xaml I use:
Not sure if this is the right way to do it.
For the EmbeddedFontProvider I defined it as having the same relative path as Local:
then in xaml I use:
In making LocalFontProvider work, I saw a key assumption I was making was wrong.
This statement assumes the directory referenced ("") is where the executable is OR when
running from VS, where the .vcxproj is.
doing this now:
will find it when running from VS.
I have to fix my paths now and VS Debugging settings such that it always looks in the same dir.
Simple control:
Code: Select all
<ToggleButton Content="" FontStyle="Normal" FontWeight="Regular" FontFamily="#Font Awesome 5 Free" FontSize="10">Code: Select all
GUI::SetFontProvider(MakePtr<NoesisApp::LocalFontProvider>("../IntegrationGLUT-blend/Fonts/"));In the xaml, I tried putting a full path like:
Code: Select all
FontFamily="../IntegrationGLUT-blend/Fonts/fa-solid-900.ttf#Font Awesome 5 Free Solid"No errors in the output window or console window .
Worth noting I tried not using LocalFontProvider and instead use this:
Code: Select all
EmbeddedFont fonts[] =
{
{ "Fonts", fa_solid_900_ttf, sizeof(fa_solid_900_ttf) },
};
Ptr<EmbeddedFontProvider> fp = MakePtr<EmbeddedFontProvider>(fonts, 1, fontProv);
GUI::SetFontProvider(fp);
Edit: using LocalFontProvider fails because FamilyExists always returns false, no matter how I try to reference the font. I tried every type of URI available and not having a URI as well to no avail. ScanFolder successfully calls RegisterFont with "Fonts" as the folder and "fa-brands-900.ttf" as the filename (among others of the same family). There's no visibility in the Noesis library to see how these things are stored internally. EmbeddedFontProvider also returns false for FamilyExists.
eg:
Code: Select all
EmbeddedFont fonts[] =
{
{ "", fa_solid_900_ttf, sizeof(fa_solid_900_ttf) },
};
Ptr<EmbeddedFontProvider> fp = MakePtr<EmbeddedFontProvider>(fonts, 1, fontProv);
bool ret = ((FontProvider*)fp)->FamilyExists("", "#Font Awesome 5 Free Solid");Both LocalFontProvider and EmbeddedFontProvider call CachedFontProvider and I can't debug any further since that code is not visible (.cpp not provided)
EDIT2:
I got a version working by extending LocalFontProvider and hardcoding the base file directory to the Windows absolute path. Then in my xaml I use:
Code: Select all
FontFamily="../IntegrationGLUT-blend/Fonts/fa-solid-900.ttf#Font Awesome 5 Free"For the EmbeddedFontProvider I defined it as having the same relative path as Local:
Code: Select all
EmbeddedFont fonts[] =
{
{ "../IntegrationGLUT-blend/Fonts", fa_solid_900_ttf, sizeof(fa_solid_900_ttf) },
};
Code: Select all
FontFamily="../IntegrationGLUT-blend/Fonts/fa-solid-900.ttf#Font Awesome 5 Free"Code: Select all
LocalFontProvider *lfp = new LocalFontProvider("");running from VS, where the .vcxproj is.
doing this now:
Code: Select all
FontFamily="../IntegrationGLUT-blend/Fonts/fa-solid-900.ttf#Font Awesome 5 Free"I have to fix my paths now and VS Debugging settings such that it always looks in the same dir.