earlSt1 / vtt-custom-nameplates

Custom Nameplates for FoundryVTT
GNU General Public License v3.0
1 stars 2 forks source link

suggestion: allow for custom fonts #2

Closed EsotericOdyssey closed 1 year ago

EsotericOdyssey commented 3 years ago

idk how feasible this is but it would be nice to be able to use a font you just have in a folder in the world data or something

Simyonovich commented 1 year ago

yes please. I had this working for a hot minute but now only the 7 base fonts are available, even though I've got custom fonts enabled to use the aniron (tolkein style) fonts for everything. Makes all my tokens look out of place now that only the basic fonts are available.

RAChoco commented 1 year ago

With the help of another user on the Foundry Discord I've found a temporary fix for this!

Kudos to LorduFreeman for helping me with this, he was instrumental in me working this out!

I'd like to note I'm a novice at this sort of thing so I will break this down as much as I can for the benefit of any other newbies reading, though I suspect I'm probably going to be the greenest person who touches any of this.

Create a world script - basically open your world.json file where your world's files are stored in Foundry (likely C:\Users[YourUsername]\AppData\Local\FoundryVTT\Data\worlds\world-name\world.json) and add the esmodules line exactly as below. The javascript file (.js) is what we'll name the file but call it whatever you like.

{
  "title": "World Name",
  "id": "world-name",
  "system": "yourSystem",
  "coreVersion": "10.291",
  "esmodules": ["./worldFont.js" ],
  "compatibility": {
    "minimum": "10",
    "verified": "10"
  },
  "systemVersion": "4.1.0"
}

In a new file in the same world folder named worldFont.js we'll enter the text below:

Hooks.on("init", () => {

    CONFIG.fontDefinitions["FontName"] = {
  editor: true,
  fonts: [
    {urls: ["font file location.ttf"]}
        ]
    };

});

Ideally you should have configured additional fonts in Foundry's Core Settings. I did this by downloading a font from Google Fonts (any .ttf file should work really), adding the font file, and naming the font family in Foundry's default dialog menu for this. Whatever you name the font you uploaded, insert that in place of FontName in the code block above, and place the precise file location of the font file (for me that's C:\Users[YourUsername]\AppData\Local\FoundryVTT\Data\fonts\Font.ttf) in place of "font file location.ttf". Apologies for the messy syntax as I've described it but in general retain any syntax exactly as noted above.

See the below screenshot for an example of it working.

https://i.imgur.com/50cArX6.png

earlSt1 commented 1 year ago

Hi all, sorry for the long wait, but i just released v2.1.3 which allows you to use fonts defined in the Additional Fonts dialog in the nameplate edit dialog. Let me know if you run into any issues!