Questions for extension creators

excuse me an ignorant cat, but I wanted to get answers from those who create extensions. I’m interested in a few small ones. but there are important questions for me. and specifically:

@DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_ASSET, defaultValue = “”)
@SimpleProperty(description = “Sets the path to the custom font in the assets.”)
public void FontPath(String path) {
this.fontPath = path;

  1. Is it possible to filter files with the extension at this stage? in this case, only files with the extension “*.ttf”
  2. if I check the availability of a file using this method :

InputStream InputStream = form.openAsset(path);

then it turns out to be available. it’s all right. but I can’t apply it. for example :

Typeface typeface = Typeface.createFromAsset(context.getAssets(), fontPath);
I don’t really work well with assets at all ^(
knowledgeable people explain in detail to me, a pathetic cat, how to be and where to watch :frowning:

To filter the file extension at the stage where you’re setting the font path, you can add a simple check within your FontPath method to ensure that only files with the “.ttf” extension are accepted. Here is an example:

@SimpleProperty(description = "Sets the path to the custom font in the assets.")
public void FontPath(String path) {
    if (path != null && path.toLowerCase().endsWith(".ttf")) {
        this.fontPath = path;
    } else {
        throw new IllegalArgumentException("Invalid font path. Only '.ttf' files are allowed.");

I think this can help if you have any problem please pm me

1 Like

Thank you for your detailed answer!

this will not affect the actual installation of the file in the editor. This code is responsible for checking and processing the file path, but not for selecting and displaying it in the editor.
but I have seen when files are filtered out at the visual level specifically in the editor. I don’t understand how this is implemented.
as it is reflected here. the list here does not contain all the files:

and I’ll immediately ask why I can’t apply the font? I’m trying to do this:
(in the example for label…)
Typeface typeface = Typeface.createFromAsset(context.getAssets(), fontPath);
((TextView) label.getView()).setTypeface(typeface);
does not work :frowning:

Please check your PM

I think you should thank ChatGPT too!

I didn’t understand your sarcasm

I think this code not work in companion.

This is what i mean :point_down:

unfortunately, there is no answer on this link. there, the author himself came across something similar :)however, I found a solution and a reason. and unfortunately not in this community :slight_smile:
I made sure that the error lies in access to assets and in the dependence on working in the editor (Repl) or not different accesses. in fact, everything is very simple if it is necessary here, I will write it in more detail…