Set font style?
-
@VirtualVirgin Actually, after testing this does not work. It is not finding any of the files.
Does anyone know how to navigate to the project folder and then the fonts folder to get all of the files there? I can't seem to find a path to do it using the FileSystem. -
Even if I use the AppData folder and let it search recursively in any child folders, it does not return any fonts:
-
@VirtualVirgin Your font files need to be in the project's images folder.
-
@VirtualVirgin it's not in the appData folder but in project's folder you access using the wildcard
{PROJECT_FOLDER}
as in my example -
@d-healey They are.
-
@ustk It doesn't seem to resolve to anything though:
-
I've tried using File.Show() on each of these variations here and all three open to the Audio Files folder in the Project Folder instead of the Project Folder itself, so it seems like there is an error with the FileSystem processing of the wildcard?
-
Ok, well I made it to the Fonts folder by navigating form the Audio folder, back to the Project folder, then on down.
But now I'm having an issue with
File.toString();
which returns the path for "Filename" instead of just the filename:
The Docs says it should just return the file name and not the full path:
-
@VirtualVirgin I don't think this will work in the compiled project because fonts are embedded in the binary and that folder structure won't exist.
With toString those are constants which are part of your file object, file.FullPath for example
-
Ok, sorry about that.
This one actually works:// this will load all of your fonts which are stored in the projectFolder/Images/Fonts inline function loadAllFontsFromProjectFolder() { local fontsFolder = FileSystem.getFolder("{PROJECT_FOLDER}").getParentDirectory().getChildFile("Images").getChildFile("Fonts"); local fontFiles = FileSystem.findFiles(fontsFolder, "*.ttf;*.otf", false); for (file in fontFiles) { local fontPath = file.toString("FullPath"); local pathParts = fontPath.split("/"); local fontNameWithExtension = pathParts[pathParts.length - 1]; local targetName = ""; // if the file name suffix is "-Regular", loadAs will use just the prefix if (fontNameWithExtension.contains("-Regular.ttf") || fontNameWithExtension.contains("-Regular.otf")) targetName = fontNameWithExtension.substring(0, fontNameWithExtension.lastIndexOf("-Regular.")); else targetName = fontNameWithExtension.substring(0, fontNameWithExtension.lastIndexOf(".")); Engine.loadFontAs("{PROJECT_FOLDER}Fonts/" + fontNameWithExtension , targetName); } }
-
@d-healey Even if gets and loads the files using the "{PROJECT_FOLDER}" wildcard? That has to be used for Engine.loadFontAs anyway, so why wouldn't it also work for this?
-
@VirtualVirgin might work, try it in the compiled plugin and let us know