def writeMustacheLog(self, mustacheFilename, dstFilename, mustacheVars, replaceMap=None): import tfs.common.TFSProject as TFSProject mustacheFile = os.path.abspath( os.path.join(TFSProject.findProjectRootFolder(), 'data', mustacheFilename)) if not (os.path.exists(mustacheFile) and os.path.isfile(mustacheFile)): raise Exception('Invalid mustacheFile: ' + mustacheFile) with open(mustacheFile, 'rt') as f: mustache_template = f.read() mustacheMap = {} mustacheMap.update(mustacheVars) logHtml = pystache.render(mustache_template, mustacheMap) if replaceMap: for key, value in replaceMap.items(): logHtml = logHtml.replace(key, value) dstFile = os.path.abspath(os.path.join(self.html_folder, dstFilename)) with open(dstFile, 'wt') as f: # TODO: explicitly encode unicode f.write(logHtml)
def readGlyphNames_AdobeGlyphListForNewFonts(): import tfs.common.TFSProject as TFSProject srcFile = os.path.abspath( os.path.join(TFSProject.findProjectRootFolder(), 'data', 'Adobe Glyph List', 'aglfn13.txt')) # print 'srcFile', srcFile if not os.path.exists(srcFile) and os.path.isfile(srcFile): raise Exception('Missing srcFile: ' + srcFile) with open(srcFile, 'rt') as f: csvData = f.read() for line in csvData.split('\n'): line = line.strip() if line.startswith('#'): continue if not line: continue hexCode, shortName, longName = line.split(';') # print 'line', line, 'hexCode, shortName, longName', hexCode, shortName, longName hexCode = toNameKey(int(hexCode, 16)) hexToShortNameMap[hexCode] = shortName hexToLongNameMap[hexCode] = longName hexCode = int(hexCode, 16) shortNameToHexMap[shortName] = hexCode
def readGlyphNames_AdobeGlyphListForNewFonts(): import tfs.common.TFSProject as TFSProject srcFile = os.path.abspath( os.path.join(TFSProject.findProjectRootFolder(), "data", "Adobe Glyph List", "aglfn13.txt") ) # print 'srcFile', srcFile if not os.path.exists(srcFile) and os.path.isfile(srcFile): raise Exception("Missing srcFile: " + srcFile) with open(srcFile, "rt") as f: csvData = f.read() for line in csvData.split("\n"): line = line.strip() if line.startswith("#"): continue if not line: continue hexCode, shortName, longName = line.split(";") # print 'line', line, 'hexCode, shortName, longName', hexCode, shortName, longName hexCode = toNameKey(int(hexCode, 16)) hexToShortNameMap[hexCode] = shortName hexToLongNameMap[hexCode] = longName hexCode = int(hexCode, 16) shortNameToHexMap[shortName] = hexCode
def readGlyphNames_AdobeGlyphListFull(): import tfs.common.TFSProject as TFSProject srcFile = os.path.abspath( os.path.join(TFSProject.findProjectRootFolder(), "data", "Adobe Glyph List", "glyphlist.txt") ) readGlyphNames_short(srcFile)
def readNameYaml(filename, dstMap): import tfs.common.TFSProject as TFSProject srcFile = os.path.abspath(os.path.join(TFSProject.findProjectRootFolder(), "data", filename)) # print 'srcFile', srcFile if not os.path.exists(srcFile) and os.path.isfile(srcFile): raise Exception("Missing srcFile: " + srcFile) with open(srcFile, "rt") as f: yamlData = f.read() yamlMap = yaml.load(yamlData) for hexCode, longName in yamlMap.items(): hexCode = toNameKey(hexCode) dstMap[hexCode] = longName
def readNameYaml(filename, dstMap): import tfs.common.TFSProject as TFSProject srcFile = os.path.abspath( os.path.join(TFSProject.findProjectRootFolder(), 'data', filename)) # print 'srcFile', srcFile if not os.path.exists(srcFile) and os.path.isfile(srcFile): raise Exception('Missing srcFile: ' + srcFile) with open(srcFile, 'rt') as f: yamlData = f.read() yamlMap = yaml.load(yamlData) for hexCode, longName in yamlMap.items(): hexCode = toNameKey(hexCode) dstMap[hexCode] = longName
def configure(self): src_paths = self.src_paths if src_paths is None: raise Exception('Missing src_paths') for src_path in src_paths: if not (os.path.exists(src_path) and os.path.isdir(src_path)): raise Exception('Invalid src_path: %s' % src_path) self.src_paths = src_paths # testFont = os.path.abspath(os.path.join('..', '..', 'data', 'FITest Plain.ufo')) # self.fifont = FIFontFromFile(ufo_src_path) # interpolation.srcCodePoints = interpolation.fifont.glyphCodePoints() log_path = self.log_path if log_path is None: self.log_path = None # raise Exception('Missing log_path') pass else: if os.path.exists(log_path): shutil.rmtree(log_path) os.mkdir(log_path) if not (os.path.exists(log_path) and os.path.isdir(log_path)): raise Exception('Invalid log_path: %s' % log_path) self.log_path = log_path def makeLogSubfolder(parent, name): subfolder = os.path.abspath(os.path.join(parent, name)) os.mkdir(subfolder) if not (os.path.exists(subfolder) and os.path.isdir(subfolder)): raise Exception('Invalid log_path: %s' % log_path) return subfolder self.html_folder = makeLogSubfolder(log_path, 'html') self.css_folder = makeLogSubfolder(self.html_folder, 'stylesheets') self.svg_folder = makeLogSubfolder(self.html_folder, 'svg') import tfs.common.TFSProject as TFSProject srcCssFile = os.path.abspath( os.path.join(TFSProject.findProjectRootFolder(), 'data', 'styles.css')) dstCssFile = os.path.abspath( os.path.join(self.css_folder, os.path.basename(srcCssFile))) shutil.copy(srcCssFile, dstCssFile)
def readCodeBlocks(): import tfs.common.TFSProject as TFSProject srcFile = os.path.abspath(os.path.join(TFSProject.findProjectRootFolder(), "data", "UnicodeCodeBlocks.yaml")) # print 'srcFile', srcFile if not os.path.exists(srcFile) and os.path.isfile(srcFile): raise Exception("Missing srcFile: " + srcFile) with open(srcFile, "rt") as f: data = f.read() maps = yaml.load(data) for map in maps: unicodeCodeBlock = TFSMap() unicodeCodeBlock.blockName = map["blockName"] unicodeCodeBlock.blockRangeStart = int(map["blockRangeStart"][2:], 16) unicodeCodeBlock.blockRangeEnd = int(map["blockRangeEnd"][2:], 16) unicodeCodeBlocks.append(unicodeCodeBlock)
def configure(self): src_paths = self.src_paths if src_paths is None: raise Exception('Missing src_paths') for src_path in src_paths: if not (os.path.exists(src_path) and os.path.isdir(src_path)): raise Exception('Invalid src_path: %s' % src_path) self.src_paths = src_paths # testFont = os.path.abspath(os.path.join('..', '..', 'data', 'FITest Plain.ufo')) # self.fifont = FIFontFromFile(ufo_src_path) # interpolation.srcCodePoints = interpolation.fifont.glyphCodePoints() log_path = self.log_dst if log_path is None: self.log_path = None # raise Exception('Missing log_path') pass else: if os.path.exists(log_path): shutil.rmtree(log_path) os.mkdir(log_path) if not (os.path.exists(log_path) and os.path.isdir(log_dst)): raise Exception('Invalid log_path: %s' % log_dst) self.log_path = log_dst def makeLogSubfolder(parent, name): subfolder = os.path.abspath(os.path.join(parent, name)) os.mkdir(subfolder) if not (os.path.exists(subfolder) and os.path.isdir(subfolder)): raise Exception('Invalid log_path: %s' % log_dst) return subfolder self.html_folder = makeLogSubfolder(log_path, 'html') self.css_folder = makeLogSubfolder(self.html_folder, 'stylesheets') self.svg_folder = makeLogSubfolder(self.html_folder, 'svg') import tfs.common.TFSProject as TFSProject srcCssFile = os.path.abspath(os.path.join(TFSProject.findProjectRootFolder(), 'data', 'styles.css')) dstCssFile = os.path.abspath(os.path.join(self.css_folder, os.path.basename(srcCssFile))) shutil.copy(srcCssFile, dstCssFile)
def readCodeBlocks(): import tfs.common.TFSProject as TFSProject srcFile = os.path.abspath( os.path.join(TFSProject.findProjectRootFolder(), 'data', 'UnicodeCodeBlocks.yaml')) # print 'srcFile', srcFile if not os.path.exists(srcFile) and os.path.isfile(srcFile): raise Exception('Missing srcFile: ' + srcFile) with open(srcFile, 'rt') as f: data = f.read() maps = yaml.load(data) for map in maps: unicodeCodeBlock = TFSMap() unicodeCodeBlock.blockName = map['blockName'] unicodeCodeBlock.blockRangeStart = int(map['blockRangeStart'][2:], 16) unicodeCodeBlock.blockRangeEnd = int(map['blockRangeEnd'][2:], 16) unicodeCodeBlocks.append(unicodeCodeBlock)
def writeMustacheLog(mustacheFilename, dstFile, mustacheVars, replaceMap=None): mustacheFile = os.path.abspath(os.path.join(TFSProject.findProjectRootFolder(), 'data', mustacheFilename)) if not (os.path.exists(mustacheFile) and os.path.isfile(mustacheFile)): raise Exception('Invalid mustacheFile: ' + mustacheFile) with open(mustacheFile, 'rt') as f: mustache_template = f.read() mustacheMap = { } mustacheMap.update(mustacheVars) logHtml = pystache.render(mustache_template, mustacheMap) if replaceMap: for key, value in replaceMap.items(): logHtml = logHtml.replace(key, value) # dstFile = os.path.abspath(os.path.join(self.html_folder, dstFilename)) with open(dstFile, 'wt') as f: # TODO: explicitly encode unicode f.write(logHtml)
def getCompounds(log_path=None): import tfs.common.TFSProject as TFSProject srcFile = os.path.abspath( os.path.join(TFSProject.findProjectRootFolder(), 'data', 'Adobe Glyph List', 'aglfn13.txt')) print 'srcFile', srcFile if not os.path.exists(srcFile) and os.path.isfile(srcFile): raise Exception('Missing srcFile: ' + srcFile) with open(srcFile, 'rt') as f: csvData = f.read() glyphInfos = [] glyphNameMap = {} for line in csvData.split('\n'): line = line.strip() if line.startswith('#'): continue if not line: continue hexCode, shortName, longName = line.split(';') shortName = shortName.strip() longName = longName.strip() glyphInfos.append(( hexCode, shortName, longName, )) glyphNameMap[longName] = hexCode # Hack # glyphNameMap['MODITFSER LETTER MACRON ACCENT'] = '02C9' glyphNameMap['MODITFSER LETTER TILDE ACCENT'] = '02DC' yamlMaps = [] unknownBaseNames = set() unknownDiacriticalNames = set() knownDiacriticalNames = set() for hexCode, shortName, longName in glyphInfos: DELIMITER = ' WITH ' if DELIMITER not in longName: continue index = longName.index(DELIMITER) baseName = longName[:index] diacriticalName = longName[index + len(DELIMITER):] # print 'longName "%s", baseName "%s", diacriticalName "%s", ' % ( longName, baseName, diacriticalName, ) if baseName in glyphNameMap: baseHexCode = glyphNameMap[baseName] else: unknownBaseNames.add(baseName) continue diacriticalHexCode = getDiacriticalHexByName(glyphNameMap, diacriticalName) if diacriticalHexCode is None: unknownDiacriticalNames.add(diacriticalName) continue knownDiacriticalNames.add(diacriticalName) diacriticalMap = { 'glyph': parseHexCode(diacriticalHexCode), } if parseHexCode(diacriticalHexCode) in ( 0xb7, # Middle dot ): diacriticalMap['align'] = DIACRITICAL_ALIGN_MIDDLE elif parseHexCode(diacriticalHexCode) in ( 0x2DB, # ogonek ): diacriticalMap['align'] = DIACRITICAL_ALIGN_TAIL elif parseHexCode(diacriticalHexCode) in ( 0xB8, # cedilla ): diacriticalMap['align'] = DIACRITICAL_ALIGN_TAIL_FLOAT else: diacriticalMap['align'] = DIACRITICAL_ALIGN_TOP # An exception if parseHexCode(hexCode) in ( 0x123, # g cedilla ): diacriticalMap['align'] = DIACRITICAL_ALIGN_TOP_ROTATE_FLOAT elif parseHexCode(hexCode) in ( 0x162, # T cedilla 0x163, # t cedilla ): diacriticalMap['align'] = DIACRITICAL_ALIGN_TAIL_H_FLIP diacriticalMap['glyph'] = 0x2DB # ogonek yamlMap = { 'glyph': parseHexCode(hexCode), 'baseGlyph': parseHexCode(baseHexCode), 'diacriticals': (diacriticalMap, ), } yamlMaps.append(yamlMap) #- glyph: 220 # baseGlyph: 'U' # diacriticals: # - glyph: 168 pass print print 'Compound glyph schema results:' print 'unknownBaseNames', sorted(unknownBaseNames) print 'unknownBaseNames', sorted(unknownDiacriticalNames) print 'knownDiacriticalNames', sorted(knownDiacriticalNames) print 'unknownBaseNames', len(unknownBaseNames) print 'unknownBaseNames', len(unknownDiacriticalNames) print 'knownDiacriticalNames', len(knownDiacriticalNames) print # print 'yamlMaps', yamlMaps yamlMaps = sorted( yamlMaps, lambda yamlMap0, yamlMap1: cmp(yamlMap0['glyph'], yamlMap1['glyph'])) if log_path is not None: import yaml dstFile = os.path.abspath(os.path.join(log_path, 'compounds.yaml')) print 'dstFile', dstFile yamlData = yaml.safe_dump(yamlMaps) with open(dstFile, 'wt') as f: f.write(yamlData) return yamlMaps
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS ''' import os import yaml import os.path as path import tfs.common.TFSProject as TFSProject from TFSMap import TFSMap project_root_folder = TFSProject.findProjectRootFolder() # if project_root_folder == None: # this_file = os.path.dirname(os.path.realpath(__file__)) project_root_folder = path.abspath(path.join(this_file, "../../")) #project_root_folder = path.abspath('/media/root/Malysh1/winshm/all_advent/Advent_Pro_Local_Copy/new_advent/KERN/charlesmchen-typefacet-8c6db26') # print(project_root_folder) # # def toNameKey(characterCode): key = '0x%04X' % characterCode return key
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS ''' import os from ConvertToUfo import ConvertToUfo from CtuSettings import CtuSettings import tfs.common.TFSProject as TFSProject pseudo_argv = ( '--src-file', os.path.join(TFSProject.findProjectRootFolder(), 'data-ignore', 'slkscr.ttf'), '--dst-file', os.path.join(TFSProject.findProjectRootFolder(), 'out', 'Silkscreen.ufo'), ) print 'pseudo_argv', ' '.join(pseudo_argv) ctu = ConvertToUfo() settings = CtuSettings(ctu).getCommandLineSettings(*pseudo_argv) ctu.process() print print 'complete.'
glyphsMaps.append({ 'glyphHex': '%X' % value, 'shortName': getUnicodeShortName(value, ignoreUnknown=True), 'longName': getUnicodeLongName(value, ignoreUnknown=True), 'glyphName': getUnicodeCharacterName(value, ignoreUnknown=True), 'unicode_category': unicode_category, 'category_color': category_color, 'categoryName': categoryName, }) mustacheMap = { 'glyphsMaps': glyphsMaps, 'pageTitle': 'Unicode Categories Chart', } mustacheFilename = 'gia_chart_template.txt' dstFilename = 'glyph_categories.html' dstFile = os.path.abspath( os.path.join(TFSProject.findProjectRootFolder(), 'out', dstFilename)) print 'dstFile', dstFile writeMustacheLog(mustacheFilename, dstFile, mustacheMap) print print 'complete.'
def getCompounds(log_path=None): import tfs.common.TFSProject as TFSProject srcFile = os.path.abspath(os.path.join(TFSProject.findProjectRootFolder(), 'data', 'Adobe Glyph List', 'aglfn13.txt')) print 'srcFile', srcFile if not os.path.exists(srcFile) and os.path.isfile(srcFile): raise Exception ('Missing srcFile: ' + srcFile) with open(srcFile, 'rt') as f: csvData = f.read() glyphInfos = [] glyphNameMap = {} for line in csvData.split('\n'): line = line.strip() if line.startswith('#'): continue if not line: continue hexCode, shortName, longName = line.split(';') shortName = shortName.strip() longName = longName.strip() glyphInfos.append( (hexCode, shortName, longName,) ) glyphNameMap[longName] = hexCode # Hack # glyphNameMap['MODITFSER LETTER MACRON ACCENT'] = '02C9' glyphNameMap['MODITFSER LETTER TILDE ACCENT'] = '02DC' yamlMaps = [] unknownBaseNames = set() unknownDiacriticalNames = set() knownDiacriticalNames = set() for hexCode, shortName, longName in glyphInfos: DELIMITER = ' WITH ' if DELIMITER not in longName: continue index = longName.index(DELIMITER) baseName = longName[:index] diacriticalName = longName[index + len(DELIMITER):] # print 'longName "%s", baseName "%s", diacriticalName "%s", ' % ( longName, baseName, diacriticalName, ) if baseName in glyphNameMap: baseHexCode = glyphNameMap[baseName] else: unknownBaseNames.add(baseName) continue diacriticalHexCode = getDiacriticalHexByName(glyphNameMap, diacriticalName) if diacriticalHexCode is None: unknownDiacriticalNames.add(diacriticalName) continue knownDiacriticalNames.add(diacriticalName) diacriticalMap = { 'glyph': parseHexCode(diacriticalHexCode), } if parseHexCode(diacriticalHexCode) in ( 0xb7, # Middle dot ): diacriticalMap['align'] = DIACRITICAL_ALIGN_MIDDLE elif parseHexCode(diacriticalHexCode) in ( 0x2DB, # ogonek ): diacriticalMap['align'] = DIACRITICAL_ALIGN_TAIL elif parseHexCode(diacriticalHexCode) in ( 0xB8, # cedilla ): diacriticalMap['align'] = DIACRITICAL_ALIGN_TAIL_FLOAT else: diacriticalMap['align'] = DIACRITICAL_ALIGN_TOP # An exception if parseHexCode(hexCode) in ( 0x123, # g cedilla ): diacriticalMap['align'] = DIACRITICAL_ALIGN_TOP_ROTATE_FLOAT elif parseHexCode(hexCode) in ( 0x162, # T cedilla 0x163, # t cedilla ): diacriticalMap['align'] = DIACRITICAL_ALIGN_TAIL_H_FLIP diacriticalMap['glyph'] = 0x2DB # ogonek yamlMap = { 'glyph': parseHexCode(hexCode), 'baseGlyph': parseHexCode(baseHexCode), 'diacriticals': ( diacriticalMap, ), } yamlMaps.append(yamlMap) #- glyph: 220 # baseGlyph: 'U' # diacriticals: # - glyph: 168 pass print print 'Compound glyph schema results:' print 'unknownBaseNames', sorted(unknownBaseNames) print 'unknownBaseNames', sorted(unknownDiacriticalNames) print 'knownDiacriticalNames', sorted(knownDiacriticalNames) print 'unknownBaseNames', len(unknownBaseNames) print 'unknownBaseNames', len(unknownDiacriticalNames) print 'knownDiacriticalNames', len(knownDiacriticalNames) print # print 'yamlMaps', yamlMaps yamlMaps = sorted(yamlMaps, lambda yamlMap0, yamlMap1: cmp(yamlMap0['glyph'], yamlMap1['glyph'])) if log_path is not None: import yaml dstFile = os.path.abspath(os.path.join(log_path, 'compounds.yaml')) print 'dstFile', dstFile yamlData = yaml.safe_dump(yamlMaps) with open(dstFile, 'wt') as f: f.write(yamlData) return yamlMaps
def configure(self): ufo_src_path = self.settings.ufo_src if ufo_src_path is None: raise Exception('Missing ufo_src_path') if not (os.path.exists(ufo_src_path) and os.path.isdir(ufo_src) and os.path.basename(ufo_src).lower().endswith('.ufo')): raise Exception('Invalid ufo_src_path: %s' % ufo_src) self.ufo_src_path = ufo_src ufo_dst_path = self.settings.ufo_dst if ufo_dst_path is None: raise Exception('Missing ufo_dst_path') if os.path.exists(ufo_dst_path): shutil.rmtree(ufo_dst_path) # if not (os.path.exists(ufo_dst_path) and os.path.isdir(ufo_dst) and os.path.basename(ufo_dst).lower().endswith('.ufo')): # raise Exception('Invalid ufo_dst_path: %s' % ufo_dst) self.ufo_dst_path = ufo_dst if os.path.abspath(ufo_src_path) == os.path.abspath(ufo_dst_path): raise Exception('ufo_src_path and ufo_dst_path cannot be the same file.') otf_dst = self.settings.otf_dst if otf_dst is not None: # if otf_dst is None: # raise Exception('Missing ufo_dst_path') if os.path.exists(otf_dst): os.unlink(otf_dst) # if not (os.path.exists(ufo_dst_path) and os.path.isdir(ufo_dst) and os.path.basename(ufo_dst).lower().endswith('.ufo')): # raise Exception('Invalid ufo_dst_path: %s' % ufo_dst) self.otf_dst = otf_dst # testFont = os.path.abspath(os.path.join('..', '..', 'data', 'FITest Plain.ufo')) self.fifont = TFSFontFromFile(ufo_src_path) # interpolation.srcCodePoints = interpolation.fifont.glyphCodePoints() log_path = self.settings.log_dst if log_path is None: self.log_path = None # raise Exception('Missing log_path') pass else: if os.path.exists(log_path): shutil.rmtree(log_path) os.mkdir(log_path) if not (os.path.exists(log_path) and os.path.isdir(log_dst)): raise Exception('Invalid log_path: %s' % log_dst) self.log_path = log_dst def makeLogSubfolder(parent, name): subfolder = os.path.abspath(os.path.join(parent, name)) os.mkdir(subfolder) if not (os.path.exists(subfolder) and os.path.isdir(subfolder)): raise Exception('Invalid log_path: %s' % log_dst) return subfolder self.html_folder = makeLogSubfolder(log_path, 'html') self.css_folder = makeLogSubfolder(self.html_folder, 'stylesheets') self.svg_folder = makeLogSubfolder(self.html_folder, 'svg') import tfs.common.TFSProject as TFSProject srcCssFile = os.path.abspath(os.path.join(TFSProject.findProjectRootFolder(), 'data', 'styles.css')) dstCssFile = os.path.abspath(os.path.join(self.css_folder, os.path.basename(srcCssFile))) shutil.copy(srcCssFile, dstCssFile) self.default_diacritical_distance = self.settings.default_diacritical_distance_ems * self.fifont.units_per_em print 'default_diacritical_distance', self.default_diacritical_distance self.topJoinCentersMap = {} self.populateAlignmentMap('--top-join-centers', self.topJoinCentersMap, self.settings.top_join_centers) self.tailJoinCentersMap = {} self.populateAlignmentMap('--tail-join-centers', self.tailJoinCentersMap, self.settings.tail_join_centers) self.middleJoinCentersMap = {} self.populateAlignmentMap('--middle-join-centers', self.middleJoinCentersMap, self.settings.middle_join_centers)
def writeCompoundHtmlLog(self, dstCodePoint, contours, baseCodePoint, diacriticalCodePoints): import pystache def getFilenamePrefix(codePoint): return u'fi-%s' % ( hex(codePoint), ) # filenamePrefix = u'fi-%s' % ( unichr(dstCodePoint), ) filenamePrefix = getFilenamePrefix(dstCodePoint) glyphSvg = self.renderSvgScene( filenamePrefix, pathTuples = ( ( 0x7f7faf7f, contours, ), ), ) import tfs.common.TFSProject as TFSProject mustache_template_file = os.path.abspath(os.path.join(TFSProject.findProjectRootFolder(), 'data', 'log_html_mustache.txt')) with open(mustache_template_file, 'rt') as f: mustache_template = f.read() def formatGlyphName(glyph): return hex(glyph) # return u'%s (%s)' % ( unichr(glyph), # hex(glyph), ) pageTitle = u'font-interpolator Log: %s' % ( formatGlyphName(dstCodePoint), ) linkMaps = [] currentIndex = 0 for index, (codePoint, _, _, _,) in enumerate(self.logData): if codePoint == dstCodePoint: currentIndex = index linkMaps.append({ 'linkFilename': '%s.html' % ( getFilenamePrefix(codePoint), ), 'linkHex': '%X' % codePoint, }) prevCodePoint, _, _, _, = self.logData[(currentIndex + len(self.logData) - 1) % len(self.logData)] nextCodePoint, _, _, _, = self.logData[(currentIndex + 1) % len(self.logData)] import tfs.common.UnicodeCharacterNames as UnicodeCharacterNames def createGlyphMap(codePoint): return { 'glyphHex': '%X' % codePoint, 'glyphName': UnicodeCharacterNames.getUnicodeCharacterName(codePoint), } diacriticalGlyphMaps = [createGlyphMap(codePoint) for codePoint in diacriticalCodePoints] mustacheMap = { 'pageTitle': pageTitle, 'glyphSvg': glyphSvg, # 'glyph': formatGlyphName(dstCodePoint), # 'glyphName': formatGlyphName(dstCodePoint), 'glyphHex': '%X' % dstCodePoint, 'glyphName': UnicodeCharacterNames.getUnicodeCharacterName(dstCodePoint), 'baseGlyphHex': '%X' % baseCodePoint, 'baseGlyphName': UnicodeCharacterNames.getUnicodeCharacterName(baseCodePoint), 'diacriticalGlyphs': diacriticalGlyphMaps, 'linkMaps': linkMaps, 'prevLinkFilename': '%s.html' % ( getFilenamePrefix(prevCodePoint), ), 'prevCodePoint': '%X' % prevCodePoint, 'prevGlyphName': UnicodeCharacterNames.getUnicodeCharacterName(prevCodePoint), 'nextLinkFilename': '%s.html' % ( getFilenamePrefix(nextCodePoint), ), 'nextCodePoint': '%X' % nextCodePoint, 'nextGlyphName': UnicodeCharacterNames.getUnicodeCharacterName(nextCodePoint), } #baseCodePoint, diacriticalCodePoints for key in ( 'familyName', 'styleName', 'fullName', 'fontName', ): mustacheMap[key] = getattr(self.fifont.info, key) logHtml = pystache.render(mustache_template, mustacheMap) logFilename = '%s.html' % ( filenamePrefix, ) logFile = os.path.abspath(os.path.join(self.html_folder, logFilename)) with open(logFile, 'wt') as f: # TODO: explicitly encode unicode f.write(logHtml)
categoryName = 'Unknown' categoryMap = unicodedataCategoryMap.get(unicode_category, None) if categoryMap is not None: categoryName = categoryMap.major + ' ' + categoryMap.minor glyphsMaps.append({ 'glyphHex': '%X' % value, 'shortName': getUnicodeShortName(value, ignoreUnknown=True), 'longName': getUnicodeLongName(value, ignoreUnknown=True), 'glyphName': getUnicodeCharacterName(value, ignoreUnknown=True), 'unicode_category': unicode_category, 'category_color': category_color, 'categoryName': categoryName, }) mustacheMap = { 'glyphsMaps': glyphsMaps, 'pageTitle': 'Unicode Categories Chart', } mustacheFilename = 'gia_chart_template.txt' dstFilename = 'glyph_categories.html' dstFile = os.path.abspath(os.path.join(TFSProject.findProjectRootFolder(), 'out', dstFilename)) print 'dstFile', dstFile writeMustacheLog(mustacheFilename, dstFile, mustacheMap) print print 'complete.'
from AutokernSettings import AutokernSettings import tfs.common.TFSProject as TFSProject from tfs.common.TFSMap import TFSMap pseudo_argv = ( # '--assess-only', # '--ufo-src-path', # os.path.abspath(os.path.join(TFSProject.findProjectRootFolder(), 'data-ignore', 'theleagueof', 'theleagueof-linden-hill-a3f7ae6', 'source', 'Linden Hill.ufo')), # '--ufo-dst-path', # os.path.abspath(os.path.join(TFSProject.findProjectRootFolder(), 'out', 'Linden Hill-kerned.ufo')), '--ufo-src-path', # os.path.abspath(os.path.join(TFSProject.findProjectRootFolder(), 'data-ignore', 'League Gothic-kerned.old.ufo')), os.path.abspath(os.path.join(TFSProject.findProjectRootFolder(), 'data-ignore', 'theleagueof', 'theleagueof-league-gothic-4f9ff8d', 'source', 'League Gothic.ufo')), '--ufo-dst-path', os.path.abspath(os.path.join(TFSProject.findProjectRootFolder(), 'out', 'League Gothic-kerned.ufo')), # '--ufo-src-path', # os.path.abspath(os.path.join(TFSProject.findProjectRootFolder(), 'data-ignore', 'HelveticaLTStd-Roman.ufo')), # '--ufo-dst-path', # os.path.abspath(os.path.join(TFSProject.findProjectRootFolder(), 'out', 'HelveticaLTStd-Roman-kerned.ufo')), '--min-distance-ems', '0.018', # '0.036', '--max-distance-ems', # '0.1', '0.080', '--max-x-extrema-overlap-ems', '0.05',
def readGlyphNames_typefaceExtra(): import tfs.common.TFSProject as TFSProject srcFile = os.path.abspath(os.path.join(TFSProject.findProjectRootFolder(), "data", "typefacet_extra_glyphlist.txt")) readGlyphNames_short(srcFile)
def readGlyphNames_AdobeGlyphListFull(): import tfs.common.TFSProject as TFSProject srcFile = os.path.abspath( os.path.join(TFSProject.findProjectRootFolder(), 'data', 'Adobe Glyph List', 'glyphlist.txt')) readGlyphNames_short(srcFile)
def readGlyphNames_typefaceExtra(): import tfs.common.TFSProject as TFSProject srcFile = os.path.abspath( os.path.join(TFSProject.findProjectRootFolder(), 'data', 'typefacet_extra_glyphlist.txt')) readGlyphNames_short(srcFile)
END OF TERMS AND CONDITIONS ''' import os from Autokern import Autokern from AutokernSettings import AutokernSettings import tfs.common.TFSProject as TFSProject from tfs.common.TFSMap import TFSMap pseudo_argv = ( # '--assess-only', '--ufo-src-path', # os.path.abspath(os.path.join(TFSProject.findProjectRootFolder(), 'data-ignore', 'League Gothic-kerned.old.ufo')), os.path.abspath( os.path.join(TFSProject.findProjectRootFolder(), 'data-ignore', 'theleagueof', 'theleagueof-league-gothic-4f9ff8d', 'source', 'League Gothic.ufo')), # os.path.abspath(os.path.join(TFSProject.findProjectRootFolder(), 'out', 'League Gothic-kerned.3.ufo')), '--ufo-dst-path', os.path.abspath( os.path.join(TFSProject.findProjectRootFolder(), 'out', 'League Gothic-kerned.ufo')), '--min-distance-ems', '0.020', # '0.036', '--max-distance-ems', '0.080', '--max-distance-ems-per-category', 'P*', '0.060',
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS ''' import os from ConvertToUfo import ConvertToUfo from CtuSettings import CtuSettings import tfs.common.TFSProject as TFSProject pseudo_argv = ('--src-file', os.path.join(TFSProject.findProjectRootFolder(), 'data-ignore', 'slkscr.ttf'), '--dst-file', os.path.join(TFSProject.findProjectRootFolder(), 'out', 'Silkscreen.ufo'), ) print 'pseudo_argv', ' '.join(pseudo_argv) ctu = ConvertToUfo() settings = CtuSettings(ctu).getCommandLineSettings(*pseudo_argv) ctu.process() print print 'complete.'
import os from Autokern import Autokern from AutokernSettings import AutokernSettings import tfs.common.TFSProject as TFSProject from tfs.common.TFSMap import TFSMap pseudo_argv = ( # '--assess-only', '--ufo-src-path', # os.path.abspath(os.path.join(TFSProject.findProjectRootFolder(), 'data-ignore', 'Linden Hill-kerned.ufo')), os.path.abspath(os.path.join(TFSProject.findProjectRootFolder(), 'data-ignore', 'Crimson_Text', 'CrimsonText-Roman.ufo')), # os.path.abspath(os.path.join(TFSProject.findProjectRootFolder(), 'out', 'Linden Hill-kerned.3.ufo')), '--ufo-dst-path', os.path.abspath(os.path.join(TFSProject.findProjectRootFolder(), 'out', 'CrimsonText-Roman-kerned.ufo')), '--glyph-categories', ## 'cedillacomb', 'Lm', '*', 'Cn', # ## '--tracking-ems', ## '0.020', ## '--min-distance-ems', ## '0.015', ## '--min-distance-ems', ## '0.035', ## '--kerning-strength',
import os from Autokern import Autokern from AutokernSettings import AutokernSettings import tfs.common.TFSProject as TFSProject from tfs.common.TFSMap import TFSMap pseudo_argv = ( # '--assess-only', '--ufo-src-path', # os.path.abspath(os.path.join(TFSProject.findProjectRootFolder(), 'data-ignore', 'Linden Hill-kerned.ufo')), os.path.abspath(os.path.join(TFSProject.findProjectRootFolder(), 'data-ignore', 'theleagueof', 'theleagueof-linden-hill-a3f7ae6', 'source', 'Linden Hill.ufo')), # os.path.abspath(os.path.join(TFSProject.findProjectRootFolder(), 'out', 'Linden Hill-kerned.5.ufo')), '--ufo-dst-path', os.path.abspath(os.path.join(TFSProject.findProjectRootFolder(), 'out', 'Linden Hill-kerned.ufo')), '--glyph-categories', # 'cedillacomb', 'Lm', '*', 'Cn', # '--tracking-ems', # '0.020', # '--min-distance-ems', # '0.015', # '--min-distance-ems', # '0.035', # '--kerning-strength',