Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete glyph #782

Open
qxygene1 opened this issue Jan 8, 2025 · 1 comment
Open

Delete glyph #782

qxygene1 opened this issue Jan 8, 2025 · 1 comment

Comments

@qxygene1
Copy link

qxygene1 commented Jan 8, 2025

Expected Behavior

Current Behavior

Possible Solution

Steps to Reproduce (for bugs)

Context

Your Environment

  • Version used:
  • Font used:
  • Browser Name and version:
  • Operating System and version (desktop or mobile):
  • Link to your project:

Not able to remove glyph with index;

code so far;

    for (let i = 0; i < font.glyphs.length; i++) {
        let glyph = font.glyphs.get(i);
        //console.log(glyph);
        if (glyph.index === 15) {
            //glyph = null;
            //delete window.glyph;
            //glyph.splice(i, 1);
            console.log(glyph);
        }
    }
@mattlag
Copy link
Contributor

mattlag commented Feb 8, 2025

It doesn't look like font has a built in delete or remove glyph function. font.glyphs is just a regular JavaScript object, so you may want to try deleting an entry the normal JavaScript way. Also, since it's an object, it won't (necessarily) have a length property and you shouldn't iterate over it like an array. This only happens to work for the glyphs object because it was set up such that they keys are the same as the glyph.index property.

You probably mean to do something like this:

for(let key in font.glyphs) {
  if(font.glyphs[key].index === 15)
    delete font.glyphs[key];
    break;
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants