diff --git a/.gitignore b/.gitignore index e3cf9fd..36242ea 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ test/obj/* release source/obj *.pkl -*.bak \ No newline at end of file +*.bak +test/test_modules.py diff --git a/setup.py b/setup.py index 44849a6..34310b8 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ setup( name = 'ligature_kerning', packages = find_packages(), - version = '0.0.3', + version = '0.0.4', license='MIT', description = 'Nasteeq ligatures kerning for OpenType (TruType) Fonts', author = 'Sayed Zeeshan Asghar', diff --git a/source/__pycache__/groups.cpython-39.pyc b/source/__pycache__/groups.cpython-39.pyc index 33b345d..58aa309 100644 Binary files a/source/__pycache__/groups.cpython-39.pyc and b/source/__pycache__/groups.cpython-39.pyc differ diff --git a/source/__pycache__/heights.cpython-39.pyc b/source/__pycache__/heights.cpython-39.pyc index 81597e6..7d450d7 100644 Binary files a/source/__pycache__/heights.cpython-39.pyc and b/source/__pycache__/heights.cpython-39.pyc differ diff --git a/source/groups.py b/source/groups.py index b4fd615..e510bdf 100644 --- a/source/groups.py +++ b/source/groups.py @@ -7,9 +7,11 @@ shifts = [] left_threshold = [] right_threshold = [] -HeighAdjustment = [0,-200,-100,-100,-50,-20,-20,0,0,-50]; # should always be non-positive -weights = [0.8,0.15,0.05] #must sum up to 1.0 +HeighAdjustment = np.ones(shape=(10,),dtype=int)*-15; # should always be non-positive +HeighAdjustment[0] = 0 +weights = [0.6,0.25,0.15] #must sum up to 1.0 exceptions = {} #needs to be populated first before calling form_groups_from_tables function + def form_groups_from_tables(Keys,Lookup,LHeightsData,RHeightsData,LCollisionList,RCollisionList,VTGFilePath,VTLFilePath): lu_len = len(Lookup) #table sorting @@ -101,9 +103,14 @@ def form_groups_from_tables(Keys,Lookup,LHeightsData,RHeightsData,LCollisionList TLst = np.zeros(shape=(L0,3),dtype=int) for i in range(0,L0): TLst[i,0] = RTable[j][i] - TLst[i,1] = RHeightsData[RTable[j][i],j+1]*weights[0] + \ - RHeightsData[RTable[j][i],3]*weights[1] + \ - RHeightsData[RTable[j][i],4]*weights[2] + if j == 0: + TLst[i,1] = RHeightsData[RTable[j][i],j+1]*0.4 + \ + RHeightsData[RTable[j][i],j+2]*0.6 + else: + TLst[i,1] = RHeightsData[RTable[j][i],j+1]*weights[0]*0.5+ \ + RHeightsData[RTable[j][i],j+2]*weights[0]*0.5 + \ + RHeightsData[RTable[j][i],3]*weights[1]+ \ + RHeightsData[RTable[j][i],4]*weights[2] TLst[i,2] = RHeightsData[RTable[j][i],j+2] RMaster[j]=np.flipud(TLst[TLst[:,1].argsort(),]) @@ -111,7 +118,7 @@ def form_groups_from_tables(Keys,Lookup,LHeightsData,RHeightsData,LCollisionList for j in range(0,nCols): if RMaster[j][:,1].any(): cushion[j] = np.mean(RMaster[j][:,1] - np.mean(RMaster[j][:,2])) - + cushion[0:1] = 0 #height thresholds to form vertical groups thresh = np.zeros(shape=(nRows,nCols),dtype=int) dT = 0 @@ -144,7 +151,7 @@ def form_groups_from_tables(Keys,Lookup,LHeightsData,RHeightsData,LCollisionList for j in range(0,nRows-1): for k in range(0,nCols): - a = np.argwhere(RMaster[k][:,1] < thresh[j,k]) + a = np.argwhere(RMaster[k][:,1] + 0.5*cushion[j] < thresh[j,k]) if a.any(): indR[j,k] = a[0] for k in range(0,nCols): diff --git a/source/obj/GlyphHeightsDictionary.pkl b/source/obj/GlyphHeightsDictionary.pkl index 928ebe4..3f73562 100644 Binary files a/source/obj/GlyphHeightsDictionary.pkl and b/source/obj/GlyphHeightsDictionary.pkl differ diff --git a/source/obj/LeftList.pkl b/source/obj/LeftList.pkl index fcc7bb5..2c8a846 100644 Binary files a/source/obj/LeftList.pkl and b/source/obj/LeftList.pkl differ diff --git a/source/obj/LeftTable.pkl b/source/obj/LeftTable.pkl index e51878d..28f7cc9 100644 Binary files a/source/obj/LeftTable.pkl and b/source/obj/LeftTable.pkl differ diff --git a/source/obj/RightList.pkl b/source/obj/RightList.pkl index 25ebff7..cdbd622 100644 Binary files a/source/obj/RightList.pkl and b/source/obj/RightList.pkl differ diff --git a/source/obj/RightTable.pkl b/source/obj/RightTable.pkl index 39c7211..2453d75 100644 Binary files a/source/obj/RightTable.pkl and b/source/obj/RightTable.pkl differ diff --git a/source/settings.txt b/source/settings.txt index 26fe65f..e1fa90a 100644 --- a/source/settings.txt +++ b/source/settings.txt @@ -2,9 +2,9 @@ # edit this files for directory and kerning control #any test after # is ignored -GLYPH_DIR_LOC C:/TestKerning #path to ligature directory +GLYPH_DIR_LOC C:/Ligatures_JNN #path to ligature directory -FONT_TYPE KASHEEDA #options: KASHEEDA REGULAR +FONT_TYPE REGULAR #options: KASHEEDA REGULAR HORIZONTAL_SHIFTS [100, 175,200,200,200,200,200,200,200,200] # amount of shifts in units for each horizontal bin @@ -21,12 +21,12 @@ EXCEPTION_STRING r # could be ending string or complete glyph name EXCEPTION_PROFILE [4000,4000,4000,1500,1800,2000,2500,4000,4000,4000] #define a height profile at different shift values, at which the glyph specified #by search string (above) will have to be shorter -EXCEPTION_ADJUSTMENT [-100,-100,-100,-350,-350,-350,-550,-550,-550,-550] +EXCEPTION_ADJUSTMENT [-100,-100,-100,-250,-250,-250,-350,-350,-350,-350] #once a glyph(s) match the EXCEPTION_STRING and EXCEPTION_PROFILE #criterion this adjustment will be applied to height of the glyph. #The values should be negative to apply more kerning and posistive #if you want to apply less kerning than default. EXCEPTION_STRING alef -EXCEPTION_PROFILE [4000,4000,4000,1500,1800,2000,2500,4000,4000,4000] -EXCEPTION_ADJUSTMENT [-100,-100,-100,-350,-350,-350,-550,-550,-550,-550] \ No newline at end of file +EXCEPTION_PROFILE [4000,4000,4000,4000,4000,4000,4000,4000,4000,4000] +EXCEPTION_ADJUSTMENT [0,0,-100,-350,-350,-350,-550,-550,-550,-550] \ No newline at end of file diff --git a/test/__pycache__/test_modules.cpython-39.pyc b/test/__pycache__/test_modules.cpython-39.pyc index e5ea15d..bc36c30 100644 Binary files a/test/__pycache__/test_modules.cpython-39.pyc and b/test/__pycache__/test_modules.cpython-39.pyc differ diff --git a/test/test_modules.py b/test/test_modules.py index 157c57c..14c1cc8 100644 --- a/test/test_modules.py +++ b/test/test_modules.py @@ -8,15 +8,17 @@ def haroof_test(): - numGlyphs = cgh.haroof_glyphs("C:/Ligatures_JNN/Haroof_Regular/",10,770) - assert numGlyphs == 46 + GlyphHeight = [] + GlyphHeight.append(1159) + numGlyphs = cgh.haroof_glyphs("C:/TestKerning/Haroof_Regular/",10,GlyphHeight) + #assert numGlyphs == 46 def all_glyphs_test(): - LookUp = cgh.calc_glyph_heights("C:/Ligaturess",10,0) + LookUp = cgh.calc_glyph_heights("C:/TestKerning",10,0) slo.save_obj(LookUp,'GlyphHeightsDictionary') def plot_test(): LookUp = slo.load_obj('GlyphHeightsDictionary') - cgh.plot_glyph_data(LookUp,"C:/Ligatures/Ligatures_Regular/flsvin.png","flsvin") - cgh.plot_glyph_data(LookUp,"C:/Ligatures/Haroof_Regular/reh.png","reh") + cgh.plot_glyph_data(LookUp,"C:/TestKerning/Ligatures_Regular/mr.png","mr") + cgh.plot_glyph_data(LookUp,"C:/TestKerning/Haroof_Regular/gr.png","gr") def test_collisions(): start_time = time.time() LookUp = slo.load_obj('GlyphHeightsDictionary')