Module [font] not found

Posted on
  • I'm trying to add a a set of fonts to Graphics.
    The list is big, so I'm using an array. (Below list is just an example)

    // DOESN'T WORK
    ["FontTeletext10x18Mode7", "FontHaxorNarrow7x17", "Font8x12"].forEach((font) => {
        require(font).add(Graphics);
    });
    

    I get back an error, Module FontTeletext10x18Mode7 not found.
    However, adding them individually seems to work.

    // WORKS
    require("FontTeletext10x18Mode7").add(Gr­aphics);
    require("FontHaxorNarrow7x17").add(Graph­ics);
    require("Font8x12").add(Graphics);
    

    Why can't I use an array to add fonts?

  • The fonts (and most other modules) aren't built-in to the watch: when you do require("Font8x12"), the uploader is smart enough to figure out you want to use Font8x12, and includes it in-line with the uploaded code.
    But the uploader isn't smart enough to figure out which module to include for require(<variable>).

  • Ohh I see, thank you! Is my second code block the only way to do it then?

  • Is my second code block the only way to do it then?

    More or less, yes... You need the actual text require("FontTeletext10x18Mode7") in the code. You could do [require("FontTeletext10x18Mode7"), ...] and so on though.

  • Ah alright, thank you Gordon!

  • Hey again Gordon, I have the following on the top of my file.

    require("FontTeletext10x18Mode7").add(Gr­aphics);
    require("FontHaxorNarrow7x17").add(Graph­ics);
    require("Font8x12").add(Graphics);
    

    Still when I try to run my program on my Bangle.js 1 it returns Uncaught Error: Module FontTeletext10x18Mode7 not found.
    I have tried using adding it on both the right and left-hand sides of the IDE. The left side gives me the same error.

    What can I do?

    EDIT: I solved it, I was uploading the JS file when I should have run it through the IDE.

  • Font not found after upgrade to firmware 2v14.
    current firmware version is 2v14 and bootloader is 2v12.

    require("Font8x16").add(Graphics);
    g.setFont8x16();
    g.drawString("0123456789");
    
    >Uncaught Error: Module Font8x16 not found
     at line 1 col 19
    require("Font8x16").add(Graphics);
    

    Settings/Communications Module URL is set to http://www.espruino.com/modules/

    Please advise.

  • It looks like something is wrong with my Chrome in Linux. It cannot load modules for Emulator too.
    Chrome in Windows works well.

    It appears that in windows it does not work same way when I put http://www.espruino.com/modules/ into Settings. It works with HTTPS.

    I've put https://www.espruino.com/modules/ that in Linux Chrome. And it works!

  • I think it's pretty standard - if you look at the chrome dev console it'll probably say something like "Can't load insecure HTTP from secure HTTPS page".

    https://www.espruino.com/modules/ should have been set as the default modules URL, so is it possible you changed it to http?

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Module [font] not found

Posted by Avatar for Asynchronous @Asynchronous

Actions