HISE Logo Forum
    • Categories
    • Register
    • Login

    Set font style?

    Scheduled Pinned Locked Moved Scripting
    16 Posts 4 Posters 50 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • VirtualVirginV
      VirtualVirgin
      last edited by

      How do I use different font styles in with the graphics?

      Trying this but it doesn't take and HISE gives me the default font instead:

       g.setFont("Fredoka-Bold", buttonSize);
      

      It must be something simple, I'm sure.

      You can listen to my orchestral mockups here:
      https://www.virtualvirgin.net/

      ustkU 1 Reply Last reply Reply Quote 0
      • ustkU
        ustk @VirtualVirgin
        last edited by ustk

        @VirtualVirgin Have you embedded the font in your project's image folder and loaded it with Engine.loadFontAs(String fileName, String fontId)?

        For my part, I embed styles in different font files so they can all be loaded separately, I don't see another way to load styles, which is a wee bit annoying...

        Engine.loadFontAs("{PROJECT_FOLDER}Fonts/myFont-normal.ttf", "Normal");
        Engine.loadFontAs("{PROJECT_FOLDER}Fonts/myFont-bold.ttf", "Bold");
        Engine.loadFontAs("{PROJECT_FOLDER}Fonts/myFont-italic.ttf", "Italic");
        // etc...
        

        Hise made me an F5 dude, browser just suffers...

        ChazroxC VirtualVirginV 2 Replies Last reply Reply Quote 3
        • ChazroxC
          Chazrox @ustk
          last edited by

          @ustk I do the same. I dont know if im doing something wrong or not. I havent figured out how to do font styles.

          1 Reply Last reply Reply Quote 0
          • VirtualVirginV
            VirtualVirgin @ustk
            last edited by VirtualVirgin

            @ustk Thank you!

            I made an inline function to load all of the fonts from your project fonts folder and auto-name them. I thought it would be easier just to drag the .ttf or .otf into the Fonts folder and let this do the rest. FYI- the naming here removes "-Regular" from the loadFontAs target name so for instance "Nunito-Regular" will now just be referred to as "Nunito". The other types will keep their suffix.

            // this will load all of your fonts which are stored in the projectFolder/Images/Fonts
            inline function loadAllFontsFromProjectFolder()
            {
            	local appDataFolder = FileSystem.getFolder(FileSystem.AppData);
            	local fontsFolder = appDataFolder.getChildFile("Fonts");
            	local fontFiles = FileSystem.findFiles(fontsFolder, "*.ttf;*.otf", false);
            
            	for (file in fontFiles)
            	{
            		local fontPath = file.toString(File.FullPath);
            		local fontName = file.toString(File.Filename);
            		local targetName = "";
            
            		// if the file name suffix is "-Regular", loadAs will use just the prefix
            		if (fontName.endsWith("-Regular.ttf") || fontName.endsWith("-Regular.otf"))
            			targetName = fontName.substring(0, fontName.lastIndexOf("-Regular."));
            		else if (fontName.endsWith(".ttf") || fontName.endsWith(".otf"))
            			targetName = fontName.substring(0, fontName.lastIndexOf("."));
            
            		Engine.loadFontAs(fontPath, targetName);
            	}
            }
            

            You can listen to my orchestral mockups here:
            https://www.virtualvirgin.net/

            VirtualVirginV 1 Reply Last reply Reply Quote 2
            • VirtualVirginV
              VirtualVirgin @VirtualVirgin
              last edited by VirtualVirgin

              @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.

              You can listen to my orchestral mockups here:
              https://www.virtualvirgin.net/

              1 Reply Last reply Reply Quote 0
              • VirtualVirginV
                VirtualVirgin
                last edited by VirtualVirgin

                Even if I use the AppData folder and let it search recursively in any child folders, it does not return any fonts: Screenshot 2025-08-29 at 7.59.07 PM.png

                You can listen to my orchestral mockups here:
                https://www.virtualvirgin.net/

                d.healeyD ustkU 2 Replies Last reply Reply Quote 0
                • d.healeyD
                  d.healey @VirtualVirgin
                  last edited by

                  @VirtualVirgin Your font files need to be in the project's images folder.

                  Link Preview Image
                  HISE | Scripting | Engine

                  An API class for accessing global properties.

                  favicon

                  (docs.hise.dev)

                  Libre Wave - Freedom respecting instruments and effects
                  My Patreon - HISE tutorials
                  YouTube Channel - Public HISE tutorials

                  VirtualVirginV 1 Reply Last reply Reply Quote 0
                  • ustkU
                    ustk @VirtualVirgin
                    last edited by

                    @VirtualVirgin it's not in the appData folder but in project's folder you access using the wildcard {PROJECT_FOLDER} as in my example

                    Hise made me an F5 dude, browser just suffers...

                    VirtualVirginV 1 Reply Last reply Reply Quote 0
                    • VirtualVirginV
                      VirtualVirgin @d.healey
                      last edited by

                      @d-healey They are.

                      You can listen to my orchestral mockups here:
                      https://www.virtualvirgin.net/

                      1 Reply Last reply Reply Quote 0
                      • VirtualVirginV
                        VirtualVirgin @ustk
                        last edited by

                        @ustk It doesn't seem to resolve to anything though: Screenshot 2025-08-29 at 8.36.48 PM.png

                        You can listen to my orchestral mockups here:
                        https://www.virtualvirgin.net/

                        1 Reply Last reply Reply Quote 0
                        • VirtualVirginV
                          VirtualVirgin
                          last edited by

                          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?

                          Screenshot 2025-08-29 at 9.00.03 PM.png

                          You can listen to my orchestral mockups here:
                          https://www.virtualvirgin.net/

                          1 Reply Last reply Reply Quote 0
                          • VirtualVirginV
                            VirtualVirgin
                            last edited by VirtualVirgin

                            Ok, well I made it to the Fonts folder by navigating form the Audio folder, back to the Project folder, then on down.Screenshot 2025-08-29 at 9.36.45 PM.png

                            But now I'm having an issue with

                            File.toString();
                            

                            which returns the path for "Filename" instead of just the filename:

                            Screenshot 2025-08-29 at 9.39.50 PM.png

                            The Docs says it should just return the file name and not the full path:

                            Screenshot 2025-08-29 at 9.40.10 PM.png

                            You can listen to my orchestral mockups here:
                            https://www.virtualvirgin.net/

                            d.healeyD 1 Reply Last reply Reply Quote 1
                            • d.healeyD
                              d.healey @VirtualVirgin
                              last edited by

                              @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

                              Libre Wave - Freedom respecting instruments and effects
                              My Patreon - HISE tutorials
                              YouTube Channel - Public HISE tutorials

                              VirtualVirginV 1 Reply Last reply Reply Quote 0
                              • VirtualVirginV
                                VirtualVirgin
                                last edited by

                                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);
                                	}
                                }
                                

                                You can listen to my orchestral mockups here:
                                https://www.virtualvirgin.net/

                                1 Reply Last reply Reply Quote 0
                                • VirtualVirginV
                                  VirtualVirgin @d.healey
                                  last edited by VirtualVirgin

                                  @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?

                                  You can listen to my orchestral mockups here:
                                  https://www.virtualvirgin.net/

                                  d.healeyD 1 Reply Last reply Reply Quote 0
                                  • d.healeyD
                                    d.healey @VirtualVirgin
                                    last edited by

                                    @VirtualVirgin might work, try it in the compiled plugin and let us know

                                    Libre Wave - Freedom respecting instruments and effects
                                    My Patreon - HISE tutorials
                                    YouTube Channel - Public HISE tutorials

                                    1 Reply Last reply Reply Quote 0
                                    • First post
                                      Last post

                                    23

                                    Online

                                    1.9k

                                    Users

                                    12.4k

                                    Topics

                                    107.9k

                                    Posts