# Path: PyDvi/Kpathsea.py
# def kpsewhich(filename, file_format=None, options=None):
# 
#     """Wrapper around the :command:`kpsewhich` command, cf. kpsewhich(1).
# 
#     *file_format*
#       used to specify the file format, see :command:`kpsewhich` help for the file format list.
# 
#     *options*
#       additional option for :command:`kpsewhich`.
# 
#     Examples::
# 
#        >>> kpsewhich('cmr10', file_format='tfm')
#        '/usr/share/texmf/fonts/tfm/public/cm/cmr10.tfm'
#     """
# 
#     key = '{}-{}-{}'.format(filename, file_format, options)
#     if key in _cache:
#         return _cache[key]
# 
#     command = ['kpsewhich']
#     if file_format is not None:
#         command.append("--format='%s'" % (file_format))
#     if options is not None:
#         command.append(options)
#     command.append(filename)
# 
#     shell_command = ' '.join(command)
#     _module_logger.debug('Run shell command: ' + shell_command)
#     pipe = subprocess.Popen(shell_command, shell=True, stdout=subprocess.PIPE)
#     stdout = pipe.communicate()[0]
#     _module_logger.debug('stdout:\n' + stdout)
#     path = stdout.rstrip()
#     path = path if path else None # Fixme: could raise an exception
# 
#     _cache[key] = path
#     return path
# 
# Path: PyDvi/Font/Font.py
# def sort_font_class(*args):
#     def __init__(self, font_manager, font_id, name):
#     def __repr__(self):
#     def _find_font(self, kpsewhich_options=None):
#     def _find_tfm(self):
#     def basename(self):
#     def is_virtual(self):
#     def print_header(self):
#     def print_summary(self):
# class FontNotFound(NameError):
# class FontMetricNotFound(NameError):
# class Font(object):


import logging
import unicodedata
import numpy as np
import freetype
from ..Kpathsea import kpsewhich
from .Font import Font, font_types, FontMetricNotFound

        return self._face.num_glyphs

    ##############################################

    def font_size(self, font_size, resolution):

        key = "{}@{}".format(font_size, resolution)
        if font_size not in self._font_size:
            self._font_size[key] = FontSize(self, font_size, resolution)
        return self._font_size[key]

    ##############################################

    def get_glyph(self, tex_glyph_index, size, resolution=600):

        # self._logger.info("glyph[{}] @size {} @resolution {} dpi".format(tex_glyph_index, size, resolution))

        font_size = self.font_size(size, resolution)

        glyph_index, name = self._charcode_to_index[tex_glyph_index]
        # self._logger.info("retrieve glyph {} {}".format(glyph_index, name))
        glyph = font_size[glyph_index]

        return glyph

    ##############################################

    def _log_face_information(self):


# Path: PyDvi/Kpathsea.py
# def kpsewhich(filename, file_format=None, options=None):
# 
#     """Wrapper around the :command:`kpsewhich` command, cf. kpsewhich(1).
# 
#     *file_format*
#       used to specify the file format, see :command:`kpsewhich` help for the file format list.
# 
#     *options*
#       additional option for :command:`kpsewhich`.
# 
#     Examples::
# 
#        >>> kpsewhich('cmr10', file_format='tfm')
#        '/usr/share/texmf/fonts/tfm/public/cm/cmr10.tfm'
#     """
# 
#     key = '{}-{}-{}'.format(filename, file_format, options)
#     if key in _cache:
#         return _cache[key]
# 
#     command = ['kpsewhich']
#     if file_format is not None:
#         command.append("--format='%s'" % (file_format))
#     if options is not None:
#         command.append(options)
#     command.append(filename)
# 
#     shell_command = ' '.join(command)
#     _module_logger.debug('Run shell command: ' + shell_command)
#     pipe = subprocess.Popen(shell_command, shell=True, stdout=subprocess.PIPE)
#     stdout = pipe.communicate()[0]
#     _module_logger.debug('stdout:\n' + stdout)
#     path = stdout.rstrip()
#     path = path if path else None # Fixme: could raise an exception
# 
#     _cache[key] = path
#     return path
# 
# Path: PyDvi/Font/Font.py
# def sort_font_class(*args):
#     def __init__(self, font_manager, font_id, name):
#     def __repr__(self):
#     def _find_font(self, kpsewhich_options=None):
#     def _find_tfm(self):
#     def basename(self):
#     def is_virtual(self):
#     def print_header(self):
#     def print_summary(self):
# class FontNotFound(NameError):
# class FontMetricNotFound(NameError):
# class Font(object):


# Path: PyDvi/Font/Type1Font.py
import logging
import unicodedata
import numpy as np
import freetype
from ..Kpathsea import kpsewhich
from .Font import Font, font_types, FontMetricNotFound


        return self._face.num_glyphs

    ##############################################

    def font_size(self, font_size, resolution):

        key = "{}@{}".format(font_size, resolution)
        if font_size not in self._font_size:
            self._font_size[key] = FontSize(self, font_size, resolution)
        return self._font_size[key]

    ##############################################

    def get_glyph(self, tex_glyph_index, size, resolution=600):

        # self._logger.info("glyph[{}] @size {} @resolution {} dpi".format(tex_glyph_index, size, resolution))

        font_size = self.font_size(size, resolution)

        glyph_index, name = self._charcode_to_index[tex_glyph_index]
        # self._logger.info("retrieve glyph {} {}".format(glyph_index, name))
        glyph = font_size[glyph_index]

        return glyph

    ##############################################

    def _log_face_information(self):


        face = self._face