@bullet./emoji
v0.1.0
Published
BulletMoji font (fork of OpenMoji) and utilities to build and work with it
Readme
@bullet./emoji
This repository contains script to build BulletMoji font (fork of OpenMoji) and package it for use in React Native apps (Android, iOS, web).
General utilities for working with emoji are also included.
BulletMoji font and other emoji utilities have been customized to include/accept bullet.-branded non-standard symbols
Building the font
To build the font, first install dependencies. For macOS run
brew install python3 woff2 xmlstarletFor Ubuntu
sudo apt install woff2 xmlstarletThen to generate artifacts
npm run generate:fontThe script will download OpenMoji SVGs and metadata, exclude all the extra-* SVGs, and place the generated font files in ./font.
Currently COLRv1 TTF for android and COLRv1 + OT-SVG WOFF2 for everything else are being built.
Using with React Native
React Native does not recognize WOFF2 fonts as assets by default. You can customize this in metro.config.js, a convenience plugin is also included:
const { getDefaultConfig } = require("expo/metro-config")
const { withWOFF2 } = require("@bullet./emoji/metro")
const config = getDefaultConfig(__dirname)
module.exports = withWOFF2(config)Then, in your app:
import { useFonts } from "expo-font"
import { BulletMoji_400Regular } from "@bullet./emoji/font"
// ...
const [loaded, error] = useFonts({ BulletMoji_400Regular })
// ...Utilities
All utilities are named exports from root package, e.g.:
import { emojify } from "@bullet./emoji"const regexp = regex()
Regular expression to match all emoji, including bullet. branded ones, forked from emoji-regex-xs.
const withEmojis = emojify(withShortCodes)
Replace all short codes fenced with colons in string with corresponding emoji, e.g. :+: becomes 👍.
const withShortCodes = codify(withEmojis)
Replace all emojis in string with corresponding short codes fenced with colons, e.g. ❤️ becomes :heart:.
const emoji = toEmoji(shortCode)
Convert bare short code to emoji, e.g. flag_lt -> 🇱🇹.
const shortCode = toShortCode(emoji)
Convert emoji to bare short code, e.g. 🤘🏻 -> metal_tone1.
Note
toEmoji() and toShortCode() have been forked from emoji-index and extended to support all skin tones in addition to bullet. branded emojis.
License
All code licensed under Apache-2.0
Original emoji assets designed by OpenMoji – the open-source emoji and icon project, and released under CC BY-SA 4.0
