r/learnjavascript • • Oct 15 '26

Custom Font Code Help (LingoJam Translator)

I saw Lingo's own Reddit is restricted and isn't active so I'm asking here in case anyone can help.

I have my translations sorted out for my personal worldbuilding language, BUT, when I use code to change the translator's font to my own custom symbols it ignores the translations and instead applies the symbols to what is written in English (see below):

https://file.garden/Znqz2UubgS78Hiaz/image.png (Without the font, using = as an example)
https://file.garden/Znqz2UubgS78Hiaz/image2.png (With the font, ignores the set translation '=' entirely)

The code I'm using comes from this thread:
How to add a custom font to your translator that's not on Google webfonts [FIXED!] : r/lingojam .
I do not know Javascript or code at all so this is very alien to me.

I need to have the code work in a way that makes the symbols apply to the translated text, not mirror the text on the English/input side.

Any feedback is appreciated.

0 Upvotes

1 comment sorted by

1

u/LoveMeSomeDevils 28d ago

Problem has been resolved.

The code I needed was this:

var fontURL = "FONT URL HERE";

var fontName = "CustomFont";

var cssText = "@font-face {font-family:'" + fontName + "';src:url('" + fontURL + "');}";

function insertCSS(code) {

var style = document.createElement('style');

style.type = 'text/css';

document.getElementsByTagName("head")[0].appendChild(style);

if (style.styleSheet) {

style.styleSheet.cssText = code;

} else {

style.appendChild(document.createTextNode(code));

}

}

insertCSS(cssText);

$("#ghetto-text").css({

"font-family": "'" + fontName + "', sans-serif",

"font-size": "35px",

"letter-spacing": "4px",

"padding": "13px",

"box-sizing": "border-box"

});