Embed Font in Exe; Using Icon Fonts;

Hello!

Is it possible to embed a font in the executable or load it from resource folder?
I want to use an icon font for symbols; or is there a better way to use icon fonts? (Of course, could make an image from them)

Any hints really apreciated!
Regards!
Hanno

Look for Windows Functionality Suite at https://github.com/arbp/WFS

There is a method inside called TemporarilyInstallFont that does what you want.

Well, found that on forum.
I will walk through that then.

Anyway, thanks a lot for the hint!

Regards

The luxury ride is MBS FontActivateMBS, which I use for my Fonts Manager app. Works great cross platform.

https://www.monkeybreadsoftware.net/fonts-folderitem-method.shtml

Well you can also embed fonts in a resource inside exe, but u don’t think there is an interface to do this in Xojo.
But maybe an external resource editor could do that.
Not sure why you want that.

For font activation our plugin function will help on Mac and Windows.

“Not sure why you want that.” -> indeed!

So, I want to use an external font which may not be on destination PC.
Of course, it can be a normal resource in resource folder and Iwould load font into application.
Is that possible?

Font symbols are used in place of normal icons, expecially web site. They scale very well, if needed.

[quote=294572:@Hans-Norbert Gratzal]So, I want to use an external font which may not be on destination PC.
Of course, it can be a normal resource in resource folder and Iwould load font into application.
Is that possible?[/quote]

That is what I do. Get Tim Parnell’s TPSF class to access more easily the Resources folder http://timi.me/xojo

This no longer works with Xojo 2016r4 (and 2017r1.1) on Windows: <https://xojo.com/issue/46596>

The same applies to other ways of doing this (without MBS Plugins), e.g. with the Declare (found in the Windows Functionality Suite).

The issue might be that the declare has no effect with Direct2D/DirectWrite (since 2016r4 used on Windows)?
Maybe Christian’s Plugin is using the same API calls?

System.IsFunctionAvailable( "AddFontResourceExW", "Gdi32" )

Is this a “bug” in the Framework, or is it just that Direct2D/DirectWrite need other Declare’s?
If yes… which Declare’s to use for 2016r4 and newer?

I dont embed fonts in the .exe I place them in a folder next to the .exe and add them dynamically to the system for the app. has worked great for me for years.

this is exactly what the previous post mentioned…
…but how do you do it when you’re building a windows application with Xojo 2017r1.1?

[quote=327844:@Jürg Otter]this is exactly what the previous post mentioned…
…but how do you do it when you’re building a windows application with Xojo 2017r1.1?[/quote]

for windows I am still using 16R4. Let me see if I can clone one of the repositories and testing with 17R1.1. Only Mac apps do we run current version on. Windows we have to stay behind a few versions.

Font licensing often prohibits adding the font to the user’s system if it’s licensed for use in an app.
I need to be able to activate and use a font temporarily, stuck on 2016r3 :confused:

Plugin uses AddFontResourceExW on Windows.

Xojo runtime library simply loads font list on start of application.
It does not allow you to use fonts outside the list currently.

There are feedback cases to ask for change in that area.

It is a real show stopper for more than half my apps. They rely on custom fonts. I will then have to stay with 2016R3.

Reading these links, it seems quite possible to use custom fonts with Direct2D, though. The method is drastically different, it seems.

https://blogs.msdn.microsoft.com/windowssdk/2009/10/20/new-samples-in-win-7-sdk-direct2d-and-directwrite/

https://msdn.microsoft.com/en-us/library/windows/desktop/ee264312(v=vs.85).aspx

http://stackoverflow.com/questions/25448355/directwrite-registerfontfileloader-create-a-font-file-loader-and-register-it-in

You may be able to draw using graphics.DrawRotatedTextMBS with a newly activated font.

I tried to move FontActivateMBS to App. Constructor, to no avail.

I would seem the font management is initialized before then.

I sincerely hope someone at Xojo will understand how this issue can be a total show stopper.

@William Yu , are you around ? Do you think it is possible to fix that issue ?

I tried to create a workaround.
Is not complicated but AFAIK actually it can’t be done (William told me so)

I use customFont for app icons within the app. Actually I have extended my method to work with font on Mac and create automatically all the needed icons as picture for windows and Linux (btw since I never discovered how to load a temporary font for linux I already used this method for Linux)

Any suggestion for Linux is greatly welcome

I’ve posted an example Xojo project in this Forum-Thread.
On Linux it uses Declares to fontconfig.

Good news !

William Yu just posted in <https://xojo.com/issue/46596> that has been fixed (Windows issue with custom fonts), and is waiting verification from the testing staff.