|
| 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 |
0 commit comments