Skip to content

Commit 24ab9cb

Browse files
author
andrej.panov
committed
initial import
0 parents  commit 24ab9cb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+5705
-0
lines changed

COPYING.scripts

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

Makefile.scripts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
VERSION:=$(shell date +"%Y%m%d")
2+
PKGNAME=font-helpers
3+
DOCUMENTS=COPYING.scripts README.scripts
4+
FFSCRIPTS=add_accented.ff \
5+
add_anchor_ext.ff \
6+
add_anchor_med.ff \
7+
add_anchor_y.ff \
8+
add_ipa.ff \
9+
add_private.ff \
10+
add_supnum.ff \
11+
alt_sub.ff \
12+
anchors.ff \
13+
case_sub.ff \
14+
combining.ff \
15+
combining_mono.ff \
16+
cop_glyph.ff \
17+
cop_kern_acc.ff \
18+
cop_kern.ff \
19+
cop_kern_left.ff \
20+
cop_kern_mult.ff \
21+
cop_kern_right.ff \
22+
copy_anchors_acc.ff \
23+
dub_aligned.ff \
24+
dub_glyph_ch.ff \
25+
dub_glyph.ff \
26+
getcvt.ff \
27+
hflip_glyph.ff \
28+
inst_acc.py \
29+
liga_sub.ff \
30+
make_bottomaccent.ff \
31+
make_cap_accent.ff \
32+
make_comb.ff \
33+
make_digraph.ff \
34+
make_double.ff \
35+
make_dup_rot.ff \
36+
make_dup_vertshift.ff \
37+
make_kern.ff \
38+
make_kern_sc.ff \
39+
make_superscript.ff \
40+
mergekern.ff \
41+
new_glyph.ff \
42+
same_cyrext.ff \
43+
same_cyr_it.ff \
44+
same_cyr_rm.ff \
45+
same_kern.ff \
46+
same_kern_sc.ff \
47+
sc_sub.ff \
48+
serbsubs.ff \
49+
spaces_dashes.ff \
50+
sub_onum.ff \
51+
tab_sub.ff
52+
53+
COMPRESS=xz -9
54+
55+
all:
56+
57+
dist:
58+
tar -cvf $(PKGNAME)-src-$(VERSION).tar Makefile.scripts \
59+
$(FFSCRIPTS) $(DOCUMENTS)
60+
$(COMPRESS) $(PKGNAME)-src-$(VERSION).tar

README.scripts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
This is a set of useful fontforge scripts for producing fonts.
2+
3+
The scripts are distributed under the terms of GNU General Public License
4+
Version 3 (see COPYING.scripts).
5+
6+
Andrey V. Panov <[email protected]>

add_accented.ff

Lines changed: 237 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,237 @@
1+
/*
2+
* Copyright (C) 2009, 2010 Andrey V. Panov
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program; if not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
# This fontforge script proposed for making accented glyphs using anchors,
19+
# copying kerning info and anchors with vertical shist from base letters to
20+
# accented ones
21+
22+
italic_angle=100*$italicangle
23+
pi=4.0*ATan2(1.0,1.0)
24+
tan_it = 1.0*Tan($italicangle*pi/180.0)
25+
26+
del_mark = 0
27+
Select(0u301)
28+
if (WorthOutputting())
29+
bbox = GlyphInfo("BBox")
30+
height = bbox[3]
31+
anchors_ref = GetAnchorPoints()
32+
size_ar = SizeOf(anchors_ref)
33+
j = 0
34+
while (j < size_ar)
35+
if (anchors_ref[j][0] == "above-mark" && anchors_ref[j][1] == "basemark")
36+
del_mark = Round(height - anchors_ref[j][3])
37+
break
38+
endif
39+
j++
40+
endloop
41+
endif
42+
43+
copy_anchors_acc.ff("A",del_mark,"Agrave","Aacute","Acircumflex","Atilde","Adieresis","Abreve","Adotbelow")
44+
copy_anchors_acc.ff("E",del_mark,"Egrave","Eacute","Ecircumflex","Etilde","Edieresis","Ebreve","Edotbelow","Ecaron")
45+
copy_anchors_acc.ff("I",del_mark,"Igrave","Iacute","Icircumflex","Idieresis","Idotbelow")
46+
copy_anchors_acc.ff("O",del_mark,"Ograve","Oacute","Ocircumflex","Otilde","Odieresis","Obreve","Odotbelow","Ohungarumlaut")
47+
copy_anchors_acc.ff("U",del_mark,"Ugrave","Uacute","Ucircumflex","Utilde","Udieresis","Ubreve","Udotbelow","Uhungarumlaut")
48+
copy_anchors_acc.ff("Y",del_mark,"Ygrave","Yacute","Ycircumflex","Ytilde","Ydieresis","Ybreve")
49+
copy_anchors_acc.ff("C",del_mark,"Cgrave","Cacute","Ccaron")
50+
copy_anchors_acc.ff("D",del_mark,"Dcaron")
51+
copy_anchors_acc.ff("R",del_mark,"Rgrave","Racute","Rcaron")
52+
copy_anchors_acc.ff("S",del_mark,"Sgrave","Sacute","Scaron")
53+
copy_anchors_acc.ff("T",del_mark,"Tcaron")
54+
copy_anchors_acc.ff("Z",del_mark,"Zgrave","Zacute","Zcaron","Zdotaccent")
55+
copy_anchors_acc.ff("a",del_mark,"agrave","aacute","acircumflex","atilde","adieresis","abreve","adotbelow")
56+
copy_anchors_acc.ff("e",del_mark,"egrave","eacute","ecircumflex","etilde","edieresis","ebreve","edotbelow","ecaron")
57+
copy_anchors_acc.ff("dotlessi",del_mark,"igrave","iacute","icircumflex","idotbelow")
58+
copy_anchors_acc.ff("o",del_mark,"ograve","oacute","ocircumflex","otilde","odieresis","obreve","odotbelow","ohungarumlaut")
59+
copy_anchors_acc.ff("u",del_mark,"ugrave","uacute","ucircumflex","utilde","udieresis","ubreve","udotbelow","uhungarumlaut")
60+
copy_anchors_acc.ff("y",del_mark,"ygrave","yacute","ycircumflex","ytilde","ydieresis","ybreve")
61+
copy_anchors_acc.ff("c",del_mark,"cgrave","cacute","ccaron")
62+
copy_anchors_acc.ff("r",del_mark,"rgrave","racute","rcaron")
63+
copy_anchors_acc.ff("s",del_mark,"sgrave","sacute","scaron")
64+
copy_anchors_acc.ff("z",del_mark,"zgrave","zacute","zcaron","zdotaccent")
65+
66+
SetPref("PreferSpacingAccents",0)
67+
68+
Select("Agrave","Aring")
69+
SelectMore("Egrave","Idieresis")
70+
SelectMore("Ntilde","Odieresis")
71+
SelectMore("Ugrave","Yacute")
72+
SelectMore("agrave","aring")
73+
SelectMore("egrave","idieresis")
74+
SelectMore("ntilde","odieresis")
75+
SelectMore("ugrave","yacute")
76+
SelectMore("ydieresis","abreve")
77+
SelectMore("Cacute","Dcaron")
78+
SelectMore("Emacron","edotaccent")
79+
SelectMore("Ecaron","gdotaccent")
80+
SelectMore("Hcircumflex","hcircumflex")
81+
SelectMore("Itilde","ibreve")
82+
SelectMore("Idotaccent")
83+
SelectMore("Jcircumflex","jcircumflex")
84+
SelectMore("Lacute","lacute")
85+
SelectMore("Nacute","nacute")
86+
SelectMore("Ncaron","ncaron")
87+
SelectMore("Omacron","ohungarumlaut")
88+
SelectMore("Racute","racute")
89+
SelectMore("Rcaron","scircumflex")
90+
SelectMore("Scaron","scaron")
91+
SelectMore("Tcaron")
92+
SelectMore("Utilde","uhungarumlaut")
93+
SelectMore("Wcircumflex","zcaron")
94+
SelectMore("Acaron","ucaron")
95+
SelectMore("AEmacron","aemacron")
96+
SelectMore("Gcaron","kcaron")
97+
SelectMore("Oogonekmacron","jcaron")
98+
SelectMore("Gacute","gacute")
99+
SelectMore(0u1F8,0u1F9) # ngrave
100+
SelectMore("AEacute","uinvertedbreve")
101+
SelectMore(0u21E,0u21F) # hcaron
102+
SelectMore(0u226,0u227) # a_dotaccent
103+
SelectMore(0u22E,0u22F) #o_dotaccent
104+
SelectMore(0u232,0u233) #ymacron
105+
SelectMoreSingletons(0u403,0u40C,0u453,0u45C)
106+
SelectMore(0u4C1,0u4C2)
107+
SelectMore(0u4D6,0u4D7)
108+
SelectMore(0u4DA,0u4DF)
109+
SelectMore(0u4E2,0u4E5)
110+
SelectMore(0u4EA,0u4F5)
111+
SelectMore(0u4F8,0u4F9)
112+
SelectMore("Bdotaccent","bdotaccent")
113+
SelectMore(0u1E08,0u1E0B)
114+
SelectMore(0u1E1C,0u1E23)
115+
SelectMore("Hdieresis","hdieresis")
116+
SelectMore("Kacute","kacute")
117+
SelectMore("Macute","mdotaccent")
118+
SelectMore("Ndotaccent","ndotaccent")
119+
SelectMore("Pacute","rdotaccent")
120+
SelectMore("Sdotaccent","sdotaccent")
121+
SelectMore("Tdotaccent","tdotaccent")
122+
SelectMore("Vtilde","vtilde")
123+
SelectMore("Wgrave","wdotaccent")
124+
SelectMore("Xdotaccent","zcircumflex")
125+
SelectMore("tdieresis","yring")
126+
SelectMore(0u1E9B)
127+
SelectMore("Ygrave","ygrave")
128+
SelectMore("Etilde","etilde")
129+
SelectMore("Ytilde","ytilde")
130+
131+
# below diacritics
132+
SelectMore(0u1E00,0u1E01)
133+
SelectMore(0u1E04,0u1E07)
134+
SelectMore(0u1E0C,0u1E13)
135+
SelectMore(0u1E18,0u1E1C)
136+
SelectMore(0u1E24,0u1E25)
137+
SelectMore(0u1E2A,0u1E2D)
138+
SelectMore(0u1E32,0u1E37)
139+
SelectMore(0u1E3A,0u1E3D)
140+
SelectMore(0u1E42,0u1E43)
141+
SelectMore(0u1E46,0u1E4B)
142+
SelectMore(0u1E5A,0u1E5B)
143+
SelectMore(0u1E5E,0u1E5F)
144+
SelectMore(0u1E62,0u1E63)
145+
SelectMore(0u1E68,0u1E69) # DOUBLE
146+
SelectMore(0u1E6C,0u1E77)
147+
SelectMore(0u1E7E,0u1E7F)
148+
SelectMore(0u1E88,0u1E89)
149+
SelectMore(0u1E92,0u1E96)
150+
SelectMore("Adotbelow","adotbelow")
151+
SelectMore("Edotbelow","edotbelow")
152+
SelectMore("Idotbelow","odotbelow")
153+
SelectMore("Ohorndotbelow","udotbelow")
154+
SelectMore("Uhorndotbelow","uhorndotbelow")
155+
156+
foreach
157+
if (! WorthOutputting())
158+
BuildAccented()
159+
refs = GlyphInfo("RefNames")
160+
name = GlyphInfo("Name")
161+
bbox = GlyphInfo("BBox")
162+
height = bbox[3]
163+
size_refs = SizeOf(refs)
164+
i = 0
165+
while (i < size_refs)
166+
ref_u = UnicodeFromName(refs[i])
167+
if (IsAlpha(ref_u))
168+
if (IsUpper(ref_u))
169+
cop_kern.ff(refs[i],name)
170+
elseif (IsLower(ref_u))
171+
cop_kern_acc.ff(refs[i],name)
172+
endif
173+
Select(refs[i])
174+
bbox_ref = GlyphInfo("BBox")
175+
height_ref = bbox_ref[3]
176+
anchors_ref = GetAnchorPoints()
177+
size_ar = SizeOf(anchors_ref)
178+
dh = Round(height - height_ref)
179+
j = 0
180+
above_exist = 0
181+
below_exist = 0
182+
while (j < size_ar)
183+
if (anchors_ref[j][0] == "above")
184+
j_ab = j
185+
above_exist = 1
186+
elseif (anchors_ref[j][0] == "below")
187+
j_be = j
188+
below_exist = 1
189+
endif
190+
j++
191+
endloop
192+
if (above_exist)
193+
if (dh > 0)
194+
dy = dh - del_mark
195+
dx = dy * tan_it
196+
else
197+
dy = 0
198+
dx = 0
199+
endif
200+
Select(name)
201+
AddAnchorPoint("above", "basechar", Round(anchors_ref[j_ab][2] - dx), Round(anchors_ref[j_ab][3] + dy))
202+
endif
203+
if(below_exist && (bbox[1] == bbox_ref[1]))
204+
Select(name)
205+
AddAnchorPoint("below", "basechar", Round(anchors_ref[j_be][2]), Round(anchors_ref[j_be][3]))
206+
endif
207+
Select(name)
208+
endif
209+
i++
210+
endloop
211+
endif
212+
endloop
213+
214+
SelectMore(0u1E14,0u1E17) # double diacritics
215+
SelectMore(0u1E38,0u1E39)
216+
SelectMore(0u1E4C,0u1E53) # double diacritics
217+
SelectMore(0u1E5A,0u1E5F)
218+
foreach
219+
if (! WorthOutputting())
220+
BuildAccented()
221+
refs = GlyphInfo("RefNames")
222+
name = GlyphInfo("Name")
223+
size_refs = SizeOf(refs)
224+
i = 0
225+
while (i < size_refs)
226+
ref_u = UnicodeFromName(refs[i])
227+
if (IsAlpha(ref_u))
228+
if (IsUpper(ref_u))
229+
cop_kern.ff(refs[i],name)
230+
elseif (IsLower(ref_u))
231+
cop_kern_acc.ff(refs[i],name)
232+
endif
233+
endif
234+
i++
235+
endloop
236+
endif
237+
endloop

add_anchor_ext.ff

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright (C) 2006 Andrey V. Panov
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program; if not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
# This fontforge script proposed for addition of anchor to glyph
19+
#
20+
21+
class = $1
22+
type = $2
23+
position = $3 # same as for bounding box, i.e. 3 is y max, integer (1 or 3)
24+
o_height = $4 # height of anchor mark, integer
25+
tan_it = $5 # tangent of italic angle, real
26+
if ($argc > 6)
27+
delta_x = $6
28+
else
29+
delta_x = 0
30+
endif
31+
if ($argc > 7)
32+
ext_point = $7 # number of x coordinate from GlyphInfo("Xextrema",...)
33+
else
34+
ext_point = 2
35+
endif
36+
37+
if ( WorthOutputting() )
38+
bbox = GlyphInfo("BBox")
39+
if (position == 3)
40+
x_max = GlyphInfo("Xextrema", Floor(bbox[position]))
41+
else
42+
x_max = GlyphInfo("Xextrema", Ceil(bbox[position]))
43+
endif
44+
# Print(GlyphInfo("Name")," ",bbox,x_max," ",class," ",type," ",position," ",o_height)
45+
if(x_max[1] >= x_max[0])
46+
if (ext_point == 0 || ext_point == 1 )
47+
x_ext = x_max[ext_point]
48+
else
49+
x_ext = (x_max[1] - x_max[0])*0.5 + x_max[0]
50+
endif
51+
AddAnchorPoint(class, type, Round(x_ext + (bbox[position] - o_height)*tan_it + delta_x), o_height)
52+
endif
53+
endif

0 commit comments

Comments
 (0)