if which('latex'): exitstatus = os.system("latex %s.tex > /dev/null" % tmp_filename) if exitstatus: log.error( "LaTeX failed - error code %d; check log file '%s.log'", exitstatus, tmp_filename) sys.exit(2) else: log.error("Program 'latex' isn't avaialable.") sys.exit(3) else: log.info("File %s not changed, used existing DVI file (%s)", input_txt, tmp_filename) # 5. Load DVI dvi = binfile(tmp_filename + ".dvi", 'rb') comment, (num, den, mag, u, l), page_offset, fonts = dviparser.dviinfo(dvi) unit_mm = num / (den * 10000.0) scale = unit_mm * 72.27 / 25.4 mag = mag / 1000.0 # 6. Preload fonts used in DVI & other stuff fontsel.preload() missing = [] for k in fonts: _, s, d, fontname = fonts[k] log.debug("Font %s=%s" % (k, fontname)) #print "Font %s=%s" % (k, fontname) try: fontsel.create_DVI_font(fontname, k, s, d, setup.options.enc_methods)
# simple utility that lists fonts used in given DVI file import sys from conv import dviparser from conv import binfile if __name__ == '__main__': if len(sys.argv) > 1: f = binfile.binfile(sys.argv[1]) (comment, (num, den, mag, u, l), pages, fonts) = dviparser.dviinfo(f) for k, (c, s, d, fnt) in fonts.iteritems(): print "%5d: %s, scale=%d, design size=%0.1f, TFM checksum=0x%08X" % ( k, fnt, s, d / 65536.0, c) f.close() # vim: ts=4 sw=4
# simple utility that lists fonts used in given DVI file import sys from conv import dviparser from conv import binfile if __name__ == '__main__': if len(sys.argv) > 1: f = binfile.binfile(sys.argv[1]) (comment, (num, den, mag, u, l), pages, fonts) = dviparser.dviinfo(f) for k, (c,s,d,fnt) in fonts.iteritems(): print "%5d: %s, scale=%d, design size=%0.1f, TFM checksum=0x%08X" % (k, fnt, s, d/65536.0, c) f.close() # vim: ts=4 sw=4
log = logging.getLogger('dvi2svg') if not args: log.info("Nothing to do.") sys.exit() # load & process information about encoding font.preload(setup.options.enc_repl) for filename, basename in args: # # 1. Open file # dvi = binfile(filename, 'rb') log.info("Processing '%s' file -> '%s'", filename, basename) # # 2. Read DVI info # comment, (num, den, mag, u, l), page_offset, fonts = DVI_info(dvi) unit_mm = num/(den*10000.0) if mag == 1000: # not scaled log.debug("%s ('%s') has %d page(s)", dvi.name, comment, len(page_offset)) else: # scaled log.debug("%s ('%s') has %d page(s); magnification is %0.2f", dvi.name, comment, len(page_offset), mag/1000.0) # # 3. Preload fonts
log = logging.getLogger('dvi2svg') if not args: log.info("Nothing to do.") sys.exit() # load & process information about encoding font.preload(setup.options.enc_repl) for filename, basename in args: # # 1. Open file # dvi = binfile(filename, 'rb') log.info("Processing '%s' file -> '%s'", filename, basename) # # 2. Read DVI info # comment, (num, den, mag, u, l), page_offset, fonts = DVI_info(dvi) unit_mm = num / (den * 10000.0) if mag == 1000: # not scaled log.debug("%s ('%s') has %d page(s)", dvi.name, comment, len(page_offset)) else: # scaled log.debug("%s ('%s') has %d page(s); magnification is %0.2f", dvi.name, comment, len(page_offset), mag / 1000.0)
tmp.close() if which('latex'): exitstatus = os.system("latex %s.tex > /dev/null" % tmp_filename) if exitstatus: log.error("LaTeX failed - error code %d; check log file '%s.log'", exitstatus, tmp_filename) sys.exit(2) else: log.error("Program 'latex' isn't avaialable.") sys.exit(3) else: log.info("File %s not changed, used existing DVI file (%s)", input_txt, tmp_filename) # 5. Load DVI dvi = binfile(tmp_filename + ".dvi", 'rb') comment, (num, den, mag, u, l), page_offset, fonts = dviparser.dviinfo(dvi) unit_mm = num/(den*10000.0) scale = unit_mm * 72.27/25.4 mag = mag/1000.0 # 6. Preload fonts used in DVI & other stuff fontsel.preload() missing = [] for k in fonts: _, s, d, fontname = fonts[k] log.debug("Font %s=%s" % (k, fontname)) #print "Font %s=%s" % (k, fontname) try: fontsel.create_DVI_font(fontname, k, s, d, setup.options.enc_methods)