2015-06-11 06:56:26 +03:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# Copyright 2015, Google Inc.
|
2015-03-16 21:14:46 +03:00
|
|
|
# Author: Dave Crossland (dave@understandinglimited.com)
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
#
|
2015-06-11 06:56:26 +03:00
|
|
|
# namelist.py: A fontTools python script for generating namelist files
|
2015-03-16 21:14:46 +03:00
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
#
|
2015-06-11 06:56:26 +03:00
|
|
|
# $ namelist.py Font.ttf > NameList.nam
|
|
|
|
import sys
|
|
|
|
from fontTools.ttLib import TTFont
|
|
|
|
from fontTools.unicode import Unicode
|
|
|
|
|
|
|
|
def main(file_name):
|
|
|
|
excluded_chars = ["????", "SPACE", "NO-BREAK SPACE"]
|
|
|
|
font = TTFont(file_name)
|
2017-02-12 23:54:00 +03:00
|
|
|
seen = set()
|
2017-02-10 20:39:27 +03:00
|
|
|
for cmap in font["cmap"].tables:
|
2015-06-11 06:56:26 +03:00
|
|
|
char_list = sorted(cmap.cmap.items())
|
|
|
|
for item in char_list:
|
|
|
|
item_description = Unicode[item[0]]
|
2017-02-12 23:54:00 +03:00
|
|
|
if item[0] in seen:
|
|
|
|
continue
|
|
|
|
seen.add(item[0])
|
2015-06-11 06:56:26 +03:00
|
|
|
if item_description not in excluded_chars:
|
2017-02-12 23:54:00 +03:00
|
|
|
print '0x{0:04X}'.format(item[0]), unichr(item[0]).encode('utf-8'), item_description
|
2015-06-11 06:56:26 +03:00
|
|
|
font.close()
|
|
|
|
|
2015-03-16 21:14:46 +03:00
|
|
|
if __name__ == '__main__':
|
2015-06-11 06:56:26 +03:00
|
|
|
main(sys.argv[1])
|