-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathadd_accented_sc.ff
190 lines (184 loc) · 5.09 KB
/
add_accented_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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
/*
* Copyright (C) 2009, 2010 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 making accented smallcap glyphs using anchors,
# copying kerning info and anchors with vertical shist from base letters to
# accented ones
italic_angle=100*$italicangle
pi=4.0*ATan2(1.0,1.0)
tan_it = 1.0*Tan($italicangle*pi/180.0)
lc_lang_c2sc = "LC caps to smallcaps subtable"
lc_lang_smcp = "LC small to smallcaps subtable"
del_mark = 0
Select(0u301)
if (WorthOutputting())
bbox = GlyphInfo("BBox")
height = bbox[3]
anchors_ref = GetAnchorPoints()
size_ar = SizeOf(anchors_ref)
j = 0
while (j < size_ar)
if (anchors_ref[j][0] == "above-mark" && anchors_ref[j][1] == "basemark")
del_mark = Round(height - anchors_ref[j][3])
break
endif
j++
endloop
endif
Select("Agrave","Aring")
SelectMore("Egrave","Idieresis")
SelectMore("Ntilde","Odieresis")
SelectMore("Ugrave","Yacute")
SelectMoreSingletons("Amacron","Abreve")
SelectMore("Cacute","Dcaron")
SelectMore("Emacron","Edotaccent")
SelectMore("Ecaron","Gdotaccent")
SelectMore("Hcircumflex")
SelectMore("Itilde","Ibreve")
SelectMore("Idotaccent")
SelectMore("Jcircumflex")
SelectMore("Lacute")
SelectMore("Nacute")
SelectMore("Ncaron")
SelectMore("Omacron","Ohungarumlaut")
SelectMore("Racute")
SelectMore("Rcaron","Scircumflex")
SelectMore("Scaron")
SelectMore("Tcaron")
SelectMore("Utilde","Uhungarumlaut")
SelectMore("Wcircumflex","Zcaron")
SelectMore("Acaron","Ucaron")
SelectMore("AEmacron")
SelectMore("Gcaron","Kcaron")
SelectMore("Oogonekmacron",0u1EE)
SelectMore("Gacute")
SelectMore(0u1F8) # ngrave
SelectMore("AEacute","Uinvertedbreve")
SelectMore(0u21E) # hcaron
SelectMore(0u226) # a_dotaccent
SelectMore(0u22E) #o_dotaccent
SelectMore(0u232) #ymacron
SelectMoreSingletons(0u403,0u40C,0u453,0u45C)
SelectMoreSingletons(0u4C1,0u4D0,0u4D2,0u4D6,0u4DC,0u4DE)
SelectMoreSingletons(0u4E2,0u4E4,0u4E6,0u4EA)
SelectMore(0u4EA,0u4F4)
SelectMore(0u4F8)
SelectMore("Bdotaccent")
SelectMoreSingletons(0u1E08,0u1E0A)
SelectMore(0u1E1C,0u1E22)
SelectMore("Hdieresis")
SelectMore("Kacute")
SelectMore("Macute","Mdotaccent")
SelectMore("Ndotaccent")
SelectMore("Pacute","Rdotaccent")
SelectMore("Sdotaccent")
SelectMore("Tdotaccent")
SelectMore("Vtilde")
SelectMore("Wgrave","Wdotaccent")
SelectMore("Xdotaccent","Zcircumflex")
SelectMore("Ygrave")
SelectMore("Etilde")
SelectMore("Ytilde")
if (InFont("uni04D8.sc"))
SelectMore(0u4DA)
endif
foreach
namecap = GlyphInfo("Name")
unicap = GlyphInfo("Unicode")
namesc = namecap + ".sc"
# Check references of capital glyph for capital letters
ucrefs = GlyphInfo("RefNames")
size_refs = SizeOf(ucrefs)
i = 0
scbaseref = 0
while (i < size_refs)
ref_u = UnicodeFromName(ucrefs[i])
if (IsAlpha(ref_u) && IsUpper(ref_u))
sc_base = ucrefs[i] + ".sc"
if (InFont(sc_base))
if (WorthOutputting(sc_base))
scbaseref = 1
endif
endif
endif
i++
endloop
if (WorthOutputting() && IsUpper(unicap) && !InFont(namesc) && scbaseref)
new_glyph.ff(namesc)
if (! WorthOutputting(namesc))
Select(namesc)
BuildAccented()
endif
if (WorthOutputting(namesc))
refs = GlyphInfo("RefNames")
name = GlyphInfo("Name")
bbox = GlyphInfo("BBox")
height = bbox[3]
size_refs = SizeOf(refs)
i = 0
while (i < size_refs)
ref_u = UnicodeFromName(refs[i])
if (IsAlpha(ref_u))
cop_kern_acc.ff(refs[i],name)
Select(refs[i])
bbox_ref = GlyphInfo("BBox")
height_ref = bbox_ref[3]
anchors_ref = GetAnchorPoints()
size_ar = SizeOf(anchors_ref)
dh = Round(height - height_ref)
j = 0
above_exist = 0
below_exist = 0
while (j < size_ar)
if (anchors_ref[j][0] == "above")
j_ab = j
above_exist = 1
elseif (anchors_ref[j][0] == "below")
j_be = j
below_exist = 1
endif
j++
endloop
if (above_exist)
if (dh > 0)
dy = dh - del_mark
dx = dy * tan_it
else
dy = 0
dx = 0
endif
Select(name)
AddAnchorPoint("above", "basechar", Round(anchors_ref[j_ab][2] - dx), Round(anchors_ref[j_ab][3] + dy))
endif
if(below_exist && (bbox[1] == bbox_ref[1]))
Select(name)
AddAnchorPoint("below", "basechar", Round(anchors_ref[j_be][2]), Round(anchors_ref[j_be][3]))
endif
Select(name)
endif
i++
endloop
Select(namecap)
AddPosSub(lc_lang_c2sc, namesc);
low = UCodePoint(ToLower(UnicodeFromName(namecap)))
if (low > 0)
Select(low)
AddPosSub(lc_lang_smcp, namesc);
endif
endif
SelectNone()
endif
endloop