How to add custom font in app inventor option?

Hello,

I don't believe it is possible to add a custom font to core app inventor. App Inventor seems to use the TextViewUtil class to set the font, which relies on the TypeFace class provided by core Android :confused: Since it relies on an outside class to handle the .ttf files, it doesn't seem to be modifyable.

But I'm not very familiar with this area of App Inventor, so I could be wrong!

Best wishes,
--Beka

1 Like

Thanks for your answer.:blush:

1 Like

If anyone know how to do it then please reply.

Can you tell me how to add fontawsome and material icon?

Hello,

I'm not exactly sure; I don't have experience doing that :confused: The extension links that people posted above may be helpful =)

If you still need more help I recommend creating a new issue in the MIT App Inventor help category. It will be best if you describe exactly what you want to do, ie add fontawesome and material icons to your app =)

Best wishes,
--Beka

1 Like
1 Like

Here is the demo to how to set font icon on label:

  1. download and import this extention:
    https://www.kevinkun.cn/enhance.html (v4)

  2. download the fontawesome-webfont.ttf (v4.7.0) file from here and upload to asset

  3. make the block like this:
    2021-01-13_204734
    in this case, the label will be like this:
    2021-01-13_204754

  4. for more unicode, please refer to:
    https://fontawesome.com/v4.7.0/cheatsheet/

that's all.

1 Like

Hi @Tauqir_Tech_BD
This should work fine:

  1. Add font name in YoungAndroidFontTypefaceChoicePropertyEditor.java file.
    Add font name in OdeMessages.java and Component.java files.
    (I assume you know how to add values there :wink: )

  2. Now you will have to do some modifications in TextViewUtil.java.
    Add this:

case Component.YOUR_FONT :
     tf = Typeface.createFromAsset(form.getAssets(),"your_font.ttf");
     break;

Make sure you add ttf file to assets.

2 Likes

Thanks for helping me

which folder is the assets folder. If you are talking about apps asset folder then please I don't want to upload everytime please give me another way or if not then which?

1 Like

appinventor-sources/appinventor/appengine/war/static/ fonts /

1 Like

Having this error when I tried this:

[javac] C:\Users\Administrator\appinventor-sources\appinventor\components\src\com\google\appinventor\components\runtime\util\TextViewUtil.java:149: error: non-static method getAssets() cannot be referenced from a static context

BUILD FAILED
C:\Users\Administrator\appinventor-sources\appinventor\build.xml:16: The following error occurred while executing this line:
C:\Users\Administrator\appinventor-sources\appinventor\build-common.xml:341: The following error occurred while executing this line:
C:\Users\Administrator\appinventor-sources\appinventor\components\build.xml:215: The following error occurred while executing this line:
C:\Users\Administrator\appinventor-sources\appinventor\build-common.xml:125: Compile failed; see the compiler error output for details.

1 Like

is that full error?

1 Like

Yes this is the only error

This is the error.

Yes how to solve this error van you help me

Since we can't see your code, the most likely thing I can think of is that you're doing something like Context.getAssets(), which is wrong because getAssets() is an instance method but Context is a class. You need to call it on an instance of Context instead, typically by calling getContext() on some other Android object. If you've got an instance of Form lying around, it is a Context so you could also use that.

Code:

code:

Code:

Code:

After changing context.getassets to form.getasset im getting
this error:

@ewpatton please help

1 Like