Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def convertFontIfNeeded(makeOTFParams):
# we've already done this.
if makeOTFParams.tempFontPath is not None:
return
# If the font doesn't look like a Unix ASCII
# Type 1 font file, convert it with 'tx'
filePath = getattr(makeOTFParams, kFileOptPrefix + kInputFont)
needsConversion = False
needsSEACRemoval = False
isTextPS = False
input_font_format = fdkutils.get_font_format(filePath)
if not input_font_format:
print("makeotf [Error] Unknown input font format '%s'" % filePath)
raise MakeOTFRunError
if input_font_format == 'UFO':
needsConversion = True
makeOTFParams.srcIsUFO = 1
allMatch, msgList = ufotools.checkHashMaps(filePath, False)
if not allMatch:
for msg in msgList:
print(msg)
raise MakeOTFShellError
elif input_font_format == 'OTF':
'--all',
action='store_true',
help='force all glyphs to be processed\n'
'Makes the tool ignore the stored hashes thus checking all the '
'glyphs, even if they have already been processed.'
)
parser.add_argument(
'font_path',
metavar='FONT_PATH',
type=validate_path,
help='Path to UFO, OTF, CFF, or Type 1 font'
)
parsed_args = parser.parse_args(args)
font_format = get_font_format(parsed_args.font_path)
if font_format not in ('UFO', 'OTF', 'CFF', 'PFA', 'PFB', 'PFC'):
parser.error('Font format is not supported.')
options = COOptions()
if parsed_args.glyph_list:
options.glyph_list += parse_glyph_list_arg(parsed_args.glyph_list)
if parsed_args.glyph_file:
gf = open(parsed_args.glyph_file)
glyph_string = gf.read()
glyph_string = glyph_string.strip()
gf.close()
options.glyph_list += parse_glyph_list_arg(glyph_string)
if parsed_args.no_overlap_checks:
def _validate_font_path(path_str):
vpath = os.path.abspath(os.path.realpath(path_str))
if os.path.isfile(vpath) and (get_font_format(vpath) == 'TTF'):
return vpath
raise argparse.ArgumentTypeError(
f"'{path_str}' is not a valid TrueType font file path.")