Need help! How to use font? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Need help! How to use font?

Actually I'm working in p5.js program. And in this library, a function "loadFont" loads font saved or installed in system. So my questions are "is it possible to use font without installing or downloading (using url) ?" "is it possible to use font downloaded or installed in system on Sololearn? " " and how can I use that font which is installed in my system on SOLOLEARN? "

27th Mar 2018, 2:24 PM
Dinesh Banjara
Dinesh Banjara - avatar
5 Answers
+ 9
@DINESH You can just use the font name in CSS like "Times New Roman" if it's installed in the client's device. However not all OS share the same font like Comis Sans in Windows and Roboto in Android as HTML is client-side. Therefore, it's better to have a fallback font in case you want to use custom font. 😉
27th Mar 2018, 2:39 PM
Zephyr Koo
Zephyr Koo - avatar
+ 5
Yes you can use url if you can find .otf or ttf files in the internet. Most shared fonts are for css.
27th Mar 2018, 2:31 PM
Toni Isotalo
Toni Isotalo - avatar
+ 5
But it in your web root. var font; function preload() { font = loadFont('font.otf'); } function setup() { textFont(myFont) //Activate your font } You can also use css fonts. element.style("font-family": "font name"); https://www.w3schools.com/cssref/css_websafe_fonts.asp
27th Mar 2018, 2:38 PM
Toni Isotalo
Toni Isotalo - avatar
+ 1
Thanks but what about a font installed in computer? How to load it?
27th Mar 2018, 2:33 PM
Dinesh Banjara
Dinesh Banjara - avatar
+ 1
Yes, it's possible function textFont('Font url/name') 😉
28th Jul 2019, 8:40 AM
AlfaV
AlfaV - avatar