7 stable releases

2.0.3 May 31, 2024
2.0.2 May 30, 2024
2.0.1 Aug 18, 2023
1.2.0 Aug 16, 2023

#111 in Internationalization (i18n)

Download history 147/week @ 2024-06-17 310/week @ 2024-06-24 70/week @ 2024-07-01 29/week @ 2024-07-08 177/week @ 2024-07-15 1/week @ 2024-07-22 138/week @ 2024-07-29 50/week @ 2024-08-05 163/week @ 2024-08-12 195/week @ 2024-08-19 199/week @ 2024-08-26 9/week @ 2024-09-02 1/week @ 2024-09-09 29/week @ 2024-09-16 34/week @ 2024-09-23 20/week @ 2024-09-30

84 downloads per month

Apache-2.0

82KB
384 lines

Unicode Language

This library detects language support given a list of Unicode codepoints. This is primarily useful for finding out what languages a font supports.

// Input codepoints as a vector of Unicode ranges
let codepoints = vec![[65, 121]];

// Detect languages with a threshold of 0.5
let results = detect(codepoints, 0.5);

// results[0].tag = "en"
// results[1].tag = "nl"
// ...

The result is a vector of Match structs, with the following signature:

struct Match {
  // BCP 47 language tag.
  tag: &'static str,
  // English name.
  name: &'static str,
  // Name in native script.
  native: &'static str,
  // Number of codepoints matched.
  count: u32,
  // Score (number of codepoints matched divided by the total).
  score: f64,
}

The language data is derived from Adobe Font's speakeasy library. The data is extracted at build time and statically compiled as part of the library.

License

This library is licensed under the Apache-2.0 license. Copyright 2023, The Type Founders.

No runtime deps

~0–345KB