twemoji-assets

A sophisticated crate that provides the assets from Twemoji.


Version License Docs

Usage

To use this crate, simply include it in your Cargo.toml file and enable the desired features:

toml [dependencies] twemoji-assets = { version = "1.0", features = ["svg", "png", "names"] }

This crate provides a convenient way to access the emoji assets from Twemoji in your Rust programs. You can use the provided from_emoji and from_name methods to select the correct asset at runtime, or use macros to select the right emoji assets at compile time.

Here's a simple example that shows how to use this crate to retrieve the SVG and PNG assets for the 🦆 (duck) emoji:

```rust use twemoji_assets::svg::SvgTwemojiAsset;

fn main() { let svgasset: &SvgTwemojiAsset = SvgTwemojiAsset::fromemoji("🦆").unwrap(); let svgdata: &str = &svgasset; println!("SVG data for 🦆: {:?}", svg_data);

#[cfg(feature = "png")]
{
    use twemoji_assets::png::PngTwemojiAsset;

    let png_asset: &PngTwemojiAsset = PngTwemojiAsset::from_emoji("🦆").unwrap();
    let png_data: &[u8] = &png_asset;
    println!("PNG data for 🦆: {:?}", png_data);
}

} ```

Note: To use the png module, you need to enable the png feature flag in your Cargo.toml file.

This crate does not provide any direct methods for utilizing the Twemoji assets. The following additional crates may be necessary to take full advantage of these emoji graphics:

Feature Flags

The features that you include in your Cargo.toml will affect which assets are available to your program. The following features are available:

As the documentation for this crate includes all features, it is recommended that you generate the docs for your project yourself. To generate the documentation, run the following command: sh cargo doc This will generate documentation for only the features that you have enabled, reducing clutter in the generated documentation.

Version Scheme

This crate follows the semantic versioning scheme as required by the Rust documentation. The version number is represented as x.y.z+a.b.c, where x.y.z is the version of the crate and a.b.c is the version of the integrated Twemoji assets. The + symbol is used to separate the two version numbers. The version of the crate may increase without a corresponding increase in the version of the integrated Twemoji assets, however, whenever the Twemoji assets are updated and new assets are added, the crate version will at least increase in the minor value (y).

Additional Resources

Project Status and Future

Twemoji, the project that this crate sources its assets from, has moved to a new home on GitHub, maintained by its original creators. The original version of Twemoji was maintained by two Twitter employees, @sofodesign and @jdecked. With the recent changes at Twitter, including the acquisition by Elon Musk, they no longer work there and do not have commit permissions to the original repository. There has been no indication from Twitter about whether they intend to keep maintaining the original Twemoji. Given that the original maintenance was done in the creators' free time, it seems highly unlikely that its maintenance is a priority for anyone currently at Twitter.

To prevent Twemoji from becoming abandoned, the original developers have forked the original repository and plan to continue working on it, releasing new Unicode-approved emoji, maintaining the code, etc., despite no longer being employed by Twitter. They have committed to keeping this essential project alive and accessible to the developer community (source).

Af of now this crate sources its assets from this new fork of Twemoji, as the future updates and maintenance of the original Twitter repository are uncertain.

Licensing

The codebase and names provided by Emojibase for this crate are licensed under the MIT License and the included graphics are licensed by Twitter (Copyright 2020 Twitter, Inc and other contributors) under the Creative Commons Attribution 4.0 International (CC-BY 4.0) license. Proper attribution must be given to Twitter and other contributors if these graphics are used or modified.

Comparison to twemoji-rs

Another crate with similar goals to this crate is twemoji-rs. Like twemoji-assets, it provides assets from Twemoji and makes them easily available in Rust. However, instead of directly including the assets, twemoji-rs finds the paths for the particular graphic on the machine where the code compiles.

Pros of twemoji-rs include:

Cons of twemoji-rs include:

Overall, the choice of whether to use twemoji-assets or twemoji-rs will depend on your specific use case and needs.