File: utf8.rb

package info (click to toggle)
ruby-prawn 2.4.0%2Bdfsg-1~
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 4,396 kB
  • sloc: ruby: 16,090; sh: 43; makefile: 20
file content (27 lines) | stat: -rw-r--r-- 864 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# frozen_string_literal: true

# Multilingualization isn't much of a problem on Prawn as its default encoding
# is UTF-8. The only thing you need to worry about is if the font support the
# glyphs of your language.

require_relative '../example_helper'

filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::ManualBuilder::Example.generate(filename) do
  text 'Take this example, a simple Euro sign:'
  text '€', size: 32
  move_down 20

  text 'This works, because €  is one of the few ' \
    'non-ASCII glyphs supported in PDF built-in fonts.'

  move_down 20

  text 'For full internationalized text support, we need to use external fonts:'
  move_down 20

  font("/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf") do
    text 'ὕαλον ϕαγεῖν δύναμαι· τοῦτο οὔ με βλάπτει.'
    text 'There you go.'
  end
end