# Path: PyDvi/Font/VirtualFont.py
# class VirtualFont(Font):
# 
#     """This class implements the virtual font type in the font manager. """
# 
#     font_type = font_types.Vf
#     font_type_string = 'TeX Virtual Font'
#     extension = 'vf'
# 
#     ##############################################
# 
#     def __init__(self, font_manager, font_id, name):
# 
#         super(VirtualFont, self).__init__(font_manager, font_id, name)
# 
#         self.dvi_fonts = {}
#         self.first_font = None
#         self.fonts = {}
#         self.font_id_map = {}
#         self._characters = {}
#         VirtualFontParser.parse(self)
# 
#     ##############################################
#  
#     def __getitem__(self, char_code):
#  
#         # """ Return the :class:`PyDvi.PkGlyph.PkGlyph` instance for the char code *char_code*. """
# 
#         return self._characters[char_code]
# 
#     ##############################################
# 
#     def __len__(self):
# 
#         """ Return the number of characters in the font. """
# 
#         return len(self._characters)
# 
#     ##############################################
# 
#     def _set_preambule_data(self,
#                             vf_id,
#                             comment,
#                             design_font_size,
#                             checksum):
# 
#         """ Set the preambule data from the Virtual Font Parser. """
# 
#         self.vf_id = vf_id
#         self.comment = comment
#         self.design_font_size = design_font_size
#         self.checksum = checksum
# 
#     ##############################################
#         
#     def register_font(self, font):
# 
#         """ Register a :class:`DviFont` instance. """
# 
#         if font.id not in self.dvi_fonts:
#             self.dvi_fonts[font.id] = font
#         if self.first_font is None:
#             self.first_font = font.id
#         # else:
#         #     print 'Font ID %u already registered' % (font.id)
# 
#     ##############################################
# 
#     def register_character(self, character):
# 
#         self._characters[character.char_code] = character
# 
#     ##############################################
# 
#     def print_summary(self):
# 
#         string_format = """
# Preambule
#   - Vf ID        %u
#   - Comment      '%s'
#   - Design size  %.1f pt
#   - Checksum     %u
# """
# 
#         message = self.print_header() + string_format % (
#             self.vf_id,
#             self.comment,
#             self.design_font_size,
#             self.checksum,
#             )
# 
#         print_card(message)
# 
#     ##############################################
# 
#     def load_dvi_fonts(self):
# 
#         self.fonts = {font_id:self.font_manager[dvi_font.name]
#                       for font_id, dvi_font in self.dvi_fonts.iteritems()}
# 
#     ##############################################
# 
#     def update_font_id_map(self):
# 
#         self.font_id_map = {font_id:font.global_id
#                             for font_id, font in self.fonts.iteritems()}
# 
# 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


import argparse
import logging
import sys
from PyDvi.Font.VirtualFont import VirtualFont
from PyDvi.Kpathsea import kpsewhich
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
# 
####################################################################################################

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


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


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

logging.basicConfig(level=logging.DEBUG)

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

parser = argparse.ArgumentParser(description='Test Virtual Font.')
parser.add_argument('font', metavar='VirtualFont',
                    help='Font name, e.g. phvr7t')
args = parser.parse_args()

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

vf_file = kpsewhich(args.font, file_format='vf')

# Path: PyDvi/Font/VirtualFont.py
# class VirtualFont(Font):
# 
#     """This class implements the virtual font type in the font manager. """
# 
#     font_type = font_types.Vf
#     font_type_string = 'TeX Virtual Font'
#     extension = 'vf'
# 
#     ##############################################
# 
#     def __init__(self, font_manager, font_id, name):
# 
#         super(VirtualFont, self).__init__(font_manager, font_id, name)
# 
#         self.dvi_fonts = {}
#         self.first_font = None
#         self.fonts = {}
#         self.font_id_map = {}
#         self._characters = {}
#         VirtualFontParser.parse(self)
# 
#     ##############################################
#  
#     def __getitem__(self, char_code):
#  
#         # """ Return the :class:`PyDvi.PkGlyph.PkGlyph` instance for the char code *char_code*. """
# 
#         return self._characters[char_code]
# 
#     ##############################################
# 
#     def __len__(self):
# 
#         """ Return the number of characters in the font. """
# 
#         return len(self._characters)
# 
#     ##############################################
# 
#     def _set_preambule_data(self,
#                             vf_id,
#                             comment,
#                             design_font_size,
#                             checksum):
# 
#         """ Set the preambule data from the Virtual Font Parser. """
# 
#         self.vf_id = vf_id
#         self.comment = comment
#         self.design_font_size = design_font_size
#         self.checksum = checksum
# 
#     ##############################################
#         
#     def register_font(self, font):
# 
#         """ Register a :class:`DviFont` instance. """
# 
#         if font.id not in self.dvi_fonts:
#             self.dvi_fonts[font.id] = font
#         if self.first_font is None:
#             self.first_font = font.id
#         # else:
#         #     print 'Font ID %u already registered' % (font.id)
# 
#     ##############################################
# 
#     def register_character(self, character):
# 
#         self._characters[character.char_code] = character
# 
#     ##############################################
# 
#     def print_summary(self):
# 
#         string_format = """
# Preambule
#   - Vf ID        %u
#   - Comment      '%s'
#   - Design size  %.1f pt
#   - Checksum     %u
# """
# 
#         message = self.print_header() + string_format % (
#             self.vf_id,
#             self.comment,
#             self.design_font_size,
#             self.checksum,
#             )
# 
#         print_card(message)
# 
#     ##############################################
# 
#     def load_dvi_fonts(self):
# 
#         self.fonts = {font_id:self.font_manager[dvi_font.name]
#                       for font_id, dvi_font in self.dvi_fonts.iteritems()}
# 
#     ##############################################
# 
#     def update_font_id_map(self):
# 
#         self.font_id_map = {font_id:font.global_id
#                             for font_id, font in self.fonts.iteritems()}
# 
# 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: test/test_virtual_font.py
import argparse
import logging
import sys
from PyDvi.Font.VirtualFont import VirtualFont
from PyDvi.Kpathsea import kpsewhich

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
# 
####################################################################################################

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


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


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

logging.basicConfig(level=logging.DEBUG)

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

parser = argparse.ArgumentParser(description='Test Virtual Font.')
parser.add_argument('font', metavar='VirtualFont',
                    help='Font name, e.g. phvr7t')
args = parser.parse_args()

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

vf_file = kpsewhich(args.font, file_format='vf')

if vf_file is None: