# Forked version
This forked version of prawn-emoji just adds some up-to-date emojis to the original version. The newer emojis are extracted from https://github.com/jdecked/twemoji (assets/72x72 folder) and https://github.com/samuelngs/apple-emoji-linux (png/160 folder) For more info check
These are the steps followed For extracting emojis from https://github.com/jdecked/twemoji (assets/72x72 folder):
# Clone with minimal history and no blobs
git clone --depth 1 --filter=blob:none https://github.com/jdecked/twemoji.git
cd twemoji
# Please adapt target folder to your local path
mv -f assets/72x72/* ../prawn-emoji/emoji/images/
cd ..
rm -rf twemoji
For extracting emojis from https://github.com/samuelngs/apple-emoji-linux (png/160 folder):
git clone --depth 1 --filter=blob:none https://github.com/samuelngs/apple-emoji-linux.git
cd apple-emoji-linux
cd png/160
# Rename files to match expected name by prawn-emoji by removing the initial "emoji_u" of the file names
for file in emoji_u*; do mv "$file" "${file:7}"; done
cd -
mv -f png/160/* ../prawn-emoji/emoji/images/
cd ..
rm -rf apple-emoji-linux
And then just update the index with
bundle exec rake emoji:update_index
This project includes emoji assets from Twemoji, Apple-Emoji-Linux, and Prawn-Emoji. See ATTRIBUTIONS.md for details.
Prawn::Emoji is an extention that adds Emoji support to Prawn.
require 'prawn/emoji'
Prawn::Document.generate 'sushi.pdf' do
font 'DejaVuSans.ttf'
text '🐟 / 🔪 + 🍚 / 🍾 = 🍣'
end
For execute this code, you need DejaVuSans.ttf font.
- Emoji is provided by Twemoji
- Support Singleton/Combining/Modifier/Flag/ZWJ Sequence Emoji
See test/pdf/emoji_rendering/expect.pdf for details.
- RTL support
- Character spacing support
- Rotation support
- Alignment support
- Font size support
See test/pdf/prawn_integration/expect.pdf for details.
14.0
2.4
3.0, 3.1, 3.2, 3.3
Add this line to your application's Gemfile:
gem 'prawn-emoji', require: false
And then execute:
$ bundle
Or install it yourself as:
$ gem install prawn-emoji
require 'prawn/emoji'
In order to draw Emoji, you must use a True Type Font.
Emoji Regex is a regular expression used to determine which emoji to draw.
Prawn::Emoji.config.regex # => ::Unicode::Emoji::REGEX_VALID by default
You can override it with unicode-emoji's Regex:
Prawn::Emoji.config.regex = ::Unicode::Emoji::REGEX_INCLUDE_TEXT
Bug reports and pull requests are welcome on GitHub at https://github.com/hidakatsuya/prawn-emoji.
Run all tests:
$ bundle exec rake test
Run unit tests:
$ bundle exec rake test:units
Run pdf tests:
$ bundle exec rake test:pdf
In order to run test:pdf
, you need to install diff-pdf in your environment, or you can run test in the docker container as below.
You can use the docker container for development. This container contains the libraries required for testing, such as diff-pdf.
docker pull ghcr.io/hidakatsuya/ruby-with-diff-pdf:latest
docker run -v $PWD:/src -it ghcr.io/hidakatsuya/ruby-with-diff-pdf bash
> src#
You can run test:
> src# bundle install
> src# bundle exec rake test
Or, you can run test instantly like this:
$ docker run --rm -v $PWD:/src:cached -it ghcr.io/hidakatsuya/ruby-with-diff-pdf bash -c "bundle install && bundle exec rake test:pdf"
$ bundle exec rake emoji:update VERSION=<Twemoji version>
This task works the following:
- Download emoji images from https://github.com/twitter/twemoji/
- Save the emoji images in the
emoji/images/
- Write image list in
emoji/images/
toemoji/index.yml
- Update version in
emoji/LICENSE
© 2015 Katsuya HIDAKA. See MIT-LICENSE for further details.
Twemoji Graphics licensed under CC-BY4.0. See emoji/LICENSE
for futher details.