Skip to content

Commit 9011e38

Browse files
committed
Haroof fix for Lahori nastaleeq font. Collisons avoided
1 parent 0dc998a commit 9011e38

13 files changed

Lines changed: 29 additions & 19 deletions

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ test/obj/*
44
release
55
source/obj
66
*.pkl
7-
*.bak
7+
*.bak
8+
test/test_modules.py

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
setup(
44
name = 'ligature_kerning',
55
packages = find_packages(),
6-
version = '0.0.3',
6+
version = '0.0.4',
77
license='MIT',
88
description = 'Nasteeq ligatures kerning for OpenType (TruType) Fonts',
99
author = 'Sayed Zeeshan Asghar',
169 Bytes
Binary file not shown.
101 Bytes
Binary file not shown.

source/groups.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
shifts = []
88
left_threshold = []
99
right_threshold = []
10-
HeighAdjustment = [0,-200,-100,-100,-50,-20,-20,0,0,-50]; # should always be non-positive
11-
weights = [0.8,0.15,0.05] #must sum up to 1.0
10+
HeighAdjustment = np.ones(shape=(10,),dtype=int)*-15; # should always be non-positive
11+
HeighAdjustment[0] = 0
12+
weights = [0.6,0.25,0.15] #must sum up to 1.0
1213
exceptions = {} #needs to be populated first before calling form_groups_from_tables function
14+
1315
def form_groups_from_tables(Keys,Lookup,LHeightsData,RHeightsData,LCollisionList,RCollisionList,VTGFilePath,VTLFilePath):
1416
lu_len = len(Lookup)
1517
#table sorting
@@ -101,17 +103,22 @@ def form_groups_from_tables(Keys,Lookup,LHeightsData,RHeightsData,LCollisionList
101103
TLst = np.zeros(shape=(L0,3),dtype=int)
102104
for i in range(0,L0):
103105
TLst[i,0] = RTable[j][i]
104-
TLst[i,1] = RHeightsData[RTable[j][i],j+1]*weights[0] + \
105-
RHeightsData[RTable[j][i],3]*weights[1] + \
106-
RHeightsData[RTable[j][i],4]*weights[2]
106+
if j == 0:
107+
TLst[i,1] = RHeightsData[RTable[j][i],j+1]*0.4 + \
108+
RHeightsData[RTable[j][i],j+2]*0.6
109+
else:
110+
TLst[i,1] = RHeightsData[RTable[j][i],j+1]*weights[0]*0.5+ \
111+
RHeightsData[RTable[j][i],j+2]*weights[0]*0.5 + \
112+
RHeightsData[RTable[j][i],3]*weights[1]+ \
113+
RHeightsData[RTable[j][i],4]*weights[2]
107114
TLst[i,2] = RHeightsData[RTable[j][i],j+2]
108115
RMaster[j]=np.flipud(TLst[TLst[:,1].argsort(),])
109116

110117
cushion = np.zeros(shape=(10,1),dtype=int)
111118
for j in range(0,nCols):
112119
if RMaster[j][:,1].any():
113120
cushion[j] = np.mean(RMaster[j][:,1] - np.mean(RMaster[j][:,2]))
114-
121+
cushion[0:1] = 0
115122
#height thresholds to form vertical groups
116123
thresh = np.zeros(shape=(nRows,nCols),dtype=int)
117124
dT = 0
@@ -144,7 +151,7 @@ def form_groups_from_tables(Keys,Lookup,LHeightsData,RHeightsData,LCollisionList
144151

145152
for j in range(0,nRows-1):
146153
for k in range(0,nCols):
147-
a = np.argwhere(RMaster[k][:,1] < thresh[j,k])
154+
a = np.argwhere(RMaster[k][:,1] + 0.5*cushion[j] < thresh[j,k])
148155
if a.any():
149156
indR[j,k] = a[0]
150157
for k in range(0,nCols):
2.73 MB
Binary file not shown.

source/obj/LeftList.pkl

914 KB
Binary file not shown.

source/obj/LeftTable.pkl

1.07 MB
Binary file not shown.

source/obj/RightList.pkl

914 KB
Binary file not shown.

source/obj/RightTable.pkl

1.07 MB
Binary file not shown.

0 commit comments

Comments
 (0)