class HexaPDF::Type::Font
This class is the base class for all font objects, be it simple fonts or composite fonts.
Represents a generic font object.
def bounding_box
def bounding_box if key?(:FontDescriptor) && self[:FontDescriptor].key?(:FontBBox) self[:FontDescriptor][:FontBBox].value else nil end end
def embedded?
def embedded? dict = self[:FontDescriptor] dict && (dict[:FontFile] || dict[:FontFile2] || dict[:FontFile3]) end
def font_file
def font_file embedded? end
def font_wrapper
Note: For internal use only!
+nil+ if this font can't be used for text output.
Retrieves the font wrapper that is needed when this font is used for text output. Returns
def font_wrapper @font_wrapper ||= nil end
def font_wrapper=(font)
Sets the font wrapper.
def font_wrapper=(font) @font_wrapper = font end
def glyph_scaling_factor
def glyph_scaling_factor 0.001 end
def missing_unicode_mapping(code)
def missing_unicode_mapping(code) @document.config['font.on_missing_unicode_mapping'].call(code, self) end
def must_be_indirect?
def must_be_indirect? true end
def to_unicode_cmap
def to_unicode_cmap cache(:to_unicode_cmap) do if key?(:ToUnicode) HexaPDF::Font::CMap.parse(self[:ToUnicode].stream) else nil end end end
def to_utf8(code)
Returns the UTF-8 string for the given character code, or calls the configuration option
def to_utf8(code) to_unicode_cmap&.to_unicode(code) || missing_unicode_mapping(code) end