Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "vendor/detect-writing-scripts/source"]
path = vendor/detect-writing-script/source
url = https://github.com/bramstein/detect-writing-script.git
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ repository = "https://github.com/the-type-founders/unicode-writing-script"
readme = "README.md"
categories = ["text-processing"]
keywords = ["writing-script", "unicode"]

[build-dependencies]
serde_json = { version = "1", default-features = false, features = ["std"] }
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Your contribution is highly appreciated. Do not hesitate to open an issue or a
pull request. Note that any contribution submitted for inclusion in the project
will be licensed according to the terms given in [LICENSE.md](LICENSE.md).

[build-img]: https://github.com/the-type-founders/unicode-writing-script-rs/workflows/build/badge.svg
[build-img]: https://github.com/the-type-founders/unicode-writing-script-rs/actions/workflows/build.yml/badge.svg
[build-url]: https://github.com/the-type-founders/unicode-writing-script-rs/actions/workflows/build.yml
[documentation-img]: https://docs.rs/unicode-writing-script/badge.svg
[documentation-url]: https://docs.rs/unicode-writing-script
Expand Down
25 changes: 25 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use std::collections::BTreeMap;
use std::fs::File;
use std::io::Write;
use std::path::Path;

const DATA: &str = include_str!("vendor/detect-writing-script/data.json");

macro_rules! ok(
($result:expr) => ($result.unwrap());
);

fn main() {
let data: BTreeMap<String, Vec<[u32; 2]>> = ok!(serde_json::from_str(DATA));
let script_count = data.len();

let root = ok!(std::env::var("OUT_DIR"));
let path = Path::new(&root).join("data.rs");
let mut file = ok!(File::create(&path));
ok!(write!(
file,
r#"
const SCRIPT_COUNT: usize = {script_count};
"#,
));
}
20 changes: 20 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,21 @@
//! Detection of writing scripts from Unicode codepoints.

include!(concat!(env!("OUT_DIR"), "/data.rs"));

/// A match.
#[derive(Clone, Copy)]
pub struct Match {
pub name: &'static str,
pub count: usize,
pub score: f64,
}

/// Detect writing scripts given ranges of Unicode codepoints.
pub fn detect<T>(_codepoints: T, _threshold: f64) -> Vec<Match>
where
T: IntoIterator<Item = [u32; 2]>,
{
let _ = [0; SCRIPT_COUNT];

unimplemented!()
}
5 changes: 5 additions & 0 deletions vendor/detect-writing-script/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
data.json:
node \
--input-type=module \
--eval "import data from './source/data/scripts.js'; console.log(JSON.stringify(data, null, 2))" \
> $@
Loading