Change font typeface in blocks tab

Helloo, I want a toggle button swap the font typeface of a text box. I have uploaded the two fonts into my project, and now I am struggling to change the font in the blocks tab.

I can use the designer > appearance tab and select one of my fonts, but when it comes to changing the font within the app, I can only choose between Default, SansSerif, Serif and Monospace.

Attached are some photos to make it clearer what I’m saying. And I have tried using the YourFont extension but either I don’t know how to use it or it won’t work.

^You can see that the custom fonts I’ve uploaded don’t appear here as one of the options. Only the default 4 do. What I’m doing here is basically: “if it is font A, then change to font B” and vice versa.

^But it appears in the designer tab.

^These two won’t connect. The “Gentium” block is from the YourFont extension.

this is weird… maybe try switching your ui or using a different font?

I switched to the Classic UI if that’s what you meant but it is still the same. I think this is more of a problem in the blocks tab. I simply don’t have the option to select any custom fonts when I select the FontTypeface block:

If there really is no native support, are there any extensions or workarounds that you think can resolve this?

Wait I might be right about simply not knowing how to use the extension. I believe this new code should work if not for how old the extension is:

But here’s the error:

I’m guessing it happens because the directory has changed over the years. This error occurs while using the companion by the way.

Like so?

I got it to work!

This is my final code. @TIMAI2 made me realize there is a file block (or whatever its called) that I’m supposed to use for situations like this. I didn’t even need the extension.

Going back to this error message, ^^^ simply removing the extension fixed it (it got me confused for a while if it was coming from the extension or App Inventor).

So the problem really was just my unfamiliarity with how the blocks work that kept me from solving the problem on my own. Today I learned that “file block” exists. Thanks for your help everyone!

nope, i dont really understand extensions, and havent used ny yet

Here is a sample app to switch every Label and TextBox font from whatever .TTF files are in the Media folder. No extension is needed.



fontSwitcher.aia (3.6 MB)
Sample run

P.S. I dragged a bunch of font files from my Windows 11 Windows\fonts directory for this sample. Your font files might not be as easy to filter, because these file names are all upper case.

1 Like

That’s nice, thanks for demonstrating. I’ll have to take a closer look since I’m not good with lists yet.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.