-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathsame_kern_sc.ff
102 lines (94 loc) · 3.09 KB
/
same_kern_sc.ff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
* Copyright (C) 2009, 2010, 2011 Andrey V. Panov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
# This fontforge script proposed for copying kerning info from small cap Latin letters to
# similar Cyrillic ones
copyen = 0
globkernlookup = 0
if ($argc > 1)
i = 1
while ( i < $argc)
arg = $argv[i]
if (arg == "copyen")
copyen = 1
elseif (arg == "globkern")
globkernlookup = 1
endif
i++
endloop
endif
latin_gl=["A","B","E","H","I","M","O","P","T","X","C","J","Idieresis","Edieresis","Ccedilla","Y","I","Abreve","Adieresis","AE","Ebreve","Odieresis"]
cyr_gl=["uni0410","uni0412","uni0415","uni041d","uni0406","uni041c","uni041e","uni0420","uni0422","uni0425","uni0421","uni0408","uni0407","uni0401","uni04AA","uni04AE","uni04C0","uni04D0","uni04D2","uni04D4","uni04D6","uni04E6"]
common_gl=["space","exclam","quotesingle","parenleft","parenright","comma",\
"hyphen","period","colon","semicolon","question","bracketleft",\
"bracketright","braceleft","braceright","guillemotleft",\
"guillemotright","endash","emdash","quotedblleft","quotedblright",\
"quotedblbase","quoteright","ellipsis"]
size_sc = SizeOf(latin_gl)
latin_gl = latin_gl + common_gl
cyr_gl = cyr_gl + common_gl
size_ar = SizeOf(latin_gl)
cyr_gl_sc = Array(size_sc)
latin_gl_sc = Array(size_sc)
latin_gl_sc = latin_gl_sc + common_gl
cyr_gl_sc = cyr_gl_sc + common_gl
i = 0
while (i < size_sc)
if (WorthOutputting(cyr_gl[i]))
Select(cyr_gl[i])
cyr_gl_sc[i] = GlyphInfo ("Name")+".sc"
else
cyr_gl_sc[i] = "."
endif
if (WorthOutputting(latin_gl[i]))
Select(latin_gl[i])
latin_gl_sc[i] = GlyphInfo ("Name")+".sc"
else
latin_gl_sc[i] = "."
endif
i++
endloop
#Print(latin_gl_sc, cyr_gl_sc)
i = 0
while (i < size_ar)
if ( (latin_gl_sc[i] != ".") && (cyr_gl_sc[i] != "."))
if ( WorthOutputting(latin_gl_sc[i]) && WorthOutputting(cyr_gl_sc[i]))
j = 0
while (j < size_ar)
if ( !(i > size_sc && j > size_sc) && (latin_gl_sc[j] != ".") && (cyr_gl_sc[j] != "."))
if ( WorthOutputting(latin_gl_sc[j]) && WorthOutputting(cyr_gl_sc[j]))
Select(latin_gl_sc[i])
kern = GlyphInfo("Kern", latin_gl_sc[j])
if (kern != 0)
Select(cyr_gl_sc[i])
kern_2 = GlyphInfo("Kern", cyr_gl_sc[j])
if (kern_2 == 0)
if (globkernlookup)
SetKern(cyr_gl_sc[j],kern,_kern_subtable)
#Print ("Setting kerning ",cyr_gl_sc[i]," ",cyr_gl_sc[j]," to ",kern)
else
SetKern(cyr_gl_sc[j],kern)
endif
endif
endif
endif
endif
j++
endloop
endif
endif
i++
endloop