jhimes144
Topic Author
Posts: 16
Joined: 19 Nov 2024, 01:36

How to create bin header file for fonts

23 Nov 2024, 21:04

I'm able to make xaml embeds using the bin2h tool. I see in the integration sample a font being embedded using a header file containing a byte array as well. I figured the bin2h tool was used for fonts as well so I passed in a font file to test it out, no dice. Is there a tool I can use to do this? If there isn't a tool, can I simply write a quick script to take the contents of the file and write my own header file with the binary contents? Or is it more involved than that?
 
User avatar
jsantos
Site Admin
Posts: 4823
Joined: 20 Jan 2012, 17:18
Contact:

Re: How to create bin header file for fonts

25 Nov 2024, 17:23

bin2h is used for all resources in our samples (fonts, textures, xamls, etc).

It is a standard tool to convert a binary file into a C header file. You can reuse that tool instead of creating a new one.
 
jhimes144
Topic Author
Posts: 16
Joined: 19 Nov 2024, 01:36

Re: How to create bin header file for fonts

25 Nov 2024, 18:48

Thanks for the info, then this means that I'm either using the tool incorrectly for fonts or there is a bug with the tool. I will search the app framework code again for a place where its being used for fonts.
 
User avatar
jsantos
Site Admin
Posts: 4823
Joined: 20 Jan 2012, 17:18
Contact:

Re: How to create bin header file for fonts

25 Nov 2024, 19:36

As you discovered, the Integration sample is using binh for fonts:
// For this sample we are embedding needed resources using our tool 'binh'
#include "Settings.xaml.bin.h"
#include "HermeneusOne-Regular.ttf.bin.h"


////////////////////////////////////////////////////////////////////////////////////////////////////
void SetResourceProviders()
{
    // Each time a resource (xaml, texture, font) is needed, the corresponding provider is invoked
    // to get a stream to the content. You must install a provider for each needed resource. There
    // are a few implementations available in the app framework (like LocalXamlProvider to load
    // from disk). For this sample, we are embedding needed resources in a C array.
    NoesisApp::EmbeddedXaml xamls[] = { { "Settings.xaml", Settings_xaml } };
    Noesis::GUI::SetXamlProvider(Noesis::MakePtr<NoesisApp::EmbeddedXamlProvider>(xamls));

    NoesisApp::EmbeddedFont fonts[] = { { "", HermeneusOne_Regular_ttf } };
    Noesis::GUI::SetFontProvider(Noesis::MakePtr<NoesisApp::EmbeddedFontProvider>(fonts));

    // Set providers for the theme
    NoesisApp::SetThemeProviders();
}
 
jhimes144
Topic Author
Posts: 16
Joined: 19 Nov 2024, 01:36

Re: How to create bin header file for fonts

25 Nov 2024, 19:39

Yes, but i need to find where the font file is being passed in the binh tool, because when I do it, it doesn't work. I don't understand why you are marking this question as resolved? Sorry if I wasn't clear, the binh tool doesn't work when I pass a font in the same way I pass an xaml file into it.
 
User avatar
jsantos
Site Admin
Posts: 4823
Joined: 20 Jan 2012, 17:18
Contact:

Re: How to create bin header file for fonts

25 Nov 2024, 19:49

You can view the usage by clicking on any font within Visual Studio. For example, in the HelloWorld sample:
..\..\..\..\..\NoesisSDK\Native\Src\Tools\Bin2h\bin2h.exe "%(FullPath)" > "$(IntermediateOutputPath)%(Filename)%(Extension).bin.h"
I am confident that there are no bugs in bin2h. :)
 
User avatar
jsantos
Site Admin
Posts: 4823
Joined: 20 Jan 2012, 17:18
Contact:

Re: How to create bin header file for fonts

25 Nov 2024, 19:53

The statement "binh tool doesn't work" is a bit too vague. Could you provide more details? Specifically, what input parameters are you using, what output are you getting, and what output were you expecting?
 
jhimes144
Topic Author
Posts: 16
Joined: 19 Nov 2024, 01:36

Re: How to create bin header file for fonts

25 Nov 2024, 20:25

Fixed it. I had made a build script that went through and ran all assets through the tool and a bug in my script for fonts was the issue, even though xaml files worked. Sorry for the trouble.

Passing invalid file to the bin tool causes it to just not return anything. I'm not sure if its worth fixing for you folks.

Who is online

Users browsing this forum: No registered users and 6 guests