コード例 #1
0
ファイル: list-entities.py プロジェクト: kreativekorp/charset
def main():
    path = charset_path('acquisition', 'entities')
    for modfile in ls(path):
        mod = load_plugin(modfile)
        if mod is not None:
            for cp, entity in mod.list_entities():
                print('%s: %s' % (cp, entity))
コード例 #2
0
ファイル: list-unidata.py プロジェクト: kreativekorp/charset
def main():
    path = charset_path('acquisition', 'unidata')
    for modfile in ls(path):
        mod = load_plugin(modfile)
        if mod is not None:
            for name, path in mod.list_files():
                print('%s -> %s' % (name, path))
コード例 #3
0
ファイル: build-ucd-js.py プロジェクト: kreativekorp/charset
def get_unidata():
	ranges = {}
	chars = {}
	path = charset_path('acquisition', 'unidata')
	for modfile in ls(path):
		mod = load_plugin(modfile)
		if mod is not None:
			print('Reading Unicode data: %s' % modfile)
			for name, path in mod.list_files():
				if name == 'UnicodeData.txt':
					with open(path, 'r') as ucd:
						for line in ucd:
							fields = line.strip().split(';')
							try:
								cp = int(fields[0], 16)
								if fields[1][:1] == '<' and fields[1][-3:] == 'st>':
									range_name = fields[1][1:-1].split(', ')
									if range_name[0] not in ranges:
										ranges[range_name[0]] = [cp, cp, fields, fields]
									elif range_name[1] == 'First':
										ranges[range_name[0]][0] = cp
										ranges[range_name[0]][2] = fields
									elif range_name[1] == 'Last':
										ranges[range_name[0]][1] = cp
										ranges[range_name[0]][3] = fields
								else:
									chars[cp] = fields
							except ValueError:
								continue
	return ranges, chars
コード例 #4
0
ファイル: list-fonts.py プロジェクト: kreativekorp/charset
def main():
    path = charset_path('acquisition', 'fonts')
    for modfile in ls(path):
        mod = load_plugin(modfile)
        if mod is not None:
            for name, path, url in mod.list_fonts():
                print('%s (%s) -> %s' % (name, url, path))
コード例 #5
0
ファイル: list-vendors.py プロジェクト: kreativekorp/charset
def main():
    path = charset_path('acquisition', 'vendors')
    for modfile in ls(path):
        mod = load_plugin(modfile)
        if mod is not None:
            for vendor in mod.list_vendors():
                for key in sorted(vendor.keys()):
                    print('%s: %s' % (key, vendor[key]))
                print()
コード例 #6
0
ファイル: build-ucd-js.py プロジェクト: kreativekorp/charset
def get_entities():
	entities = {}
	path = charset_path('acquisition', 'entities')
	for modfile in ls(path):
		mod = load_plugin(modfile)
		if mod is not None:
			for cp, entity in mod.list_entities():
				if cp not in entities:
					entities[cp] = entity
	return entities
コード例 #7
0
def get_font_data():
    fonts = {}
    path = charset_path('font-metadata')
    for path in ls(path):
        print('Reading font data: %s' % path)
        try:
            font_data = get_font_file_data(path)
        except Exception as e:
            print('Error: %s' % e)
            continue
        if font_data is None:
            print('Skipping this font because reasons.')
        elif font_data[0] is None:
            print('Error: Font has no name.')
        elif font_data[0] in fonts:
            newchars = fonts[font_data[0]][1].update(font_data[1])
            newvendor = font_data[2] if fonts[
                font_data[0]][2] is None else fonts[font_data[0]][2]
            fonts[font_data[0]] = (font_data[0], newchars, newvendor, None)
        else:
            fonts[font_data[0]] = (font_data[0], font_data[1], font_data[2],
                                   None)
    path = charset_path('acquisition', 'fonts')
    for modfile in ls(path):
        mod = load_plugin(modfile)
        if mod is not None:
            for name, path, url in mod.list_fonts():
                print('Reading font data: %s' % path)
                try:
                    font_data = get_font_file_data(path)
                except Exception as e:
                    print('Error: %s' % e)
                    continue
                if font_data is None:
                    print('Skipping this font because reasons.')
                elif font_data[0] is None:
                    print('Error: Font has no name.')
                elif font_data[0] in fonts:
                    newchars = fonts[font_data[0]][1].update(font_data[1])
                    newvendor = font_data[2] if fonts[
                        font_data[0]][2] is None else fonts[font_data[0]][2]
                    fonts[font_data[0]] = (font_data[0], newchars, newvendor,
                                           url)
                else:
                    fonts[font_data[0]] = (font_data[0], font_data[1],
                                           font_data[2], url)
    fonts = [fonts[k] for k in fonts]
    fonts.sort(key=lambda font: font[0].lower())
    return fonts