Beispiel #1
0
def get_designsize(fontname):
    """
	Function (tries to) determine designsize of given font.

	First checks a cache (loaded from setup.font_lookup),
	then seeks for corresponding TFM file and reads designsize.
	"""
    if fontname in config.fonts_lookup:
        encoding, designsize = config.fonts_lookup[fontname]
        log.debug("Getting designsize for '%s' from file cache" % fontname)
        return designsize

    # read TFM, if any
    log.debug('Checking TFM file...')
    filename = findfile.locate(fontname + '.tfm', setup.tex_paths)
    if filename:
        log.debug("Using file '%s'" % filename)
        file = binfile(filename, 'rb')
        try:
            _, designsize, _, _ = read_TFM(file)
        except TFMError, e:
            log.error("TFM error" + str(TFMError))
        else:
            file.close()
            return designsize / (2.0**20)
Beispiel #2
0
def get_designsize(fontname):
	"""
	Function (tries to) determine designsize of given font.

	First checks a cache (loaded from setup.font_lookup),
	then seeks for corresponding TFM file and reads designsize.
	"""
	if fontname in config.fonts_lookup:
		encoding, designsize = config.fonts_lookup[fontname]
		log.debug("Getting designsize for '%s' from file cache" % fontname)
		return designsize

	# read TFM, if any
	log.debug('Checking TFM file...')
	filename = findfile.locate(fontname + '.tfm', setup.tex_paths)
	if filename:
		log.debug("Using file '%s'" % filename)
		file = binfile(filename, 'rb')
		try:
			_, designsize, _, _ = read_TFM(file)
		except TFMError, e:
			log.error("TFM error" + str(TFMError))
		else:
			file.close()
			return designsize / (2.0**20)
Beispiel #3
0
def get_encoding_from_TFM(fontname):
	log.debug('checking TFM file')
	filename = findfile.locate(fontname + '.tfm', setup.tex_paths)
	if filename:
		log.debug("... using '%s'" % filename)
		file = binfile(filename, 'rb')
		try:
			_, _, encodingname, _ = read_TFM(file)
		except TFMError, e:
			log.error("... TFM error: %s" % str(TFMError))
		else:
			file.close()
			try:
				encoding = config.encoding_lookup[encodingname]
				log.debug("... encoding %s" % encoding)
				return encoding
			except KeyError:
				log.error("... font %s: unknown TeX encoding: '%s'" % (fontname, encodingname))
Beispiel #4
0
def get_encoding_from_TFM(fontname):
    log.debug('checking TFM file')
    filename = findfile.locate(fontname + '.tfm', setup.tex_paths)
    if filename:
        log.debug("... using '%s'" % filename)
        file = binfile(filename, 'rb')
        try:
            _, _, encodingname, _ = read_TFM(file)
        except TFMError, e:
            log.error("... TFM error: %s" % str(TFMError))
        else:
            file.close()
            try:
                encoding = config.encoding_lookup[encodingname]
                log.debug("... encoding %s" % encoding)
                return encoding
            except KeyError:
                log.error("... font %s: unknown TeX encoding: '%s'" %
                          (fontname, encodingname))