- solaris783
- Posts: 5
- Joined:
Specified Font not showing up
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.
Re: Specified Font not showing up
The LocalFontProvider, whose source code is available and you can inspect and debug, uses the passed string to prepend it to all requests made to the provider. By default, the "", means, "open from the current working directory". You can adjust accordingly your working directory in Visual Studio while debugging.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 whenCode: Select allLocalFontProvider *lfp = new LocalFontProvider("");
running from VS, where the .vcxproj is.
Or you can even create your own implementation for your specific scenario.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot], Semrush [Bot] and 9 guests