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

Allow startUnicode to start at 0xf0000 #256

Open
exil opened this issue Jan 22, 2025 · 3 comments
Open

Allow startUnicode to start at 0xf0000 #256

exil opened this issue Jan 22, 2025 · 3 comments

Comments

@exil
Copy link

exil commented Jan 22, 2025

I would like to have the startUnicode value be 0xf0000 but it does not seem to work. From what I can tell it is because String.fromCharCode used in writeFontStream only works up to 0xffff. Is it possible to support 5 digit unicode characters (such as using String.fromCodePoint instead?) or is there perhaps some workaround I can use in the meantime?

@jaywcjlove
Copy link
Owner

@exil Hello! This issue is because String.fromCharCode only supports characters up to 0xFFFF and cannot handle higher Unicode characters. If you want to support five-digit Unicode characters (such as 0xf0000), you should use String.fromCodePoint, which supports the full Unicode range, including characters from 0x10000 to 0x10FFFF.

You can try replacing String.fromCharCode with String.fromCodePoint in your code, and that should handle high-code characters. If the issue is resolved after the modification, feel free to submit a PR. You can test it first to see if it works, and if there are any problems, we can discuss further.

let encodedCodes: string | number = _code.charCodeAt(0);

encodedCodes = _code.split('').map(x => x.charCodeAt(0)).join(';&#');

-      let encodedCodes: string | number = _code.charCodeAt(0);
+      let encodedCodes: string | number = _code.codePointAt(0);

const curUnicode = String.fromCharCode(startUnicode);

- const curUnicode = String.fromCharCode(startUnicode);
+ const curUnicode = String.fromCodePoint(startUnicode);

@netcore-jroger
Copy link

@exil Did you try?

@exil
Copy link
Author

exil commented Feb 17, 2025

@exil Did you try?

I have not had a chance to try yet but I will keep you updated.

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

3 participants