Index: source/tools/fontbuilder2/endonym.txt =================================================================== --- source/tools/fontbuilder2/endonym.txt +++ source/tools/fontbuilder2/endonym.txt @@ -0,0 +1,113 @@ +English (United States) +Afrikaans +العربية +العربية (مصر) +العربية (العراق) +العربية (المملكة العربية السعودية) +asturianu +azərbaycan +bar +беларуская +български +বাংলা +brezhoneg +català +čeština +Cymraeg +dansk +Deutsch +мальдивский +རྫོང་ཁ +Ελληνικά +English (United Kingdom) +esperanto +español +español (Argentina) +español (Chile) +español (México) +eesti +euskara +فارسی +suomi +Filipino +føroyskt +français +français (Canada) +frp +Gaeilge +Gàidhlig +galego +ગુજરાતી +עברית +हिन्दी +hrvatski +magyar +հայերեն +Indonesia +italiano +日本語 +ложбан +ქართული +қазақ тілі +ខ្មែរ +ಕನ್ನಡ +한국어 +карельский +kurdî +kernewek +кыргызча +латинский +Lëtzebuergesch +ລາວ +Довгі рядки +lietuvių +latviešu +македонски +മലയാളം +монгол +मराठी +Melayu +Malti +မြန်မာ +norsk bokmål +नेपाली +Nederlands +северный сото +окситанский +ଓଡ଼ିଆ +ਪੰਜਾਬੀ +polski +پښتو +português (Brasil) +português (Portugal) +română +русский +русский (Украина) +санскрит +сардинский +سنڌي +සිංහල +slovenčina +slovenščina +Soomaali +shqip +српски +сунданский +svenska +Kiswahili +szl +தமிழ் (இந்தியா) +తెలుగు +тоҷикӣ +ไทย +türkmen dili +Tagalog +Türkçe +українська +اردو +o‘zbek +Tiếng Việt +isiXhosa +中文 +中文(新加坡) +中文(台灣) Index: source/tools/fontbuilder2/fontbuilder.py =================================================================== --- source/tools/fontbuilder2/fontbuilder.py +++ source/tools/fontbuilder2/fontbuilder.py @@ -7,6 +7,8 @@ import FontLoader import Packer +from os.path import isfile + # Representation of a rendered glyph class Glyph(object): def __init__(self, ctx, renderstyle, char, idx, face, size): @@ -102,6 +104,9 @@ faceList = [] indexList = [] + usedList = [0]*66000 + if ttfNames[-1] != "unifont-13.0.06.ttf": + ttfNames.append("unifont-13.0.06.ttf") for i in range(len(ttfNames)): (face, indices) = FontLoader.create_cairo_font_face_for_file("../../../binaries/data/tools/fontbuilder/fonts/%s" % ttfNames[i], 0, loadopts) faceList.append(face) @@ -120,9 +125,21 @@ # Estimate the 'average' height of text, for vertical center alignment charheight = round(ctx.glyph_extents([(indexList[0]("I"), 0.0, 0.0)])[3]) + if isfile("endonym.txt"): + fd = open("endonym.txt", 'r') + while True: + sym = fd.read(1) + if not sym: + break + usedList[ord(sym)] = 1 + fd.close() + # Translate all the characters into glyphs # (This is inefficient if multiple characters have the same glyph) glyphs = [] + + info = [0,0] + #for c in chars: for c in range(0x20, 0xFFFE): for i in range(len(indexList)): @@ -130,9 +147,18 @@ if c == 0xFFFD and idx == 0: # use "?" if the missing-glyph glyph is missing idx = indexList[i]("?") if idx: + if i == (len(indexList) - 1): + # skip all symbols from unifont not used in endonym.txt + if usedList[c] != 1: + continue + info[1] += 1 glyphs.append(Glyph(ctx, renderstyle, chr(c), idx, faceList[i], size + dsizes[ttfNames[i]])) + info[0] += 1 + usedList[c] = 2 break + print("\t%d (%d extra symbols)" % (info[0], info[1])) + # Sort by decreasing height (tie-break on decreasing width) glyphs.sort(key = lambda g: (-g.h, -g.w))