Пример #1
0
#
if  args.purpose is None:
	#
	faults = True
	#
	print('=\n=> Please Provide the Purpose of Similarity Extraction: component 1 to 1 similarity, or kerning groups loose similarity: -p "comp" or "kern"\n=')	
	#
#
args.compress = "Yes"
# if  args.compress is None:
# 	#
# 	faults = True
# 	#
# 	print('=\n=> Please Select to Compress to Class Based Plist: -c "Yes" or "No" \n=')	
	#
#
if faults == False:
	#
	EFO_temp = os.path.join(args.source,"temp")
	#
	EFO = EFO(args.source,EFO_temp)
	#
	EFO._efo_to_ufos(args.font, True)
	#
	SIMEX = SIMEX(args.source, args.purpose, args.compress, args.font)
	#
	SIMEX.extract_similarity()
	#
	print("Manual Crosscheck would be wise for the generated Similarity Plists")
	#
#
Пример #2
0
    },
    {
        "font_info": []
    },
    {
        "font_kerning_settings": []
    }
]
#
if faults == False:
	#
	EFO_temp = os.path.join(args.source,"temp")
	#
	EFO = EFO(args.source,EFO_temp)
	#
	EFO._efo_to_ufos(args.fonts, True, "flat")
	#
	source_efo_flat_kern_dir = os.path.join(EFO._in, "kerning/flat")
	source_efo_similarity_kern_plist = os.path.join(EFO._in, "groups/kerning.plist")
	#
	f_files_class = []
	#
	for x in EFO.all_exported_ufo_dst:
		#
		for k, v in x.items():
			#
			copy_ufo_for_class_compress = v.split('.ufo')[0]+'_class.ufo'
			#
			generic_tools.copyDirectory(v, copy_ufo_for_class_compress)
			#
			f_files_class.append(k+'_class')
if  args.fonts is None:
	#
	faults = True
	#
	print('=\n=> Please Provide the Font Instances to Export to UFO: -f "thn,reg,bld"\n=')	
	#
if  args.kerning_type is None:
	#
	faults = True
	#
	print('=\n=> Please Provide the Kerning Type to copy to UFOs: -k "class" / "flat" \n=')	
	#
else:
		
	if args.kerning_type not in ["class","flat"]:
		#
		faults = True
		#
		print('=\n=> Please Provide a Valid Kerning Type: -k "class" / "flat" \n=')	
		#
if faults == False:
	#
	EFO = EFO(args.source,args.output)
	#
	EFO._efo_to_ufos(args.fonts, False, args.kerning_type)
	#
	fontinfo_json = EFO.fontinfo
	#
#

Пример #4
0
             #
             dspace_fonts.append(font)
             #
         #
     #
 #
 xml_dspace_file.close()
 #
 dspace_fonts = ','.join(dspace_fonts)
 #
 faults = generic_tools.check_given_fonts_exist(dspace_fonts,
                                                EFO.font_files)
 #
 if faults == False:
     #
     EFO._efo_to_ufos(dspace_fonts, False, "class", True)
     #
     for x in EFO.all_exported_ufo_dst:
         #
         for k, v in x.items():
             #
             copy_ufo_for_componentization = v.split('.ufo')[0]
             #
             for y in sources.iter():
                 #
                 for source in list(y):
                     #
                     if source.tag == 'source':
                         #
                         font = str(
                             source.attrib['filename']).split('.ufo')[0]
Пример #5
0
def do_kerning_alterations(EFO, deg, orig_fonts, targ_fonts):
    #
    '''
	open flat kerning for orig_fonts
		get fontinfo capHeight
		flatten all fonts that participate
		
		for each font, for each glyphname in glyphlib not _notdef
			find highest point location for orig and targ fonts
			store to transfer_dict as glif_name : { closest y point to cap height of contour[0] point list as [x,y], index in original contour[0] point list }
		
		for each font in target and dest
	'''
    #
    read_efo_json_fontinfo(EFO, "Downstream")
    fonts = get_font_file_array(EFO)
    #
    #
    orig_fonts = split_input(orig_fonts)
    targ_fonts = split_input(targ_fonts)
    #
    EFO._efo_to_ufos(','.join(orig_fonts + targ_fonts), False, "class")
    #
    for z in orig_fonts + targ_fonts:
        #
        instance_name = generic_tools.sanitize_string(
            EFO.current_font_family_name + ' ' + z)
        instance_directory = os.path.join(EFO.current_font_family_directory,
                                          instance_name + '.ufo')
        #
        comp_tools.flatten_components(instance_directory)
        #
    #
    source_glyphflib = os.path.join(EFO._in, "glyphlib.xml")
    glyphlib = ET.parse(source_glyphflib)
    #
    t_d = get_transfer_dict(EFO, orig_fonts, targ_fonts, glyphlib)
    #
    for o_f in fonts:
        #
        if o_f in orig_fonts:
            #
            for t_f in fonts:
                #
                if t_f in targ_fonts:
                    #
                    for t_f in targ_fonts:
                        #
                        orig_flat_kerning = os.path.join(
                            EFO._in, "kerning", "flat", o_f + '.plist')
                        s_p_f = plistlib.readPlist(orig_flat_kerning)
                        #
                        targ_flat_kerning = os.path.join(
                            EFO._in, "kerning", "flat", t_f + '.plist')
                        t_p_f = plistlib.readPlist(targ_flat_kerning)
                        #
                        for x in s_p_f:
                            #print("glyph",x)
                            #print("LOFPt", LOFPt)
                            #print("LTFPt", LTFPt)
                            #
                            for y in s_p_f[x]:
                                #
                                LOFPt = t_d["orig"][o_f][get_glif_name(
                                    glyphlib,
                                    x).split(".glif")[0]]["data"][0]  # y orig
                                LTFPt = t_d["targ"][t_f][get_glif_name(
                                    glyphlib, x).split(".glif")[0]]["data"][
                                        0]  # y target
                                #
                                #
                                ROFPt = t_d["orig"][o_f][get_glif_name(
                                    glyphlib,
                                    y).split(".glif")[0]]["data"][0]  # y orig
                                RTFPt = t_d["targ"][t_f][get_glif_name(
                                    glyphlib, y).split(".glif")[0]]["data"][
                                        0]  # y target
                                #
                                #
                                Kn = s_p_f[x][y]  # orig kerning
                                #
                                i_n = generic_tools.sanitize_string(
                                    EFO.current_font_family_name + ' ' + o_f)
                                i_n_dir = os.path.join(
                                    EFO.current_font_family_directory,
                                    i_n + '.ufo')
                                #
                                OLw = get_glif_width(EFO._in, glyphlib, x,
                                                     o_f)  # orig_font_L_width
                                TLw = get_glif_width(EFO._in, glyphlib, x,
                                                     t_f)  # targ_font_L_width
                                #
                                ORw = get_glif_width(EFO._in, glyphlib, y,
                                                     o_f)  # orig_font_R_width
                                TRw = get_glif_width(EFO._in, glyphlib, y,
                                                     t_f)  # targ_font_R_width
                                #
                                DKn = get_new_kerning(Kn, OLw, TLw, ORw, TRw,
                                                      LOFPt, LTFPt, ROFPt,
                                                      RTFPt)
                                #
                                t_p_f[x][y] = DKn
                                #
                                print("\t", "Kn:", Kn, "\tDKn", DKn, "\tPAIR:",
                                      x, y)
                                #
                            #
                        #
                        plistlib.writePlist(t_p_f, targ_flat_kerning)
Пример #6
0
#
faults = False
#
if args.source is None:
    #
    faults = True
    #
    print('=\n=> Please Provide Source EFO File: -s "/font.efo"\n=')
    #
if args.fonts is None:
    #
    faults = True
    #
    print(
        '=\n=> Please Provide the Fonts to Convert to SVG: -f "thn,reg,bld"\n='
    )
    #
#
if faults == False:
    #
    EFO_temp = os.path.join(args.source, "temp")
    #
    EFO = EFO(args.source, EFO_temp)
    #
    EFO._efo_to_ufos(args.fonts)
    #
    UFO_to_SVG = UFO2SVG(args.source, args.fonts)
    #
    UFO_to_SVG.efo_to_svgs()
    #
#
Пример #7
0
if args.fonts is None:
    #
    faults = True
    #
    print(
        '=\n=> Please Provide the Font Instances to Componentize: -f "thn,reg,bld"\n='
    )
    #
if faults == False:
    #
    #
    EFO_temp = os.path.join(args.source, "temp")
    #
    EFO = EFO(args.source, EFO_temp)
    #
    EFO._efo_to_ufos(args.fonts, True, "class")
    #
    f_files_class = []
    #
    for x in EFO.all_exported_ufo_dst:
        #
        for k, v in x.items():
            #
            copy_ufo_for_componentization = v.split('.ufo')[0] + '_compo.ufo'
            #
            generic_tools.copyDirectory(v, copy_ufo_for_componentization)
            #
            f_files_class.append(k + '_compo')
            #
            EFO.current_font_file_name = k
            #