diff --git a/.github/copyright.sh b/.github/copyright.sh index 5da12dee2..356408bf6 100644 --- a/.github/copyright.sh +++ b/.github/copyright.sh @@ -8,7 +8,7 @@ # Check all the standard Rust source files # Exclude the Emoji picker example because it also has some MIT licensed content -output=$(rg "^// Copyright (19|20)[\d]{2} (.+ and )?the Xilem Authors( and .+)?$\n^// SPDX-License-Identifier: Apache-2\.0$\n\n" --files-without-match --multiline -g "*.rs" -g "!xilem/examples/emoji_picker/emoji_data.rs" .) +output=$(rg "^// Copyright (19|20)[\d]{2} (.+ and )?the Xilem Authors( and .+)?$\n^// SPDX-License-Identifier: Apache-2\.0$\n\n" --files-without-match --multiline -g "*.rs" .) if [ -n "$output" ]; then echo -e "The following files lack the correct copyright header:\n" diff --git a/README.md b/README.md index e5990dcba..f5411c30c 100644 --- a/README.md +++ b/README.md @@ -164,6 +164,7 @@ Some files used for examples are under different licenses: - The font file (`RobotoFlex-Subset.ttf`) in `xilem/resources/fonts/roboto_flex/` is licensed solely as documented in that folder (and is not licensed under the Apache License, Version 2.0). - The data file (`status.csv`) in `xilem/resources/data/http_cats_status/` is licensed solely as documented in that folder (and is not licensed under the Apache License, Version 2.0). +- The data file (`emoji.csv`) in `xilem/resources/data/emoji_names/` is licensed solely as documented in that folder (and is not licensed under the Apache License, Version 2.0). ## Contribution diff --git a/xilem/Cargo.toml b/xilem/Cargo.toml index a9ad036b4..f9dedb822 100644 --- a/xilem/Cargo.toml +++ b/xilem/Cargo.toml @@ -9,7 +9,11 @@ license.workspace = true repository.workspace = true homepage.workspace = true rust-version.workspace = true -exclude = ["/resources/fonts/roboto_flex/", "/resources/data/http_cats_status/"] +exclude = [ + "/resources/fonts/roboto_flex/", + "/resources/data/http_cats_status/", + "/resources/data/emoji_names/", +] [package.metadata.docs.rs] all-features = true @@ -83,7 +87,7 @@ name = "emoji_picker" [[example]] name = "emoji_picker_android" -path = "examples/emoji_picker/main.rs" +path = "examples/emoji_picker.rs" # cdylib is required for cargo-apk crate-type = ["cdylib"] diff --git a/xilem/README.md b/xilem/README.md index d51bf26c1..9b3f59a2d 100644 --- a/xilem/README.md +++ b/xilem/README.md @@ -68,6 +68,7 @@ Some files used for examples are under different licenses: * The font file (`RobotoFlex-Subset.ttf`) in `resources/fonts/roboto_flex/` is licensed solely as documented in that folder (and is not licensed under the Apache License, Version 2.0). * The data file (`status.csv`) in `resources/data/http_cats_status/` is licensed solely as documented in that folder (and is not licensed under the Apache License, Version 2.0). +* The data file (`emoji.csv`) in `resources/data/emoji_names/` is licensed solely as documented in that folder (and is not licensed under the Apache License, Version 2.0). Note that these files are *not* distributed with the released crate. diff --git a/xilem/examples/emoji_picker/main.rs b/xilem/examples/emoji_picker.rs similarity index 82% rename from xilem/examples/emoji_picker/main.rs rename to xilem/examples/emoji_picker.rs index fcbe829c5..5e2d17e0a 100644 --- a/xilem/examples/emoji_picker/main.rs +++ b/xilem/examples/emoji_picker.rs @@ -1,18 +1,10 @@ // Copyright 2024 the Xilem Authors -// SPDX-License-Identifier: Apache-2.0 OR MIT +// SPDX-License-Identifier: Apache 2.0 //! A simple emoji picker. -//! It is expected that the Emoji in this example may not render. -//! This is because Vello does not support any kinds of bitmap fonts. -//! -//! Note that the MIT license is needed because of the emoji data. -//! Everything except for the [`EMOJI`] constant is Apache 2.0 licensed. #![expect(clippy::shadow_unrelated, reason = "Idiomatic for Xilem users")] -mod emoji_data; - -use emoji_data::EMOJI; use winit::error::EventLoopError; use xilem::{ core::map_state, @@ -40,12 +32,12 @@ fn app_logic(data: &mut EmojiPagination) -> impl WidgetView { paginate( data.start_index, (data.size * data.size) as usize, - EMOJI.len(), + data.emoji.len(), ), |state: &mut EmojiPagination| &mut state.start_index, ), data.last_selected - .map(|idx| label(format!("Selected: {}", EMOJI[idx].display)).text_size(40.)), + .map(|idx| label(format!("Selected: {}", data.emoji[idx].display)).text_size(40.)), )) .direction(Axis::Vertical) } @@ -60,7 +52,7 @@ fn picker(data: &mut EmojiPagination) -> impl WidgetView { let row_idx = data.start_index + y * data.size as usize; for x in 0..data.size as usize { let idx = row_idx + x; - let emoji = EMOJI.get(idx); + let emoji = data.emoji.get(idx); // TODO: Use OneOf2 let view: Box> = match emoji { Some(emoji) => { @@ -123,29 +115,54 @@ struct EmojiPagination { size: u32, last_selected: Option, start_index: usize, + emoji: Vec, } fn run(event_loop: EventLoopBuilder) -> Result<(), EventLoopError> { + let emoji = EmojiInfo::parse_file(); let data = EmojiPagination { size: 4, last_selected: None, start_index: 0, + emoji, }; let app = Xilem::new(data, app_logic); app.run_windowed(event_loop, "First Example".into()) } -// Helpers for the emoji_data module. That is a separate file for licensing reasons. struct EmojiInfo { name: &'static str, display: &'static str, } -const fn e(display: &'static str, name: &'static str) -> EmojiInfo { - EmojiInfo { name, display } +impl EmojiInfo { + /// Parse the supported emoji's information. + fn parse_file() -> Vec { + let mut lines = EMOJI_NAMES_CSV.lines(); + let first_line = lines.next(); + assert_eq!( + first_line, + Some("display,name"), + "Probably wrong CSV-like file" + ); + lines.flat_map(Self::parse_single).collect() + } + + fn parse_single(line: &'static str) -> Option { + let (display, name) = line.split_once(',')?; + Some(Self { display, name }) + } } +/// A subset of emoji data from , used under the MIT license. +/// Full details can be found in `xilem/resources/data/emoji_names/README.md` from +/// the workspace root. +const EMOJI_NAMES_CSV: &str = include_str!(concat!( + env!("CARGO_MANIFEST_DIR"), + "/resources/data/emoji_names/emoji.csv", +)); + // Boilerplate code: Identical across all applications which support Android #[expect(clippy::allow_attributes, reason = "No way to specify the condition")] diff --git a/xilem/examples/emoji_picker/emoji_data.rs b/xilem/examples/emoji_picker/emoji_data.rs deleted file mode 100644 index f43d66d09..000000000 --- a/xilem/examples/emoji_picker/emoji_data.rs +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright 2013 the Xilem Authors and Cal Henderson -// SPDX-License-Identifier: MIT - -// The MIT License (MIT) -// -// Copyright (c) 2013 Cal Henderson -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -use crate::{e, EmojiInfo}; - -/// Data adapted as a subset of -/// under the MIT License. Full license text can be found above in the source file. -pub(crate) const EMOJI: &[EmojiInfo] = &[ - e("😁", "grinning face with smiling eyes"), - e("😂", "face with tears of joy"), - e("😃", "smiling face with open mouth"), - e("😄", "smiling face with open mouth and smiling eyes"), - e("😅", "smiling face with open mouth and cold sweat"), - e("😆", "smiling face with open mouth and tightly-closed eyes"), - e("😇", "smiling face with halo"), - e("😈", "smiling face with horns"), - e("😉", "winking face"), - e("😊", "smiling face with smiling eyes"), - e("😋", "face savouring delicious food"), - e("😌", "relieved face"), - e("😍", "smiling face with heart-shaped eyes"), - e("😎", "smiling face with sunglasses"), - e("😏", "smirking face"), - e("😐", "neutral face"), - e("😑", "expressionless face"), - e("😒", "unamused face"), - e("😓", "face with cold sweat"), - e("😔", "pensive face"), - e("😕", "confused face"), - e("😖", "confounded face"), - e("😗", "kissing face"), - e("😘", "face throwing a kiss"), - e("😙", "kissing face with smiling eyes"), - e("😚", "kissing face with closed eyes"), - e("😛", "face with stuck-out tongue"), - e("😜", "face with stuck-out tongue and winking eye"), - e("😝", "face with stuck-out tongue and tightly-closed eyes"), - e("😞", "disappointed face"), - e("😟", "worried face"), - e("😠", "angry face"), - e("😡", "pouting face"), - e("😢", "crying face"), - e("😣", "persevering face"), - e("😤", "face with look of triumph"), - e("😥", "disappointed but relieved face"), - e("😦", "frowning face with open mouth"), - e("😧", "anguished face"), - e("😨", "fearful face"), - e("😩", "weary face"), - e("😪", "sleepy face"), - e("😫", "tired face"), - e("😬", "grimacing face"), - e("😭", "loudly crying face"), - e("😮‍💨", "face exhaling"), - e("😮", "face with open mouth"), - e("😯", "hushed face"), - e("😰", "face with open mouth and cold sweat"), - e("😱", "face screaming in fear"), - e("😲", "astonished face"), - e("😳", "flushed face"), - e("😴", "sleeping face"), - e("😵‍💫", "face with spiral eyes"), - e("😵", "dizzy face"), - e("😶‍🌫️", "face in clouds"), - e("😶", "face without mouth"), - e("😷", "face with medical mask"), - e("😸", "grinning cat face with smiling eyes"), - e("😹", "cat face with tears of joy"), - e("😺", "smiling cat face with open mouth"), - e("😻", "smiling cat face with heart-shaped eyes"), - e("😼", "cat face with wry smile"), - e("😽", "kissing cat face with closed eyes"), - e("😾", "pouting cat face"), - e("😿", "crying cat face"), - e("🙀", "weary cat face"), - e("🙁", "slightly frowning face"), - e("🙂‍↔️", "head shaking horizontally"), - e("🙂‍↕️", "head shaking vertically"), - e("🙂", "slightly smiling face"), - e("🙃", "upside-down face"), - e("🙄", "face with rolling eyes"), - e("🙅‍♀️", "woman gesturing no"), - e("🙅‍♂️", "man gesturing no"), - e("🙅", "face with no good gesture"), - e("🙆‍♀️", "woman gesturing ok"), - e("🙆‍♂️", "man gesturing ok"), - e("🙆", "face with ok gesture"), - e("🙇‍♀️", "woman bowing"), - e("🙇‍♂️", "man bowing"), - e("🙇", "person bowing deeply"), - e("🙈", "see-no-evil monkey"), - e("🙉", "hear-no-evil monkey"), - e("🙊", "speak-no-evil monkey"), - e("🙋‍♀️", "woman raising hand"), - e("🙋‍♂️", "man raising hand"), - e("🙋", "happy person raising one hand"), - e("🙌", "person raising both hands in celebration"), - e("🙍‍♀️", "woman frowning"), - e("🙍‍♂️", "man frowning"), - e("🙍", "person frowning"), - e("🙎‍♀️", "woman pouting"), - e("🙎‍♂️", "man pouting"), - e("🙎", "person with pouting face"), - e("🙏", "person with folded hands"), - e("🚀", "rocket"), - e("🚁", "helicopter"), -]; diff --git a/xilem/resources/data/emoji_names/LICENSE b/xilem/resources/data/emoji_names/LICENSE new file mode 100644 index 000000000..85ddb3c0f --- /dev/null +++ b/xilem/resources/data/emoji_names/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2013 Cal Henderson + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/xilem/resources/data/emoji_names/README.md b/xilem/resources/data/emoji_names/README.md new file mode 100644 index 000000000..ca4e098d4 --- /dev/null +++ b/xilem/resources/data/emoji_names/README.md @@ -0,0 +1,10 @@ +# Emoji names + +The data in emoji.csv was adapted as a subset of . +These were extracted from on 2024-09-03, +specifically as at commit [`a8174c74675355c8c6a9564516b2e961fe7257ef`](https://github.com/iamcal/emoji-data/blob/a8174c74675355c8c6a9564516b2e961fe7257ef/emoji_pretty.json). +Full license text can be found above in the source file. + +## License + +These are licensed solely under the MIT license, as found in [LICENSE](./LICENSE). diff --git a/xilem/resources/data/emoji_names/emoji.csv b/xilem/resources/data/emoji_names/emoji.csv new file mode 100644 index 000000000..1cd1ef8de --- /dev/null +++ b/xilem/resources/data/emoji_names/emoji.csv @@ -0,0 +1,99 @@ +display,name +😁,grinning face with smiling eyes +😂,face with tears of joy +😃,smiling face with open mouth +😄,smiling face with open mouth and smiling eyes +😅,smiling face with open mouth and cold sweat +😆,smiling face with open mouth and tightly-closed eyes +😇,smiling face with halo +😈,smiling face with horns +😉,winking face +😊,smiling face with smiling eyes +😋,face savouring delicious food +😌,relieved face +😍,smiling face with heart-shaped eyes +😎,smiling face with sunglasses +😏,smirking face +😐,neutral face +😑,expressionless face +😒,unamused face +😓,face with cold sweat +😔,pensive face +😕,confused face +😖,confounded face +😗,kissing face +😘,face throwing a kiss +😙,kissing face with smiling eyes +😚,kissing face with closed eyes +😛,face with stuck-out tongue +😜,face with stuck-out tongue and winking eye +😝,face with stuck-out tongue and tightly-closed eyes +😞,disappointed face +😟,worried face +😠,angry face +😡,pouting face +😢,crying face +😣,persevering face +😤,face with look of triumph +😥,disappointed but relieved face +😦,frowning face with open mouth +😧,anguished face +😨,fearful face +😩,weary face +😪,sleepy face +😫,tired face +😬,grimacing face +😭,loudly crying face +😮‍💨,face exhaling +😮,face with open mouth +😯,hushed face +😰,face with open mouth and cold sweat +😱,face screaming in fear +😲,astonished face +😳,flushed face +😴,sleeping face +😵‍💫,face with spiral eyes +😵,dizzy face +😶‍🌫️,face in clouds +😶,face without mouth +😷,face with medical mask +😸,grinning cat face with smiling eyes +😹,cat face with tears of joy +😺,smiling cat face with open mouth +😻,smiling cat face with heart-shaped eyes +😼,cat face with wry smile +😽,kissing cat face with closed eyes +😾,pouting cat face +😿,crying cat face +🙀,weary cat face +🙁,slightly frowning face +🙂‍↔️,head shaking horizontally +🙂‍↕️,head shaking vertically +🙂,slightly smiling face +🙃,upside-down face +🙄,face with rolling eyes +🙅‍♀️,woman gesturing no +🙅‍♂️,man gesturing no +🙅,face with no good gesture +🙆‍♀️,woman gesturing ok +🙆‍♂️,man gesturing ok +🙆,face with ok gesture +🙇‍♀️,woman bowing +🙇‍♂️,man bowing +🙇,person bowing deeply +🙈,see-no-evil monkey +🙉,hear-no-evil monkey +🙊,speak-no-evil monkey +🙋‍♀️,woman raising hand +🙋‍♂️,man raising hand +🙋,happy person raising one hand +🙌,person raising both hands in celebration +🙍‍♀️,woman frowning +🙍‍♂️,man frowning +🙍,person frowning +🙎‍♀️,woman pouting +🙎‍♂️,man pouting +🙎,person with pouting face +🙏,person with folded hands +🚀,rocket +🚁,helicopter