more char sets for font
@@ -46,6 +46,12 @@ pub struct Font {
#[derive(Debug, Clone)]
pub struct SharedFont(pub Arc<Mutex<Font>>);
+impl SharedFont {
+ pub fn new(font: Font) -> Self {
+ Self(Arc::new(Mutex::new(font)))
+ }
+}
+
impl From<Arc<Mutex<Font>>> for SharedFont {
fn from(arc: Arc<Mutex<Font>>) -> Self {
SharedFont(arc)
@@ -66,7 +72,81 @@ impl Debug for Font {
impl Font {
pub fn default_char_set() -> &'static [Range<u32>] {
- &[0x0020..0x00FF] // Basic Latin + Latin Supplement
+ &[
+ // Basic Latin + Latin Supplement
+ 0x0020..0x00FF,
+ ]
+ }
+
+ pub fn korean_char_set() -> &'static [Range<u32>] {
+ &[
+ // Basic Latin + Latin Supplement
+ 0x0020..0x00FF,
+ // Korean alphabets
+ 0x3131..0x3163,
+ // Korean characters
+ 0xAC00..0xD7A3,
+ // Invalid
+ 0xFFFD..0xFFFD,
+ ]
+ }
+
+ pub fn chinese_full_char_set() -> &'static [Range<u32>] {
+ &[
+ // Basic Latin + Latin Supplement
+ 0x0020..0x00FF,
+ // General Punctuation
+ 0x2000..0x206F,
+ // CJK Symbols and Punctuations, Hiragana, Katakana
+ 0x3000..0x30FF,
+ // Katakana Phonetic Extensions
+ 0x31F0..0x31FF,
+ // Half-width characters
+ 0xFF00..0xFFEF,
+ // Invalid
+ 0xFFFD..0xFFFD,
+ // CJK Ideograms
+ 0x4e00..0x9FAF,
+ ]
+ }
+
+ pub fn cyrillic_char_set() -> &'static [Range<u32>] {
+ &[
+ // Basic Latin + Latin Supplement
+ 0x0020..0x00FF,
+ // Cyrillic + Cyrillic Supplement
+ 0x0400..0x052F,
+ // Cyrillic Extended-A
+ 0x2DE0..0x2DFF,
+ // Cyrillic Extended-B
+ 0xA640..0xA69F,
+ ]
+ }
+
+ pub fn thai_char_set() -> &'static [Range<u32>] {
+ &[
+ // Basic Latin + Latin Supplement
+ 0x0020..0x00FF,
+ // Punctuations
+ 0x2010..0x205E,
+ // Thai
+ 0x0E00..0x0E7F,
+ ]
+ }
+
+ pub fn vietnamese_char_set() -> &'static [Range<u32>] {
+ &[
+ // Basic Latin + Latin Supplement
+ 0x0020..0x00FF,
+ // Vietnamese
+ 0x0102..0x0103,
+ 0x0110..0x0111,
+ 0x0128..0x0129,
+ 0x0168..0x0169,
+ 0x01A0..0x01A1,
+ 0x01AF..0x01B0,
+ 0x1EA0..0x1EF9,
+ ]
}
pub fn from_memory(
