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

Make crate no_std compatible #67

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

fschutt
Copy link

@fschutt fschutt commented Feb 3, 2021

This patch makes the crate compatible on no_std (embedded) environments. The API stays the same. If possible, please publish a new version after merging.

@greyblake
Copy link
Owner

@fschutt Hi, thanks for the PR!
Just out of curiosity: is there any real use case whatlang and no_std?

@fschutt
Copy link
Author

fschutt commented Feb 4, 2021

Yes, because together with yeslogic/allsorts#42 and hsivonen/encoding_rs#66 I can then port azul-text-layout to no_std, so that I can get a text-layouting crate to work on embedded hardware. Eventually, this will enable embedded support for the entire https://azul.rs/ framework (once I have text layout, regular layout and a software renderer running on no_std, there's nothing stopping Rust from being used for embedded GUIs).

This might not have been the intended use of this library, but I'm currently using it to estimate the script of user input, so that I can select the proper font shaping algorithm.

@greyblake
Copy link
Owner

@fschutt
Did you I get it right: you consider using whatlang to identify only script (writing system like Cyrillic, Latin, Arabic, etc) but not really languages?

If so, would it be better for you to be able to access only detect_script functionality without reset of that whatlang library (whatlang cares language trigrams models that are about 3-4Mb, and they are not needed for script detection).

If above is right, then maybe we should consider extracting detect_script functionality into a separate crate.

@fschutt
Copy link
Author

fschutt commented Feb 4, 2021

Well right now, I need to pass the language to allsorts gsub_apply function here:

image

You are right that this probably won't work on devices with low memory constraints (for those devices I could just pass in None as the language). For desktop applications it probably doesn't matter because they have enough memory.

Setting the lang attribute is required for using the langsys table on fonts, but it isn't strictly necessary.

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

Successfully merging this pull request may close these issues.

2 participants