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

getAvailableFontsSync() don't return the latest font info when called multiple times. #55

Open
random-yang opened this issue Sep 10, 2021 · 2 comments

Comments

@random-yang
Copy link

No description provided.

@aalexgabi
Copy link

I tested the async and sync versions on Windows and both seem to work for me:

import { createRequire } from "module";
const require = createRequire(import.meta.url);
const fontManager = require('font-manager');


// fontManager.getAvailableFonts((fonts) => {
//     const filterdFonts = fonts.filter((font) => font.family.includes('Consolas'));
//     console.log('fonts', filterdFonts);
// });


const fonts = fontManager.getAvailableFontsSync();
const filterdFonts = fonts.filter((font) => font.family.includes('Consolas'));
console.log('fonts', filterdFonts);

I'm using git+https://github.com/q-lukasz/font-manager.git#issue-45--compile-error-mac-os-x--node-13-7 as upstream. Not sure if that includes more fixes.

@aalexgabi
Copy link

@random-yang I think I managed to "reproduce" this by running it in a loop that lists and unregisters fonts in windows. I am doing this because in Windows fonts are in a table so if you register a font multiple times it has multiple entries in that table.

I also ran this in a separate script (different process) and I still had the same issue so it's not related to the library but seem to be related by the latency in windows in uregistering fonts (at least in my case).

I assume you are not unregistering fonts. In that case the issue may be that the font is registered multiple times so it seems like font-manager returns a cached result.

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