Font-loading is now done via font name (=name of font folder), updated DejaVu font file

This commit is contained in:
Ochi Wolfe 2013-09-01 22:14:59 +02:00
parent 70c04baf9c
commit 72d51b7221
4 changed files with 17 additions and 7 deletions

View file

@ -24,11 +24,12 @@ SCRIPTS_DIR = "scripts"
OUTPUT_DIR = "output" OUTPUT_DIR = "output"
if not os.path.exists(OUTPUT_DIR): if not os.path.exists(OUTPUT_DIR):
os.mkdir(OUTPUT_DIR) os.mkdir(OUTPUT_DIR)
# Iterate through all directories in the "fonts" directory. # Iterate through all directories in the "fonts" directory.
for fontName in os.listdir(FONTS_DIR): for fontName in os.listdir(FONTS_DIR):
fontFilePaths = glob.glob(os.path.join(FONTS_DIR, fontName, "*.[o,t]tf")) fontFilePaths = glob.glob(os.path.join(FONTS_DIR, fontName, "*.[o,t]tf")) \
+ glob.glob(os.path.join(FONTS_DIR, fontName, "*.[O,T]TF"))
# Ignore this font directory is there are no font files inside it. # Ignore this font directory is there are no font files inside it.
if len(fontFilePaths) < 1: if len(fontFilePaths) < 1:

View file

@ -14,6 +14,7 @@ writes the result out to an image file.
''' '''
import cairo import cairo
import glob
import itertools import itertools
import math import math
import os import os
@ -22,7 +23,8 @@ from . import FontFaceCreator
from . import TGAWriter from . import TGAWriter
from ScriptReader import ScriptReader from ScriptReader import ScriptReader
OUTPUT_DIR = "output" FONTS_DIR = "fonts"
OUTPUT_DIR = "output"
SCRIPTS_DIR = "scripts" SCRIPTS_DIR = "scripts"
class GridConfig: class GridConfig:
@ -149,9 +151,16 @@ class TexturePainter:
self.drawChar(char) self.drawChar(char)
elif script.getCmd() == "loadFont": elif script.getCmd() == "loadFont":
fontPath = script.getRawArg() fontName = script.getRawArg()
if fontPath == "": fontPath = ""
if fontName == "":
fontPath = defaultFont fontPath = defaultFont
else:
fontFilePaths = glob.glob(os.path.join(FONTS_DIR, fontName, "*.[o,t]tf")) \
+ glob.glob(os.path.join(FONTS_DIR, fontName, "*.[O,T]TF"))
if len(fontFilePaths) < 1:
raise Exception("No font file found for font \"" + fontName + "\".")
fontPath = fontFilePaths[0]
self.loadFont(fontPath) self.loadFont(fontPath)
elif script.getCmd() == "jumpToCell": elif script.getCmd() == "jumpToCell":

View file

@ -1,6 +1,6 @@
jumpToCell 0 9 jumpToCell 0 9
loadFont fonts/DejaVu/DejaVu.ttf loadFont DejaVu
drawChars ▲◀▼▶○◔◑◕● drawChars ▲◀▼▶○◔◑◕●
drawChars ↑←↓→↺↻☐☑☒ drawChars ↑←↓→↺↻☐☑☒
@ -10,7 +10,7 @@ drawChars ♪♫♠♣♥♦⚀⚁⚂⚃⚄⚅✔✘☺☹
jumpToCell 24 11 jumpToCell 24 11
loadFont fonts/FreeSerif/FreeSerif.ttf loadFont FreeSerif
drawChars ℹ❌⌖∡⌛⌚ drawChars ℹ❌⌖∡⌛⌚