Query about link assets

hello sir , i didnt find any way to check how does the font looks in companion , in compiled apps it works but while in companion assets and fonts doesnt shows , do you have any sample of open source project please provide me link.

I used this in my extension:

@SimpleFunction(description = "设置组件字体。fontName字体名以//开始表明字体在素材库")
	public void setFontTypeface(AndroidViewComponent component, String fontName) {
		TextView view = (TextView) component.getView();
		Typeface tf = Typeface.DEFAULT;
		if (fontName.startsWith("//")) {
			fontName = fontName.substring(2);
			if (isReplForm) {
				String realpath;
				String files = this.context.getExternalFilesDir(null).getPath();
				if (Build.VERSION.SDK_INT >= 29) {
					realpath = files + "/assets/" + fontName;
				} else {
					if (files.contains("wxbit")) {
						realpath = files + "/assets/" + fontName;
					} else {
						realpath = files + "/AppInventor/assets/" + fontName;
						tf = Typeface.createFromFile(realpath);
					}
				}
				tf = Typeface.createFromFile(realpath);
			} else {
				tf = Typeface.createFromAsset(this.context.getAssets(), fontName);
			}
		} else {
			if (fontName.toLowerCase().startsWith("file://")) {
				fontName = fontName.substring(7);
			}
			tf = Typeface.createFromFile(fontName);
		}
		view.setTypeface(tf);
		view.requestLayout();

	}
2 Likes

Thankyou i will test later

A side note:
Why there is a different path to the assets with Companion for Android < 10 will probably remain an eternal secret of AI2. :wink: