make_translation.py: only use bdflib when necessary
This commit is contained in:
@@ -5,12 +5,12 @@ import argparse
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import io
|
import io
|
||||||
|
import functools
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import sys
|
import sys
|
||||||
import fontTables
|
import fontTables
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
from bdflib import reader as bdfreader
|
|
||||||
|
|
||||||
HERE = os.path.dirname(__file__)
|
HERE = os.path.dirname(__file__)
|
||||||
|
|
||||||
@@ -20,8 +20,11 @@ except NameError:
|
|||||||
to_unicode = str
|
to_unicode = str
|
||||||
|
|
||||||
|
|
||||||
with open(os.path.join(HERE, "wqy-bitmapsong/wenquanyi_9pt.bdf"), "rb") as handle:
|
@functools.lru_cache(maxsize=None)
|
||||||
cjkFont = bdfreader.read_bdf(handle)
|
def cjkFont():
|
||||||
|
from bdflib import reader as bdfreader
|
||||||
|
with open(os.path.join(HERE, "wqy-bitmapsong/wenquanyi_9pt.bdf"), "rb") as f:
|
||||||
|
return bdfreader.read_bdf(f)
|
||||||
|
|
||||||
|
|
||||||
def log(message):
|
def log(message):
|
||||||
@@ -184,7 +187,7 @@ def getLetterCounts(defs, lang):
|
|||||||
def getCJKGlyph(sym):
|
def getCJKGlyph(sym):
|
||||||
from bdflib.model import Glyph
|
from bdflib.model import Glyph
|
||||||
try:
|
try:
|
||||||
glyph: Glyph = cjkFont[ord(sym)]
|
glyph: Glyph = cjkFont()[ord(sym)]
|
||||||
except:
|
except:
|
||||||
return None
|
return None
|
||||||
data = glyph.data
|
data = glyph.data
|
||||||
|
|||||||
Reference in New Issue
Block a user