PistonDevelopers / graphics

A library for 2D graphics, written in Rust, that works with multiple back-ends
MIT License
479 stars 55 forks source link

add 'invalid character" field to character struct #1163

Closed ayyEve closed 2 years ago

ayyEve commented 2 years ago

This will help with adding fallback font support downstream.

NOTE! This may be breaking if someone uses custom implementation of Character (since it adds an extra field). I'm not sure how likely this is to actually occur though.

I'm creating a PR regardless because I believe this would be extremely useful for games, especially multi-lingual games (like rhythm games, which is what I'm working on) where having multiple languages in the same text block is a common occurrence.

I did a quick cargo-check with the 3 main backends and they all build fine, so I assume there are no compatibility issues there.|

This was tested with Roboto trying to display Chinese characters (也馳驰), and using Kosugi Maru Regular to display the same characters. Displayed (valid) characters show as valid, and Errored (invalid) characters show as invalid.

bvssvni commented 2 years ago

Looks good!

bvssvni commented 2 years ago

Merging.

bvssvni commented 2 years ago

Thanks!