Prawn::Emoji

Gem Version Build Status Maintainability

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.

Features

Emoji

  • Emoji is provided by Twemoji
  • Support Singleton/Combining/Modifier/Flag/ZWJ Sequence Emoji

See test/pdf/emoji_rendering/expect.pdf for details.

Prawn Integration

  • RTL support
  • Character spacing support
  • Rotation support
  • Alignment support
  • Font size support

See test/pdf/prawn_integration/expect.pdf for details.

Known Issues

prawn-emoji/issues

Installation

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

Setup

require 'prawn/emoji'

True Type Font Required

In order to draw Emoji, you must use a True Type Font. I recommend you use a Japanese font.

Supported Versions

Ruby

2.4, 2.5, 2.6

Prawn

2.2+

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/hidakatsuya/prawn-emoji.

Development

How to test

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.

Run test using the Docker container

The diff-pdf is already installed on the Docker container, so there is no need to install it in your environment.

$ docker build -t prawn-emoji-test .

# Run test:pdf by default
$ docker run --rm prawn-emoji-test

# Run test:units
$ docker run --rm prawn-emoji-test test:units

# Run all test
$ docker run --rm prawn-emoji-test test

How to update bundled emojis

$ bundle exec rake emoji:update VERSION=<Twemoji version>

This task works the following:

  1. Download emoji images from https://github.com/twitter/twemoji/
  2. Save the emoji images in the emoji/images/
  3. Write image list in emoji/images/ to emoji/index.yml
  4. Update version in emoji/LICENSE

License

© 2015 Katsuya HIDAKA. See MIT-LICENSE for further details.

Twemoji

Twemoji Graphics licensed under CC-BY4.0. See emoji/LICENSE for futher details.

IPA Font

IPA Font License Agreement v1.0