module HexaPDF

def self.data_dir

Returns the data directory for HexaPDF.
def self.data_dir
  unless defined?(@data_dir)
    require 'rbconfig'
    @data_dir = File.expand_path(File.join(__dir__, '..', '..', 'data', 'hexapdf'))
    unless File.directory?(@data_dir)
      @data_dir = File.expand_path(File.join(RbConfig::CONFIG["datadir"], "hexapdf"))
    end
    unless File.directory?(@data_dir)
      raise "HexaPDF data directory not found! This is a bug, please report it!"
    end
  end
  @data_dir
end

def self.font_on_invalid_glyph(codepoint, invalid_glyph)

contains such a glyph, +invalid_glyph+ is used.
contains a glyph for the +codepoint+ (taking the font variant into account). If no fallback font
It uses the first font in the list provided by the 'font.fallback' configuration option that

Provides the default implementation for the configuration option 'font.on_invalid_glyph'.
def self.font_on_invalid_glyph(codepoint, invalid_glyph)
  font_wrapper = invalid_glyph.font_wrapper
  document = font_wrapper.pdf_object.document
  variant = case
            when font_wrapper.italic? && font_wrapper.bold? then :bold_italic
            when font_wrapper.bold? then :bold
            when font_wrapper.italic? then :italic
            else :none
            end
  document.config['font.fallback'].each do |font_name|
    font = document.fonts.add(font_name, variant: variant) rescue document.fonts.add(font_name)
    glyph = font.decode_codepoint(codepoint)
    unless glyph.kind_of?(HexaPDF::Font::InvalidGlyph)
      return [glyph]
    end
  end
  [invalid_glyph]
end