question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError is thrown when layout.scripts is null in 0.6.9

See original GitHub issue

TypeError: Cannot read property ‘length’ of undefined

at Object.Layout.getDefaultScriptName
(.../node_modules/opentype.js/src/layout.js:111:43)
at Font.stringToGlyphs
(.../node_modules/opentype.js/src/font.js:155:58)
   /**
     * Returns the best bet for a script name.
     * Returns 'DFLT' if it exists.
     * If not, returns 'latn' if it exists.
     * If neither exist, returns undefined.
     */
    getDefaultScriptName: function() {
        var layout = this.getTable();
        if (!layout) { return; }
        var hasLatn = false;
        for (var i = 0; i < layout.scripts.length; i++) {
            var name = layout.scripts[i].tag;
            if (name === 'DFLT') return name;
            if (name === 'latn') hasLatn = true;
        }
        if (hasLatn) return 'latn';
    },

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Jolg42commented, Feb 17, 2018

It should be fixed in master (I need to build the dist files) thanks to @fpirsch 👍

1reaction
TeisDcommented, Oct 3, 2017

I fixed this in my application by modifying getTable in layout.js like this:

   /**
     * Get or create the Layout table (GSUB, GPOS etc).
     * @param  {boolean} create - Whether to create a new one.
     * @return {Object} The GSUB or GPOS table.
     */
    getTable: function(create) {
        let layout = this.font.tables[this.tableName];
        if ((!layout && create) || layout.scripts === undefined) {
            layout = this.font.tables[this.tableName] = this.createDefaultTable();
        }
        return layout;
    },

It didn’t break anything else so far, but it’s not really a solution as it doesn’t address the underlying problem (which I couldn’t locate).

Anyway, it might be useful as a reference to anyone looking for a quick fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

JavaScript TypeError: Cannot read property 'style' of null
It sounds like the <div> Noite does not exist when you're calling this script. Try moving the javascript to the body of your...
Read more >
uncaught typeerror cannot set properties of null ... - You.com
I am just learning java script so I am pretty new at it. I have been trying to debug it for at-least 1...
Read more >
Changelog - Cypress Documentation
Correctly cast the CYPRESS_VERIFY_TIMEOUT environment variable as a number so Cypress will no longer throw TypeError: Expected the timeout option to be a ......
Read more >
Uncaught TypeError: Cannot read property of null - iDiallo
All this means is that you are trying to access a property of an object that is undefined. These usually happens when we...
Read more >
Bug listing with status RESOLVED with resolution FIXED as at ...
... Bug:68 - "revised ntp ebuild script for ntp 4.1.72" status:RESOLVED ... baselayout 1.7.0-r1" status:RESOLVED resolution:FIXED severity:minor ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found