Import kerning

classic Classic list List threaded Threaded
1 message Options
Ico
Reply | Threaded
Open this post in threaded view
|

Import kerning

Ico
Hope I signed-up.

This is the issue
https://github.com/fontforge/fontforge/issues/2927

and this is my complete script


import fontforge
import sys
import json
import os


path=os.path.dirname(__file__)    #take absolute path

with open(os.path.join(path, "characterMap.json")) as data_file:    #parsing JSON   
    ranges = json.load(data_file)    #contains used Unicode groups, defined what fonts exactly want

if ('--help' in sys.argv):
    print '\nUsage: script.py [input path of font] ' + \
    ' [output path of font]\n'
else :
    inputPath = os.path.join(os.getcwd(), sys.argv[1])
    outputPath = os.path.join(os.getcwd(), sys.argv[2])   

    a=[]
    for group, value in ranges.items(): #iterate over ranges - Unicode groups defined in JSON
        a.append(('ranges',None))
        a += value

    b=[]
    amb=fontforge.open(inputPath)    #open source font from path from second argument
    n=fontforge.font()    #create new font
    for l in amb.gpos_lookups:
        print "\n"
        print amb.gsub_lookups
        print "\n"
        n.importLookups(amb,l)
        print "\n"
        print n.getLookupSubtables(l)
        print "\n"   
        for z in n.getLookupSubtables(l):
            print "\n"
            print n.isKerningClass(z)
            print "\n"
            print n.getLookupSubtableAnchorClasses(z)
            print "\n"   
    for j in amb.gsub_lookups:
        n.importLookups(amb,j)
    amb.selection.select(*a)    #copy all of chars from ranges
    amb.copy()    #does copy them   
    n.encoding=amb.encoding    #type of encoding   
    # n.addLookupSubtable(amb.gpos_lookups[0], amb.getLookupSubtables(amb.gpos_lookups[0]))
    # subtable=amb.getLookupSubtables(amb.gpos_lookups[0])
    # n.addLookupSubtable(n.gpos_lookups[0], "newSub")
    # print "\n"
    # print n.getLookupSubtables(n.gpos_lookups[0])
    # print "\n"
    n.layers["Back"].is_quadratic = amb.layers["Back"].is_quadratic    #optimalization
    n.layers["Fore"].is_quadratic = amb.layers["Fore"].is_quadratic    #optimalization
    n.version=amb.version
    n.fontname=amb.fontname    #name it with first argument
    n.familyname=amb.familyname    #name it with first argument
    n.fullname=amb.fullname    #name it with first argument
    n.gasp=amb.gasp
    n.uwidth=amb.uwidth
    n.weight=amb.weight
    n.intersect()
    n.removeOverlap()    #optimalization
    n.simplify()    #optimalization
    n.addExtrema()    #optimalization
    n.round ()        #optimalization
    n.autoHint()    #optimalization
    n.autoInstr()    #optimalization
    n.correctDirection ()    #optimalization
    n.ascent = amb.ascent
    n.descent = amb.descent
    n.upos = amb.upos
    n.os2_winascent = amb.os2_winascent
    n.os2_windescent = amb.os2_windescent
    n.os2_use_typo_metrics = amb.os2_use_typo_metrics
    n.os2_typoascent = amb.os2_typoascent
    n.os2_typodescent = amb.os2_typodescent
    n.os2_typolinegap = amb.os2_typolinegap
    n.os2_winascent_add = amb.os2_winascent_add
    n.os2_windescent_add = amb.os2_windescent_add
    n.os2_typoascent_add = amb.os2_typoascent_add
    n.os2_typodescent_add = amb.os2_typodescent_add
    n.os2_width = amb.os2_width
    n.os2_strikeypos = amb.os2_strikeypos
    n.os2_strikeysize = amb.os2_strikeysize
    n.os2_subxoff = amb.os2_subxoff
    n.os2_subxsize = amb.os2_subxsize
    n.os2_subyoff = amb.os2_subyoff
    n.os2_subysize = amb.os2_subysize
    n.os2_supxoff = amb.os2_supxoff
    n.os2_supxsize = amb.os2_supxsize
    n.os2_supyoff = amb.os2_supyoff
    n.os2_supysize = amb.os2_supysize
    n.os2_weight = amb.os2_weight
    n.os2_weight_width_slope_only = amb.os2_weight_width_slope_only
    n.hasvmetrics = amb.hasvmetrics
    n.hhea_ascent = amb.hhea_ascent
    n.hhea_ascent_add = amb.hhea_ascent_add
    n.hhea_descent = amb.hhea_descent
    n.hhea_descent_add = amb.hhea_descent_add
    n.hhea_linegap = amb.hhea_linegap
    n.os2_fstype = amb.os2_fstype
    n.os2_codepages = amb.os2_codepages
    n.os2_family_class = amb.os2_family_class
    n.os2_fstype = amb.os2_fstype
    n.os2_panose = amb.os2_panose   
    n.selection.select(*a)   
    n.paste()    #paste chars from sourced font   
    n.generate(outputPath)    #generate font and place it in path from third argument
    n.close()

    print "\n --- Font was install successfully ---\n"

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
fontforge-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/fontforge-users
http://fontforge.10959.n7.nabble.com/User-f8781.html