class Prawn::Fonts::TTF::FullFontSubsetsCollection
An adapter for subset collection to represent a full font.
@private
Constants
- FULL_FONT
Public Class Methods
Source
# File lib/prawn/fonts/ttf.rb, line 77 def initialize(original) @original = original (@cmap ||= original.cmap.unicode.first) || raise(NoUnicodeCMap.new(font: name)) @code_space_size = case cmap.code_map.keys.max when 0..0xff then 1 when 0x100..0xffff then 2 when 0x10000..0xffffff then 3 else 4 end # Codespaces are not sequentional, they're ranges in # a multi-dimentional space. Each byte is considered separately. So we # have to maximally extend the lower two bytes in order to allow for # continuos Unicode mapping. # We only keep the highest byte because Unicode only goes to 1FFFFF # and fonts usually cover even less of the space. We don't want to # list all those unmapped charac codes here. @code_space_max = cmap.code_map.keys.max | ('ff' * (code_space_size - 1)).to_i(16) end
Public Instance Methods
Source
# File lib/prawn/fonts/ttf.rb, line 104 def encode(characters) [ [ FULL_FONT, characters.map { |c| check_bounds!(c) [cmap[c]].pack('n') }.join(''), ], ] end
Encode characters.
@return [Array<Array(FULL_FONT, String)>]