Resource file/data file, fonts

Hi all,

For an application I’m developing, I need to create a viewer and editor (both separate applications).
The viewer will display text and images, and play an audio file (music). It will also send commands over the Serial port.

I’ve been trying to figure out a way to do this. Now I would think the best approach is to create a resource file with all the required files.
This way there’s only 1 file which needs to be dropped in a specific folder.
Any ideas on how to achieve something like this?

That being said, the client application will have to use custom fonts as well.
I’ve been trying to get .svg fonts to work (desktop application), but I find them hard to implement. I would have to parse the SVG myself, and I’m not sure if that would be fast enough.

Another option would be to use .bmp fonts (like in the good old Amiga days :wink: ), but I think it would be better if it’s something vectorized so that it would look decent on different resolutions and when it’s being resized.

I’ve also thought to use a .ttf file directly, but I’m not sure if it’s possible to parse a .ttf file or something like that to actually use it in an application without installing it.

I should note that the viewer will run on a Raspberry Pi most likely, but I would prefer a cross-platform solution.

I’d love to hear your input :slight_smile:

Thanks!

-Steve

I’m actually working on a similar thing. Although that project is kind of on hold right now.
Instead of using a serial port, I use a server that hosts the media files.

In my case, the viewer is the client, a Raspberry Pi. Periodically the client checks for updates and downloads those updates.
And in my case, I have not only one client. I have several.

But the client can serve as a server as well, just by listening for connections on a TCP port. In case the server has immediate updates, that can’t wait, the server can push those updates to the client.

The server is nothing more than a “post office”. It receives content from an admin app. And it holds data until it is fetched by the client, or pushes it to the client if it needs to.
And, just like sending an email, the media and other data, can be sent to one individual, a group or all clients.

An admin app can connect to the server to post new updates and whatnot. This admin app is kind of the remote control of the server.

I’m sure this might not exactly what your apps do. But still, I see some similarities.
Try thinking of a client-server approach, over TCP… I think it just might be a bit easier.

About embedding fonts… There are some topics in this forum about that.

[quote=382914:@Edwin van den Akker]
I’m sure this might not exactly what your apps do. But still, I see some similarities.
Try thinking of a client-server approach, over TCP… I think it just might be a bit easier.[/quote]

My use case won’t allow that unfortunately. Thanks for the help though :slight_smile:

You can use TTF fonts as web fonts directly. They have to be stored on a web space. I would advise against employing licensed fonts since they very seldom encompass web use, but you can safely use Google fonts.

https://www.w3schools.com/cssref/css3_pr_font-face_rule.asp

A resource folder (one for each use) populated with all data: .text, .image, .sound, etc. ?

Before use, you check if in the target folder you find the .text file (for example) and return an error (if not found) or continue.

.svg font ? I learned something.

Why don’t you use standard font ?

[quote=382975:@Emile Schwarz]A resource folder (one for each use) populated with all data: .text, .image, .sound, etc. ?

Before use, you check if in the target folder you find the .text file (for example) and return an error (if not found) or continue.

.svg font ? I learned something.

Why don’t you use standard font ?[/quote]

That’s what I’m looking into right now as well. The biggest issue is actually embedding it into the resource file.
I’m wondering if something like this is possible by utilizing binary streams or something similar.

Instead of a resource folder, I need it to be a single file, as it has to be easy to modify. Basically, the editor I’m building will have to spit out a packaged file which can be read by the viewer application.

If you are trying to use Mac Resource Forks then as far as macOS is concerned they are a dead technology.

Have you looked at Xojo’s Virtual Folders?

You qualify that to be easy ?

Easy is: drop a text file (image, sound files) into a folder.
NOT EASY: put everything in a binary file, one after the other… with a table of contents as file header :wink:

But if it is easy for you, go ahead.

[quote=382998:@Emile Schwarz]You qualify that to be easy ?

Easy is: drop a text file (image, sound files) into a folder.
NOT EASY: put everything in a binary file, one after the other… with a table of contents as file header :wink:

But if it is easy for you, go ahead.[/quote]

For my purposes it is easier to have 1 file. Ever played the original doom? You could install a MOD by just dropping a single .wad file in the executable folder. For my purposes, I need the same thing :slight_smile:

[quote=382984:@Kevin Gale]If you are trying to use Mac Resource Forks then as far as macOS is concerned they are a dead technology.

Have you looked at Xojo’s Virtual Folders?[/quote]

I haven’t thought of using virtual folders for this. It would be the first time I actually use those and they seem to be exactly what I need. Thanks! :slight_smile:

I think it would be feasible to actually add the .ttf font file to a virtual folder and then use it like that. I wouldn’t have to bother with svg fonts or building my own parser then.

Thanks for the help, all!

Someone seems to love complexity…

Not only that you probably won’t even be able to code sign your application to release it.

While you can include the TTF file in your VV, you’ll need to copy it somewhere before it can be activated.

You see a VV is just that, it’s a virtual volume that’s proprietary technology of Xojo, while there is absolutely no problem with that, the OS will always see it as a single file, so to get any OS service (such as font activation) you’ll need to copy the file out of the VV and into a special folder.

Another alternative is to use a zip file, Apple do this for their iWork applications. The file the user sees and works with is a zip file, but in reality you expand the file to a folder in the background and then re-compress when they “Save” or “Export”.

To start with you can use a shell class to access the built in zip functions of the OS. Once you’re more comfortable and ready to start really working with Zip files, check out Thomas Templemann’s Zip tools http://www.tempel.org/

No, never. I do not even know what it is.

You cannot activate a font from a file in a Virtual folder. It has to be on a real disk.

MBS has plugins to activate fonts on Mac and Windows.