Can't load the font

I can't run this font and it's occurring the warning '20673: Uncaught Font could not be loaded: Not Found'. I still can't figure it out what's wrong with the code. Please give me a hand! Thx!! 螢幕快照 2015-09-30 下午09.13.08

Answers

  • edited September 2015

    You don’t simply call your font file in loadFont() command. You need to load a valid version for Processing using the tool in the main menu of the application. This will make a bitmap copy of a predetermined size, and put it in your data folder. The suffixe would then be .vlw and not .ttf
    myFont = loadFont("Mistral-36.vlw");

    If you prefer to use the original Font file (vectorial) and not making a bitmap copy, then the command should be createFont(), like this one :
    myFont = createFont("Mistral.ttf", 36);

    Be careful to use double quotes. The name of your file is called as a string, not as a character.

  • I will add an info : the first option should be preferred if you think of bring your Processing sketch (or the exported app) on different computer and your not sure if there will be the font that you are using. The down side is that the bitmap copy of your font will show nicely only if you’re respecting the size that you picked at the time you create the .vlw file in your data.

  • edited September 2015

    @19941202lwk, please prefer pasting code instead of screenshots so we can actually use CTRL+C there:
    http://forum.Processing.org/two/discussion/8045/how-to-format-code-and-text

    In myFont = loadFont('Mistral.ttf');, it's assumed "Mistral.ttf" is in the same folder as your JS file sketch.
    Also, pay attention to capitalization. Check out "Mistral.ttf" really matches the file name.

    If it still fails, please post your ".html" file as well. Maybe the default path was changed there. :-@

  • edited October 2015

    Oups! I did not notice that this post was in p5.js category. I was assuming it was a general programming question.
    Did you have a look at this example?
    http://p5js.org/reference/#/p5.Font/textBounds
    Also, I remember that it was more easy to use certain type of font file. .otf (open type font) seems to work better than true type font (.ttf). So maybe this is the source of your problem?

  • Hit F12 to open the console. Look for a failed request: this will confirm a request is being made - i.e. The command executed successfully - and the path at which it's trying to access the file. This should help establish the cause of the problem.

    Given the error message it seems unlikely, but if you are testing with local files on your machine this might also be caused by browser security restrictions. You need to run a test server; or switch browser to Firefox dev as @GoToLoop will no doubt mention...

  • I find that we should preview in Firefox as this browser could preview the preload font! thanks everyone help me here !

Sign In or Register to comment.