Exemple #1
0
def parseFont(s, scale=((1, 1), (1, 1))):
	if ";" in s:
		name, size = s.split(";")
		orig = size
		try:
			size = int(size)
		except ValueError:
			try:
				size = size.replace("f", str(getSkinFactor()))
				size = int(eval(size))
			except Exception as err:
				print("[skin] %s '%s': font size formula '%s', processed to '%s', cannot be evaluated!" % (type(err).__name__, err, orig, s))
				size = None
	else:
		name = s
		size = None
	try:
		f = fonts[name]
		name = f[0]
		size = f[1] if size is None else size
	except KeyError:
		if name not in getFontFaces():
			f = fonts["Body"]
			print("[skin] Error: Font '%s' (in '%s') is not defined!  Using 'Body' font ('%s') instead." % (name, s, f[0]))
			name = f[0]
			size = f[1] if size is None else size
	return gFont(name, int(size) * scale[0][0] // scale[0][1])
Exemple #2
0
def parseFont(s, scale=((1, 1), (1, 1))):
	if ";" in s:
		name, size = s.split(";")
	else:
		name = s
		size = None
	try:
		f = fonts[name]
		name = f[0]
		size = f[1] if size is None else size
	except KeyError:
		if name not in getFontFaces():
			f = fonts["Body"]
			print "[Skin] Error: Font '%s' (in '%s') is not defined!  Using 'Body' font ('%s') instead." % (name, s, f[0])
			name = f[0]
			size = f[1] if size is None else size
	return gFont(name, int(size) * scale[0][0] / scale[0][1])