Debian Codegraph @

texmf-dist/fonts/source/gregoriotex/squarize.py

raw
1 # This is a fontforge python script; use fontforge -lang=py -script to run it
2 # coding=utf-8
3 # pylint: disable=too-many-branches, too-many-arguments, too-many-lines
4 # pylint: disable=import-error, no-member, C0326
5
6 """
7 Python fontforge script to build a square notation font.
8
9 Copyright (C) 2013-2025 The Gregorio Project (see CONTRIBUTORS.md)
10
11 This file is part of Gregorio.
12
13 Gregorio is free software: you can redistribute it and/or modify
14 it under the terms of the GNU General Public License as published
15 by the Free Software Foundation, either version 3 of the License,
16 or (at your option) any later version.
17
18 Gregorio is distributed in the hope that it will be useful, but
19 WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with Gregorio. If not, see <http://www.gnu.org/licenses/>.
25
26 This script takes a very simple .sfd file with a few symbols and
27 builds a complete square notation font. See gregorio-base.sfd for
28 naming conventions of these symbols.
29
30 To build your own font, look at gregorio-base.sfd, and build your
31 own glyphs from it.
32 """
33
34
35 import sys
36 import os
37 import os.path
38 import json
39 import argparse
40 import fontforge
41 import psMat
42 import stemsschemas
43
44 GPLV3 = """Gregorio is free software: you can redistribute it and/or
45 modify it under the terms of the GNU General Public License as
46 published by the Free Software Foundation, either version 3 of the
47 License, or (at your option) any later version.
48
49 Gregorio is distributed in the hope that it will be useful, but
50 WITHOUT ANY WARRANTY; without even the implied warranty of
51 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
52 General Public License for more details.
53
54 You should have received a copy of the GNU General Public License
55 along with this program. If not, see <http://www.gnu.org/licenses/>.
56
57 As a special exception, if you create a document which uses this font,
58 and embed this font or unaltered portions of this font into the
59 document, this font does not by itself cause the resulting document to
60 be covered by the GNU General Public License. This exception does not
61 however invalidate any other reasons why the document might be covered
62 by the GNU General Public license. If you modify this font, you may
63 extend this exception to your version of the font, but you are not
64 obligated to do so. If you do not wish to do so, delete this exception
65 statement from your version."""
66
67 # defines the maximal interval between two notes, the bigger this number is,
68 # the more glyphs you'll have to generate
69 MAX_INTERVAL = 5
70 ALL_AMBITUS = list(range(1, MAX_INTERVAL + 1))
71 AMBITUS_ONE_ONLY = [ 1 ]
72
73 # this dictionary must have a value for 0 to 14 (the maximum overall ambitus)
74 AMBITUS = {
75 0 : 'Zero',
76 1 : 'One',
77 2 : 'Two',
78 3 : 'Three',
79 4 : 'Four',
80 5 : 'Five',
81 6 : 'Six',
82 7 : 'Seven',
83 8 : 'Eight',
84 9 : 'Nine',
85 10 : 'Ten',
86 11 : 'Eleven',
87 12 : 'Twelve',
88 13 : 'Thirteen',
89 14 : 'Fourteen',
90 }
91
92 GREGORIO_VERSION = '6.1.0'
93
94 # The unicode character at which we start our numbering:
95 # U+E000 is the start of the BMP Private Use Area
96 glyphnumber = 0xe000 - 1
97
98 # see defaults in get_parser()
99 FONT_CONFIG = None
100 STEM_SCHEMA = None
101 oldfont = None
102 newfont = None
103 font_name = None
104 subspecies = None
105 cavum = None
106 all_glyph_names = {}
107 FLATTENED_ORISCUS = {}
108
109 def get_parser():
110 "Return command line parser"
111 parser = argparse.ArgumentParser(
112 description="""Converts a small set of glyphs into a complete
113 gregorian square notation font. The initial glyphs have a name
114 convention, see gregorio-base.sfd.""")
115 parser.add_argument('-o', '--outfile',
116 help='output ttf file name',
117 action='store', default=False, dest='outfile')
118 parser.add_argument('-s', '--sub-species',
119 help='subspecies (may be \'op\')',
120 action='store', default=False, dest='subspecies')
121 parser.add_argument('-v', '--variant',
122 help='variant (may be \'hollow\' or \'hole\')',
123 action='store', default=False, dest='cavum')
124 parser.add_argument('-c', '--config-font',
125 help='font-specific configuration',
126 action='store', dest='config_file')
127 parser.add_argument('-n', '--name',
128 help='name of the font, should match output file name to be found by luaotfload',
129 action='store', default=False, dest='font_name')
130 parser.add_argument('-sc', '--stems-schema',
131 help='stem length schema, can be \'default\' or \'solesmes\'',
132 action='store', default='default', dest='stems_schema')
133 parser.add_argument('base_font', help="input sfd file name", action='store')
134 return parser
135
136 def main():
137 "Main function"
138 global oldfont, newfont, font_name, subspecies, cavum, FONT_CONFIG, STEM_SCHEMA
139 parser = get_parser()
140 if len(sys.argv) == 1:
141 parser.print_help()
142 sys.exit(1)
143 args = parser.parse_args()
144 with open(args.config_file, 'r') as stream:
145 font_config = json.load(stream)
146 subspecies = '_%s' % args.subspecies if args.subspecies else ''
147 cavum = args.cavum
148 if 'base height' not in font_config:
149 font_config['base height'] = 157.5
150 if 'bracket shift' not in font_config:
151 font_config['bracket shift'] = font_config['base height'] / 2.0
152 if 'hepisema additional width' not in font_config:
153 font_config['hepisema additional width'] = 5
154 if 'deminutus vertical shift' not in font_config:
155 font_config['deminutus vertical shift'] = 10
156 if 'additional upper queue height' not in font_config:
157 font_config['additional upper queue height'] = 10
158 FONT_CONFIG = font_config
159 STEM_SCHEMA = stemsschemas.get_stem_schema(args.stems_schema, font_config)
160 outfile = args.outfile
161 inputfile = args.base_font
162 if not outfile:
163 pre = os.path.splitext(inputfile)
164 outfile = '%s.ttf' % pre
165 oldfont = fontforge.open(inputfile)
166 if args.font_name:
167 font_name = args.font_name
168 else:
169 font_name = oldfont.fontname
170 if args.subspecies:
171 font_name = '%s-%s' % (font_name, args.subspecies)
172 if cavum:
173 font_name = '%s-%s' % (font_name, cavum)
174 newfont = fontforge.font()
175 # newfont.encoding = "UnicodeFull"
176 newfont.encoding = "ISO10646-1"
177 newfont.fontname = font_name
178 newfont.fullname = font_name
179 newfont.familyname = font_name
180 newfont.version = GREGORIO_VERSION
181 newfont.copyright = oldfont.copyright.replace('<<GPLV3>>', GPLV3)
182 newfont.weight = "regular"
183 initialize_glyphs()
184 flattened_oriscus()
185 hepisema()
186 brackets()
187 measures()
188 virga()
189 pes()
190 pes_quadratum()
191 pes_oriscus()
192 flexus()
193 scandicus()
194 ancus()
195 salicus()
196 salicus_flexus()
197 torculus()
198 torculus_liquescens()
199 porrectus()
200 porrectusflexus()
201 torculusresupinus()
202 leading()
203 fusion()
204 fusion_pes()
205 fusion_pes_quadratum()
206 fusion_flexus()
207 fusion_porrectus()
208 # variants and extras must be copied last!
209 copy_variant_glyphs()
210 copy_extra_glyphs()
211 newfont.generate(outfile)
212 oldfont.close()
213 newfont.close()
214 print('last code point in', font_name, 'is', hex(glyphnumber))
215
216 def new_glyph():
217 """ Create a new glyph and select it.
218 """
219 global newfont, glyphnumber
220 glyphnumber += 1
221 if glyphnumber > 0xf8ff:
222 print("WARNING: exceeded private use area")
223 newfont.selection.select('u%05x' % glyphnumber)
224
225 def set_glyph_name(name):
226 """ Sets the name of current glyph.
227 """
228 global all_glyph_names, newfont, glyphnumber
229 if glyphnumber in newfont:
230 if name in all_glyph_names:
231 print(f'ERROR: duplicate glyph name [{name}]', file=sys.stderr)
232 sys.exit(1)
233 else:
234 all_glyph_names[name] = True
235 newfont[glyphnumber].glyphname = name
236
237 def message(glyph_name):
238 """Prints a message to stdout, so that the user gets less bored when
239 building the font.
240 """
241 print("generating", glyph_name, "for", font_name)
242
243 def precise_message(glyph_name):
244 "Prints more information to entertain the user."
245 print(" *", glyph_name)
246
247 # This is a dictionary of glyph name to boolean that indicates whether the
248 # glyph name requires a corresponding cavum variant; the names must consist
249 # wholly of ASCII letters
250 DIRECT_GLYPHS = {
251 'CClef' : False,
252 'FClef' : False,
253 'CClefChange' : False,
254 'FClefChange' : False,
255 'Flat' : False,
256 'FlatHole' : False,
257 'FlatParen' : False,
258 'FlatParenHole' : False,
259 'Natural' : False,
260 'NaturalHole' : False,
261 'NaturalParen' : False,
262 'NaturalParenHole' : False,
263 'Sharp' : False,
264 'SharpHole' : False,
265 'SharpParen' : False,
266 'SharpParenHole' : False,
267 'VirgulaTwo' : False,
268 'VirgulaThree' : False,
269 'VirgulaFour' : False,
270 'VirgulaFive' : False,
271 'VirgulaSix' : False,
272 'VirgulaParenTwo' : False,
273 'VirgulaParenThree' : False,
274 'VirgulaParenFour' : False,
275 'VirgulaParenFive' : False,
276 'VirgulaParenSix' : False,
277 'DivisioMinimisTwo' : False,
278 'DivisioMinimisThree' : False,
279 'DivisioMinimisFour' : False,
280 'DivisioMinimisFive' : False,
281 'DivisioMinimisSix' : False,
282 'DivisioMinimaTwo' : False,
283 'DivisioMinimaThree' : False,
284 'DivisioMinimaFour' : False,
285 'DivisioMinimaFive' : False,
286 'DivisioMinimaSix' : False,
287 'DivisioMinimaParenTwo' : False,
288 'DivisioMinimaParenThree' : False,
289 'DivisioMinimaParenFour' : False,
290 'DivisioMinimaParenFive' : False,
291 'DivisioMinimaParenSix' : False,
292 'DivisioMinorTwo' : False,
293 'DivisioMinorThree' : False,
294 'DivisioMinorFour' : False,
295 'DivisioMinorFive' : False,
296 'DivisioMaiorTwo' : False,
297 'DivisioMaiorThree' : False,
298 'DivisioMaiorFour' : False,
299 'DivisioMaiorFive' : False,
300 'DivisioMaiorDottedTwo' : False,
301 'DivisioMaiorDottedThree' : False,
302 'DivisioMaiorDottedFour' : False,
303 'DivisioMaiorDottedFive' : False,
304 'DivisioMaiorDottedBackingTwo' : False,
305 'DivisioMaiorDottedBackingThree' : False,
306 'DivisioMaiorDottedBackingFour' : False,
307 'DivisioMaiorDottedBackingFive' : False,
308 'PunctumDeminutus' : False,
309 'AuctumMora' : False,
310 'Punctum' : True,
311 'AscendensPunctumInclinatum' : True,
312 'DescendensPunctumInclinatum' : True,
313 'StansPunctumInclinatum' : True,
314 'Stropha' : True,
315 'StrophaAucta' : True,
316 'StrophaAuctaLongtail' : True,
317 'VirgaBaseLineBL' : True,
318 'Quilisma' : True,
319 'QuilismaLineTR' : True,
320 'AscendensOriscus' : True,
321 'AscendensOriscusLineBL' : True,
322 'AscendensOriscusLineTL' : True,
323 'AscendensOriscusLineTR' : True,
324 'DescendensOriscus' : True,
325 'DescendensOriscusLineBL' : True,
326 'DescendensOriscusLineTL' : True,
327 'PunctumInclinatumAuctus' : True,
328 'PunctumInclinatumDeminutus' : True,
329 'VEpisema' : False,
330 'VEpisema.circumflexus' : False,
331 'LineaPunctum' : True,
332 'Circulus' : False,
333 'Semicirculus' : False,
334 'Accentus' : False,
335 'CustosUpLong' : False,
336 'CustosUpShort' : False,
337 'CustosUpMedium' : False,
338 'CustosDownLong' : False,
339 'CustosDownShort' : False,
340 'CustosDownMedium' : False,
341 'AccentusReversus' : False,
342 'SemicirculusReversus' : False,
343 'PunctumAscendens' : True,
344 'PunctumDescendens' : True,
345 'DivisioDominican' : False,
346 'DivisioDominicanAlt' : False,
347 'Linea' : True,
348 'RoundBrace' : False,
349 'CurlyBrace' : False,
350 'BarBrace' : False,
351 'RoundBraceDown' : False,
352 'OriscusDeminutus' : True,
353 'PunctumSmall' : False,
354 'PunctumLineBR' : True,
355 'PunctumLineBL' : True,
356 'PunctumLineTL' : True,
357 'PunctumLineTR' : True,
358 'PunctumLineBLBR' : True,
359 'PunctumAuctusLineBL' : True,
360 'AscendensOriscusLineBLTR' : True,
361 }
362
363 VARIANT_CAVUM = {
364 'Punctum#Cavum' : 'Punctum',
365 'LineaPunctum#Cavum' : 'LineaPunctum',
366 }
367
368 GLYPH_FALLBACKS = {
369 '#Cavum' : {
370 'auctusa1' : 'PunctumAscendens',
371 'auctusa2' : 'auctusa1',
372 'auctusd1' : 'PunctumDescendens',
373 'AscendensOriscusFlatBottom' : 'AscendensOriscus',
374 'AscendensOriscusLineBRFlatBottom' : 'AscendensOriscusFlatBottom',
375 'AscendensOriscusLineTRFlatBottom' : 'AscendensOriscusFlatBottom',
376 'AscendensOriscusFlattened' : 'AscendensOriscus',
377 'AscendensOriscusFlatTop' : 'AscendensOriscus',
378 'AscendensOriscusLineBLFlatTop' : 'AscendensOriscusFlatTop',
379 'AscendensOriscusLineTLFlatTop' : 'AscendensOriscusFlatTop',
380 'AscendensOriscusLineBL' : 'AscendensOriscus',
381 'AscendensOriscusLineBLBR' : 'AscendensOriscus',
382 'AscendensOriscusLineBLTR' : 'AscendensOriscus',
383 'AscendensOriscusLineBR' : 'AscendensOriscus',
384 'AscendensOriscusLineTL' : 'AscendensOriscus',
385 'AscendensOriscusLineTLBR' : 'AscendensOriscus',
386 'AscendensOriscusLineTLTR' : 'AscendensOriscus',
387 'AscendensOriscusLineTR' : 'AscendensOriscus',
388 'DescendensOriscusFlatBottom' : 'DescendensOriscus',
389 'DescendensOriscusLineBLFlatBottom' : 'DescendensOriscusFlatBottom',
390 'DescendensOriscusLineTLFlatBottom' : 'DescendensOriscusFlatBottom',
391 'DescendensOriscusFlattened' : 'DescendensOriscus',
392 'DescendensOriscusFlatTop' : 'DescendensOriscus',
393 'DescendensOriscusLineBRFlatTop' : 'DescendensOriscusFlatTop',
394 'DescendensOriscusLineTRFlatTop' : 'DescendensOriscusFlatTop',
395 'DescendensOriscusLineBL' : 'DescendensOriscus',
396 'DescendensOriscusLineBLBR' : 'DescendensOriscus',
397 'DescendensOriscusLineBLTR' : 'DescendensOriscus',
398 'DescendensOriscusLineBR' : 'DescendensOriscus',
399 'DescendensOriscusLineTL' : 'DescendensOriscus',
400 'DescendensOriscusLineTLBR' : 'DescendensOriscus',
401 'DescendensOriscusLineTLTR' : 'DescendensOriscus',
402 'DescendensOriscusLineTR' : 'DescendensOriscus',
403 'mademinutus' : 'Punctum',
404 'mdeminutus' : 'Punctum',
405 'mnbdeminutus' : 'Punctum',
406 'mnbpdeminutus' : 'p2base',
407 'mpdeminutus' : 'p2base',
408 'msdeminutus' : 'p2base',
409 'pesdeminutus' : 'p2base',
410 'PunctumAuctusLineBL' : 'PunctumDescendens',
411 'PunctumLineTLTR' : 'Punctum',
412 'PunctumLineBL' : 'Punctum',
413 'PunctumLineBLBR' : 'Punctum',
414 'PunctumLineBR' : 'Punctum',
415 'PunctumLineTL' : 'Punctum',
416 'PunctumLineTR' : 'Punctum',
417 'QuilismaLineTR' : 'Quilisma',
418 'rvirgabase' : 'virgabase',
419 'rvbase' : 'VirgaBaseLineBL',
420 'StrophaAuctaLongtail' : 'StrophaAucta',
421 'virgabase' : 'Punctum',
422 'VirgaBaseLineBL' : 'virgabase',
423 'VirgaReversaDescendens' : 'mdeminutus',
424 'VirgaReversaLongqueueDescendens' : 'VirgaReversaDescendens',
425 'VirgaReversaOpenqueueDescendens' : 'VirgaReversaDescendens',
426 'VirgaReversaAscendens' : 'pesdeminutus',
427 'VirgaReversaLongqueueAscendens' : 'VirgaReversaAscendens',
428 'VirgaReversaOpenqueueAscendens' : 'VirgaReversaAscendens',
429 },
430 }
431
432 GLYPH_EXISTS = {}
433
434 def glyph_exists(glyph_name):
435 "returns if glyph named glyphName exists in font (boolean)"
436 global GLYPH_EXISTS, oldfont
437 if glyph_name in GLYPH_EXISTS:
438 return GLYPH_EXISTS[glyph_name]
439 result = True
440 try:
441 oldfont.selection.select(glyph_name + '')
442 except Exception:
443 result = False
444 GLYPH_EXISTS[glyph_name] = result
445 return result
446
447 Empty = {}
448
449 def subspecies_of(glyph_name, variant, suffix=''):
450 fallbacks = GLYPH_FALLBACKS.get(suffix, Empty)
451 name_to_try = glyph_name
452 while name_to_try:
453 if subspecies and glyph_exists(name_to_try + subspecies + suffix + variant):
454 return name_to_try + subspecies + suffix + variant
455 elif glyph_exists(name_to_try + suffix + variant):
456 return name_to_try + suffix + variant
457 else:
458 name_to_try = fallbacks.get(name_to_try)
459 if not name_to_try and variant != '':
460 variant = ''
461 name_to_try = glyph_name
462 return glyph_name + suffix + variant
463
464 def copy_existing_glyph(glyph_name, has_cavum=True, variant=''):
465 "copies the named glyph, if it exists, and returns whether it was copied"
466 if glyph_exists(subspecies_of(glyph_name, variant)):
467 complete_paste(glyph_name, has_cavum, variant)
468 set_glyph_name(glyph_name)
469 return True
470 else:
471 return False
472
473 def copy_existing_glyph_as_new(glyph_name, as_name=None, fallback=None,
474 has_cavum=True, variant=''):
475 "copies the named glyph as a new glyph"
476 glyph_to_copy = glyph_name
477 if not glyph_exists(subspecies_of(glyph_to_copy, variant)) and fallback:
478 glyph_to_copy = fallback
479 if glyph_exists(subspecies_of(glyph_to_copy, variant)):
480 new_glyph()
481 complete_paste(glyph_to_copy, has_cavum, variant)
482 set_glyph_name(as_name or glyph_name)
483 return True
484 else:
485 return False
486
487 # This will be populated by initialize_glyphs
488 COMMON_DIRECT_VARIANTS = {}
489
490 def initialize_glyphs():
491 "Builds the first glyphs."
492 global newfont, oldfont, font_name, cavum
493 if cavum == 'hollow':
494 # when generating the hollow font, pre-invert Cavum glyphs
495 print('inverting cavum glyphs for', font_name)
496 for glyph in oldfont.glyphs():
497 if "#Cavum" in glyph.glyphname:
498 # this is a COPY of the foreground layer
499 layer = glyph.foreground
500 for contour in layer:
501 contour.reverseDirection()
502 # since layer is a COPY, it needs to be put back to take effect
503 glyph.foreground = layer
504 # DIRECT_GLYPHS contains the names of the glyphs that are already in
505 # gregorio_base, mostly one-note glyphs.
506 direct_glyphs = list(DIRECT_GLYPHS)
507 direct_glyphs.sort()
508 # not iterating the dictionary directly because we want sorted key order
509 for name in direct_glyphs:
510 if glyph_exists(name):
511 new_glyph()
512 dot_position = name.find('.')
513 if dot_position <= 0:
514 complete_paste(name, DIRECT_GLYPHS[name])
515 else:
516 COMMON_DIRECT_VARIANTS[name] = True
517 complete_paste(name[:dot_position], DIRECT_GLYPHS[name],
518 name[dot_position:])
519 set_glyph_name(name)
520 else:
521 print('Warning: glyph '+name+' missing from '+font_name)
522
523 def use_default_oriscus(orientation, varietal, ignore_varietal = False, line = ''):
524 "Uses the base oriscus"
525 FLATTENED_ORISCUS[orientation+'Oriscus'+line+varietal] = orientation+'Oriscus'+line
526
527 def use_flattened_oriscus(orientation, varietal, ignore_varietal = False, line = ''):
528 "Uses flattened oriscus if it exists"
529 full_name = orientation+'Oriscus'+line+varietal;
530 if glyph_exists(full_name) and not ignore_varietal:
531 FLATTENED_ORISCUS[full_name] = full_name
532 else:
533 if not ignore_varietal:
534 print('Warning: glyph '+full_name+' missing from '+font_name)
535 FLATTENED_ORISCUS[full_name] = orientation+'Oriscus'+line
536
537 def flattened_oriscus():
538 "Copies and sets up the flattened oriscus glyphs"
539 copy_existing_glyph_as_new('AscendensOriscusFlatBottom',
540 S_UPPER_OBLATUS_ASCENDENS_ORISCUS, 'AscendensOriscus')
541 copy_existing_glyph_as_new('DescendensOriscusFlatTop',
542 S_LOWER_OBLATUS_DESCENDENS_ORISCUS, 'DescendensOriscus')
543 global oldfont, FONT_CONFIG, FLATTENED_ORISCUS
544 if 'flattened oriscus' in FONT_CONFIG and FONT_CONFIG['flattened oriscus']:
545 use = use_flattened_oriscus
546 else:
547 use = use_default_oriscus
548 for orientation in [ 'Ascendens', 'Descendens' ]:
549 for varietal in [ 'Flattened', 'FlatTop', 'FlatBottom' ]:
550 use(orientation, varietal)
551 for line in [ 'LineTL', 'LineBL' ]:
552 use('Ascendens', 'FlatTop', False, line)
553 use('Ascendens', 'FlatBottom', True, line)
554 use('Descendens', 'FlatTop', True, line)
555 use('Descendens', 'FlatBottom', False, line)
556 for line in [ 'LineTR', 'LineBR' ]:
557 use('Ascendens', 'FlatTop', True, line)
558 use('Ascendens', 'FlatBottom', False, line)
559 use('Descendens', 'FlatTop', False, line)
560 use('Descendens', 'FlatBottom', True, line)
561
562 def copy_variant_glyphs():
563 "Copies the variant glyphs."
564 global newfont, oldfont
565 for glyph in oldfont.glyphs():
566 name = glyph.glyphname
567 dot_position = name.find('.')
568 if (glyph.isWorthOutputting() and dot_position > 0 and
569 name.find("_") == -1 and name not in COMMON_DIRECT_VARIANTS):
570 base_name = name[:dot_position]
571 variant = name[dot_position:]
572 if base_name in DIRECT_GLYPHS:
573 new_glyph()
574 complete_paste(base_name, DIRECT_GLYPHS[base_name], variant)
575 set_glyph_name(name)
576 elif base_name in VARIANT_CAVUM:
577 new_glyph()
578 if cavum:
579 base_name = VARIANT_CAVUM[base_name]
580 complete_paste(base_name, DIRECT_GLYPHS[base_name], variant)
581 set_glyph_name(base_name + variant)
582
583 def copy_extra_glyphs():
584 "Copies the extra glyphs."
585 global FONT_CONFIG, cavum
586 # extra glyphs are only supported in the non-cavum font
587 if not cavum:
588 extra_glyphs = FONT_CONFIG.get('extra glyphs', [])
589 if len(extra_glyphs) > 0:
590 message('extra glyphs')
591 for name in extra_glyphs:
592 # must use str(name) here because the JSON strings are
593 # apparently not normal strings
594 if copy_existing_glyph_as_new(str(name), has_cavum=False):
595 precise_message(name)
596
597 # this will be populated by get_width
598 WIDTHS = {}
599
600 def get_width(glyphName):
601 "Get length of glyph glyphName in the base font."
602 global oldfont
603 if glyphName not in WIDTHS:
604 if glyph_exists(glyphName):
605 WIDTHS[glyphName] = oldfont[subspecies_of(glyphName, '')].width
606 else:
607 WIDTHS[glyphName] = 0
608 return WIDTHS[glyphName]
609
610 # Shapes
611 S_PES = 'Pes'
612 S_UPPER_PES = 'UpperPes'
613 S_LOWER_PES = 'LowerPes'
614 S_PES_QUADRATUM = 'PesQuadratum'
615 S_UPPER_PES_QUADRATUM = 'UpperPesQuadratum'
616 S_LOWER_PES_QUADRATUM = 'LowerPesQuadratum'
617 S_PES_QUADRATUM_LONGQUEUE = 'PesQuadratumLongqueue'
618 S_UPPER_PES_QUADRATUM_LONGQUEUE = 'UpperPesQuadratumLongqueue'
619 S_LOWER_PES_QUADRATUM_LONGQUEUE = 'LowerPesQuadratumLongqueue'
620 S_PES_QUADRATUM_OPENQUEUE = 'PesQuadratumOpenqueue'
621 S_UPPER_PES_QUADRATUM_OPENQUEUE = 'UpperPesQuadratumOpenqueue'
622 S_LOWER_PES_QUADRATUM_OPENQUEUE = 'LowerPesQuadratumOpenqueue'
623 S_QUILISMA_PES = 'QuilismaPes'
624 S_PES_QUASSUS = 'PesQuassus'
625 S_UPPER_PES_QUASSUS = 'UpperPesQuassus'
626 S_LOWER_PES_QUASSUS = 'LowerPesQuassus'
627 S_UPPER_OBLATUS_PES_QUASSUS = 'UpperOblatusPesQuassus'
628 S_PES_QUASSUS_LONGQUEUE = 'PesQuassusLongqueue'
629 S_UPPER_PES_QUASSUS_LONGQUEUE = 'UpperPesQuassusLongqueue'
630 S_LOWER_PES_QUASSUS_LONGQUEUE = 'LowerPesQuassusLongqueue'
631 S_UPPER_OBLATUS_PES_QUASSUS_LONGQUEUE = 'UpperOblatusPesQuassusLongqueue'
632 S_PES_QUASSUS_OPENQUEUE = 'PesQuassusOpenqueue'
633 S_UPPER_PES_QUASSUS_OPENQUEUE = 'UpperPesQuassusOpenqueue'
634 S_LOWER_PES_QUASSUS_OPENQUEUE = 'LowerPesQuassusOpenqueue'
635 S_UPPER_OBLATUS_PES_QUASSUS_OPENQUEUE = 'UpperOblatusPesQuassusOpenqueue'
636 S_PES_QUASSUS_INUSITATUS = 'PesQuassusInusitatus'
637 S_UPPER_PES_QUASSUS_INUSITATUS = 'UpperPesQuassusInusitatus'
638 S_LOWER_PES_QUASSUS_INUSITATUS = 'LowerPesQuassusInusitatus'
639 S_LOWER_OBLATUS_PES_QUASSUS_INUSITATUS = 'LowerOblatusPesQuassusInusitatus'
640 S_PES_QUASSUS_INUSITATUS_LONGQUEUE = 'PesQuassusInusitatusLongqueue'
641 S_UPPER_PES_QUASSUS_INUSITATUS_LONGQUEUE = 'UpperPesQuassusInusitatusLongqueue'
642 S_LOWER_PES_QUASSUS_INUSITATUS_LONGQUEUE = 'LowerPesQuassusInusitatusLongqueue'
643 S_LOWER_OBLATUS_PES_QUASSUS_INUSITATUS_LONGQUEUE = 'LowerOblatusPesQuassusInusitatusLongqueue'
644 S_PES_QUASSUS_INUSITATUS_OPENQUEUE = 'PesQuassusInusitatusOpenqueue'
645 S_UPPER_PES_QUASSUS_INUSITATUS_OPENQUEUE = 'UpperPesQuassusInusitatusOpenqueue'
646 S_LOWER_PES_QUASSUS_INUSITATUS_OPENQUEUE = 'LowerPesQuassusInusitatusOpenqueue'
647 S_LOWER_OBLATUS_PES_QUASSUS_INUSITATUS_OPENQUEUE = 'LowerOblatusPesQuassusInusitatusOpenqueue'
648 S_QUILISMA_PES_QUADRATUM = 'QuilismaPesQuadratum'
649 S_QUILISMA_PES_QUADRATUM_LONGQUEUE = 'QuilismaPesQuadratumLongqueue'
650 S_QUILISMA_PES_QUADRATUM_OPENQUEUE = 'QuilismaPesQuadratumOpenqueue'
651 S_FLEXUS = 'Flexus'
652 S_UPPER_FLEXUS = 'UpperFlexus'
653 S_LOWER_FLEXUS = 'LowerFlexus'
654 S_FLEXUS_NOBAR = 'FlexusNobar'
655 S_FLEXUS_LONGQUEUE = 'FlexusLongqueue'
656 S_FLEXUS_OPENQUEUE = 'FlexusOpenqueue'
657 S_FLEXUS_ORISCUS = 'FlexusOriscus'
658 S_UPPER_FLEXUS_ORISCUS = 'UpperFlexusOriscus'
659 S_LOWER_FLEXUS_ORISCUS = 'LowerFlexusOriscus'
660 S_LOWER_OBLATUS_FLEXUS_ORISCUS = 'LowerOblatusFlexusOriscus'
661 S_FLEXUS_ORISCUS_INUSITATUS = 'FlexusOriscusInusitatus'
662 S_UPPER_FLEXUS_ORISCUS_INUSITATUS = 'UpperFlexusOriscusInusitatus'
663 S_UPPER_OBLATUS_FLEXUS_ORISCUS_INUSITATUS = 'UpperOblatusFlexusOriscusInusitatus'
664 S_LOWER_FLEXUS_ORISCUS_INUSITATUS = 'LowerFlexusOriscusInusitatus'
665 S_PORRECTUS_FLEXUS = 'PorrectusFlexus'
666 S_PORRECTUS_FLEXUS_LONGQUEUE = 'PorrectusFlexusLongqueue'
667 S_PORRECTUS_FLEXUS_NOBAR = 'PorrectusFlexusNobar'
668 S_PORRECTUS = 'Porrectus'
669 S_PORRECTUS_LONGQUEUE = 'PorrectusLongqueue'
670 S_PORRECTUS_NOBAR = 'PorrectusNobar'
671 # for stem length determination only:
672 S_PORRECTUS_DEMINUTUS_ALT = 'PorrectusDeminutus.alt'
673 S_TORCULUS = 'Torculus'
674 S_TORCULUS_RESUPINUS = 'TorculusResupinus'
675 S_TORCULUS_QUILISMA = 'TorculusQuilisma'
676 S_TORCULUS_RESUPINUS_QUILISMA = 'TorculusResupinusQuilisma'
677 S_SCANDICUS = 'Scandicus'
678 S_ANCUS = 'Ancus'
679 S_ANCUS_LONGQUEUE = 'AncusLongqueue'
680 S_ANCUS_OPENQUEUE = 'AncusOpenqueue'
681 S_PES_ASCENDENS_ORISCUS = 'PesAscendensOriscus'
682 S_PES_DESCENDENS_ORISCUS = 'PesDescendensOriscus'
683 S_SALICUS = 'Salicus'
684 S_SALICUS_LONGQUEUE = 'SalicusLongqueue'
685 S_SALICUS_OPENQUEUE = 'SalicusOpenqueue'
686 S_SALICUS_FLEXUS = 'SalicusFlexus'
687 S_TORCULUS_LIQUESCENS = 'TorculusLiquescens'
688 S_TORCULUS_LIQUESCENS_QUILISMA = 'TorculusLiquescensQuilisma'
689 S_FLEXUS_ORISCUS_SCAPUS = 'FlexusOriscusScapus'
690 S_FLEXUS_ORISCUS_SCAPUS_LONGQUEUE = 'FlexusOriscusScapusLongqueue'
691 S_FLEXUS_ORISCUS_SCAPUS_OPENQUEUE = 'FlexusOriscusScapusOpenqueue'
692 S_FLEXUS_ORISCUS_SCAPUS_INUSITATUS = 'FlexusOriscusScapusInusitatus'
693 S_FLEXUS_ORISCUS_SCAPUS_INUSITATUS_LONGQUEUE = 'FlexusOriscusScapusInusitatusLongqueue'
694 S_FLEXUS_ORISCUS_SCAPUS_INUSITATUS_OPENQUEUE = 'FlexusOriscusScapusInusitatusOpenqueue'
695 S_LEADING_PUNCTUM = 'LeadingPunctum'
696 S_LEADING_QUILISMA = 'LeadingQuilisma'
697 S_LEADING_ORISCUS = 'LeadingOriscus'
698 S_PUNCTUM = 'Punctum'
699 S_UPPER_PUNCTUM = 'UpperPunctum'
700 S_LOWER_PUNCTUM = 'LowerPunctum'
701 S_QUILISMA = 'Quilisma'
702 S_ASCENDENS_ORISCUS = 'AscendensOriscus'
703 S_DESCENDENS_ORISCUS = 'DescendensOriscus'
704 S_ASCENDENS_ORISCUS_SCAPUS = 'AscendensOriscusScapus'
705 S_ASCENDENS_ORISCUS_SCAPUS_LONGQUEUE = 'AscendensOriscusScapusLongqueue'
706 S_ASCENDENS_ORISCUS_SCAPUS_OPENQUEUE = 'AscendensOriscusScapusOpenqueue'
707 S_DESCENDENS_ORISCUS_SCAPUS = 'DescendensOriscusScapus'
708 S_DESCENDENS_ORISCUS_SCAPUS_LONGQUEUE = 'DescendensOriscusScapusLongqueue'
709 S_DESCENDENS_ORISCUS_SCAPUS_OPENQUEUE = 'DescendensOriscusScapusOpenqueue'
710 S_UPPER_ASCENDENS_ORISCUS = 'UpperAscendensOriscus'
711 S_UPPER_DESCENDENS_ORISCUS = 'UpperDescendensOriscus'
712 S_UPPER_OBLATUS_ASCENDENS_ORISCUS = 'UpperOblatusAscendensOriscus'
713 S_LOWER_ASCENDENS_ORISCUS = 'LowerAscendensOriscus'
714 S_LOWER_DESCENDENS_ORISCUS = 'LowerDescendensOriscus'
715 S_LOWER_OBLATUS_DESCENDENS_ORISCUS = 'LowerOblatusDescendensOriscus'
716 S_VIRGA = 'Virga'
717 S_VIRGA_LONGQUEUE = 'VirgaLongqueue'
718 S_VIRGA_OPENQUEUE = 'VirgaOpenqueue'
719 S_UPPER_VIRGA = 'UpperVirga'
720 S_UPPER_VIRGA_LONGQUEUE = 'UpperVirgaLongqueue'
721 S_UPPER_VIRGA_OPENQUEUE = 'UpperVirgaOpenqueue'
722 S_VIRGA_REVERSA = 'VirgaReversa'
723 S_VIRGA_REVERSA_LONGQUEUE = 'VirgaReversaLongqueue'
724 S_VIRGA_REVERSA_OPENQUEUE = 'VirgaReversaOpenqueue'
725
726 # Liquescentiae
727 L_NOTHING = 'Nothing'
728 L_INITIO_DEBILIS = 'InitioDebilis'
729 L_DEMINUTUS = 'Deminutus'
730 L_ASCENDENS = 'Ascendens'
731 L_DESCENDENS = 'Descendens'
732 L_UP = 'Up'
733 L_DOWN = 'Down'
734 L_INITIO_DEBILIS_DEMINUTUS = 'InitioDebilisDeminutus'
735 L_INITIO_DEBILIS_ASCENDENS = 'InitioDebilisAscendens'
736 L_INITIO_DEBILIS_DESCENDENS = 'InitioDebilisDescendens'
737 L_INITIO_DEBILIS_UP = 'InitioDebilisUp'
738 # A very special case for stem length: when the queue of ancus must go to the
739 # bottom of the second note (which is the first note of a deminutus), we use
740 # this.
741 L_DEMINUTUS_FIRST = "DeminutusFirst"
742
743 def complete_paste(src, has_cavum, variant=''):
744 "Copy and paste a glyph."
745 global oldfont, newfont, glyphnumber, cavum
746 if cavum == 'hollow':
747 paste_glyph(src, has_cavum=has_cavum, variant=variant)
748 set_width(get_width(src))
749 else:
750 if has_cavum or cavum != 'hole':
751 oldfont.selection.select(subspecies_of(src, variant,
752 '#Cavum' if cavum == 'hole' else ''))
753 oldfont.copy()
754 newfont.selection.select('u%05x' % glyphnumber)
755 newfont.paste()
756
757 def simplify():
758 """ Simplify a glyph. Does nothing in current version of fontforge (seems to
759 be a bug).
760 """
761 global newfont, glyphnumber
762 newfont[glyphnumber].simplify(0, ['mergelines'])
763 newfont[glyphnumber].simplify()
764 newfont[glyphnumber].removeOverlap()
765 newfont[glyphnumber].simplify(0, ['mergelines'])
766 newfont[glyphnumber].simplify()
767
768 def paste_glyph(src, xdimen=0, ydimen=0, has_cavum=True, variant=''):
769 "Copy and paste a glyph, possibly moving it in the process."
770 global oldfont, newfont, glyphnumber, cavum
771 if not cavum or (has_cavum and cavum == 'hollow'):
772 paste_and_move(src, variant, xdimen, ydimen)
773 if cavum and has_cavum:
774 paste_and_move(src, variant, xdimen, ydimen, '#Cavum')
775
776 def paste_and_move(src, variant, xdimen, ydimen, suffix=''):
777 "Pastes the src glyph into dst, and moves it with horiz and vert offsets."
778 global oldfont, newfont, glyphnumber
779 src = subspecies_of(src, variant, suffix)
780 if xdimen != 0 or ydimen != 0:
781 oldfont[src].transform(psMat.translate(xdimen, ydimen))
782 try:
783 oldfont.selection.select(src)
784 except:
785 raise ValueError('unable to select ' + src)
786 oldfont.copy()
787 newfont.selection.select('u%05x' % glyphnumber)
788 newfont.pasteInto()
789 if xdimen != 0 or ydimen != 0:
790 oldfont[src].transform(psMat.translate(-xdimen, -ydimen))
791
792 def end_glyph(name):
793 "Final function to call when building a glyph."
794 global newfont, glyphnumber
795 set_glyph_name(name)
796 newfont[glyphnumber].simplify(0, ['mergelines'])
797 newfont[glyphnumber].simplify(0)
798 newfont[glyphnumber].removeOverlap()
799 newfont[glyphnumber].simplify(0, ['mergelines'])
800 newfont[glyphnumber].simplify(0)
801 newfont[glyphnumber].canonicalContours()
802 newfont[glyphnumber].canonicalStart()
803
804 def scale(xdimen, ydimen):
805 "Scales a glyph, horizontally by x and vertically by y"
806 global newfont, glyphnumber
807 newfont[glyphnumber].transform(psMat.scale(xdimen, ydimen))
808
809 def move(xdimen, ydimen):
810 "moves a glyph, horizontally by x and vertically by y"
811 global newfont, glyphnumber
812 newfont[glyphnumber].transform(psMat.translate(xdimen, ydimen))
813
814 def set_width(width):
815 "Set the width of a glyph"
816 global newfont, glyphnumber
817 if glyphnumber in newfont:
818 newfont[glyphnumber].width = int(width)
819
820 def get_queue_glyph(height, rev = False):
821 "Creates the asked line glyph in tmpglyph"
822 global oldfont, STEM_SCHEMA
823 oldfont.selection.select('queuebase')
824 oldfont.copy()
825 oldfont.selection.select('tmpglyph')
826 oldfont.paste()
827 # Mind height sign here, transform doesn't like negative values
828 oldfont['tmpglyph'].transform(psMat.scale(1,-height+FONT_CONFIG['stem bottom']+
829 FONT_CONFIG['additional upper queue height']))
830 oldfont['tmpglyph'].transform(psMat.translate(0,height-FONT_CONFIG['stem bottom']))
831 queueglyphname = 'queue' if not rev else 'rqueue'
832 oldfont.selection.select(queueglyphname)
833 oldfont[queueglyphname].transform(psMat.translate(0, height-FONT_CONFIG['stem bottom']))
834 oldfont.copy()
835 oldfont.selection.select('tmpglyph')
836 oldfont.pasteInto()
837 oldfont[queueglyphname].transform(psMat.translate(0, -height+FONT_CONFIG['stem bottom']))
838 oldfont['tmpglyph'].removeOverlap()
839 oldfont['tmpglyph'].simplify(0)
840 oldfont['tmpglyph'].simplify(0, ['mergelines'])
841 return 'tmpglyph'
842
843 def draw_line(i, length, height):
844 "Writes a line in currently selected glyph, with length and height offsets"
845 if cavum != 'hole' and i > 1:
846 linename = "line%d" % i
847 paste_and_move(linename, '', length, height)
848
849 STEM_LIQ_FALLBACKS = {
850 L_DESCENDENS : L_ASCENDENS,
851 L_ASCENDENS : L_NOTHING,
852 L_DEMINUTUS : L_NOTHING,
853 L_INITIO_DEBILIS: L_DEMINUTUS,
854 L_INITIO_DEBILIS_DEMINUTUS: L_DEMINUTUS,
855 L_INITIO_DEBILIS_ASCENDENS: L_ASCENDENS,
856 L_INITIO_DEBILIS_DESCENDENS: L_DESCENDENS,
857 L_UP: L_NOTHING,
858 L_DOWN: L_NOTHING,
859 L_DEMINUTUS_FIRST: L_NOTHING
860 }
861
862 STEM_SHAPE_FALLBACKS = {
863 S_VIRGA_REVERSA : S_VIRGA,
864 S_ASCENDENS_ORISCUS_SCAPUS : S_VIRGA,
865 S_DESCENDENS_ORISCUS_SCAPUS: S_VIRGA,
866 S_FLEXUS_ORISCUS_SCAPUS: S_FLEXUS,
867 S_PES_QUADRATUM: S_FLEXUS,
868 S_PES_QUASSUS: S_PES_QUADRATUM,
869 S_QUILISMA_PES_QUADRATUM: S_PES_QUADRATUM,
870 S_UPPER_PES_QUADRATUM: S_PES_QUADRATUM,
871 S_LOWER_PES_QUADRATUM: S_PES_QUADRATUM,
872 S_UPPER_PES_QUASSUS: S_PES_QUASSUS,
873 S_UPPER_OBLATUS_PES_QUASSUS: S_UPPER_PES_QUASSUS,
874 S_LOWER_PES_QUASSUS: S_PES_QUASSUS,
875 S_PORRECTUS: S_FLEXUS,
876 S_PORRECTUS_FLEXUS: S_PORRECTUS,
877 S_PORRECTUS_DEMINUTUS_ALT: S_FLEXUS,
878 # 3 notes glyphs are handled in a different way, see get_default_shift
879 #S_ANCUS: S_FLEXUS,
880 #S_SALICUS: S_PES_QUASSUS,
881 }
882
883 def get_shift(qtype, shape, liq, i, j):
884 """Returns the shift corresponding to the arguments in the queue length
885 schema or False
886 """
887 global STEM_SCHEMA
888 #print('get shift %s %s %s %d %d' % (qtype, shape, liq, i, j))
889 i = str(i)
890 j = str(j)
891 if shape not in STEM_SCHEMA:
892 return False
893 if liq not in STEM_SCHEMA[shape]:
894 return False
895 if i=='0':
896 return STEM_SCHEMA[shape][liq].get(qtype, False)
897 elif i not in STEM_SCHEMA[shape][liq]:
898 return False
899 elif j=='0':
900 return STEM_SCHEMA[shape][liq][i].get(qtype, False)
901 else:
902 if j in STEM_SCHEMA[shape][liq][i] and qtype in STEM_SCHEMA[shape][liq][i][j]:
903 return STEM_SCHEMA[shape][liq][i][j][qtype]
904 else:
905 return False
906 return False # Shouldn't happen
907
908 def get_default_shift(qtype, shape, liq, i, j, side):
909 """Returns the default shift associated with the schema. This
910 function should be used for ancus or salicus only. The idea
911 is to take i+j when reasonable, i otherwise.
912 """
913 global STEM_SCHEMA
914 if i==0:
915 print('fatal error, this should not happen!')
916 exit()
917 if shape == S_ANCUS:
918 if j==0 or STEM_SCHEMA['ignore j']:
919 return get_shift(qtype, S_FLEXUS, L_DEMINUTUS_FIRST, i, 0)
920 else:
921 if MAX_INTERVAL < (i+j):
922 return get_shift(qtype, S_FLEXUS, L_DEMINUTUS_FIRST, i, 0)
923 else:
924 return get_shift(qtype, S_FLEXUS, L_DEMINUTUS, i+j, 0)
925 elif shape == S_SALICUS:
926 # for this shape, i is the second ambitus j is the first one
927 # so that it's just a mirror of ancus
928 if j==0 or STEM_SCHEMA['ignore j']:
929 return get_queue_shift(qtype, S_PES_QUASSUS, L_NOTHING, i, 'right', 0)
930 else:
931 if MAX_INTERVAL < (i+j):
932 return get_queue_shift(qtype, S_PES_QUASSUS, L_NOTHING, i, 'right', 0)
933 else:
934 return get_queue_shift(qtype, S_PES_QUADRATUM, L_NOTHING, i+j, 'right', 0)
935 else:
936 print('calling get_default_shift with shape %s, this should not happen!' % shape)
937 exit()
938
939 def get_queue_shift(qtype, shape, liq, i=0, side='left', j=0):
940 """ Returns the queue shift associated with the arguments in the queue
941 length schema, applying all fallbacks.
942 """
943 global STEM_SCHEMA
944 queueshape = shape
945 shift = False
946 # kind of do-while loop...
947 while not shift:
948 shift = get_shift(qtype, queueshape, liq, i, j)
949 #print(shift)
950 queueliq = liq
951 while not shift and queueliq in STEM_LIQ_FALLBACKS:
952 queueliq = STEM_LIQ_FALLBACKS[queueliq]
953 shift = get_shift(qtype, queueshape, queueliq, i, j)
954 #print(shift)
955 if queueshape in STEM_SHAPE_FALLBACKS:
956 queueshape = STEM_SHAPE_FALLBACKS[queueshape]
957 else:
958 break
959 if not shift:
960 shift = get_default_shift(qtype, shape, liq, i, j, side)
961 #print(shift)
962 return shift
963
964 def draw_left_queue(i, qtype, stemshape, liq = L_NOTHING, j=0, length=0, shift=0):
965 """ Write the left queue of a glyph. Non-obvious args:
966 - i: the ambitus between the first and second note
967 - j: ambitus between the second and third note in case of an ancus
968 - length: horizontal shift to apply to the queue
969 - shift: the vertical shift to apply to the queue
970 """
971 if cavum != 'hole':
972 qshift = get_queue_shift(qtype, stemshape, liq, i, 'left', j)
973 queue_glyph = get_queue_glyph(qshift, False)
974 paste_and_move(queue_glyph, '', length, shift)
975
976 def draw_right_queue(i, length, qtype, stemshape, liq = L_NOTHING, j=0, shift=0):
977 """ Write the right queue of a glyph. Same arguments as draw_left_queue
978 """
979 if cavum != 'hole':
980 qshift = get_queue_shift(qtype, stemshape, liq, i, 'right', j)
981 queue_glyph = get_queue_glyph(qshift, True)
982 paste_and_move(queue_glyph, '', length, shift)
983
984 def draw_virga_in(right_queue, firstglyph, qtype, liq, stemshape=S_VIRGA, i=0):
985 "Draws a virga at height i."
986 if not right_queue:
987 draw_left_queue(i, qtype, stemshape, liq)
988 paste_glyph(firstglyph, 0, (i)*FONT_CONFIG['base height'])
989 first_width = get_width(firstglyph)
990 if right_queue:
991 draw_right_queue(i, first_width-get_width('line2'), qtype, stemshape)
992 return first_width
993
994 def write_virga(shape, lique=L_NOTHING, right_queue=False, firstglyph='rvirgabase',
995 qtype='short', stemshape=S_VIRGA):
996 "Writes the virga glyphs."
997 new_glyph()
998 if lique == L_NOTHING:
999 glyph_name = shape
1000 else:
1001 glyph_name = '%s%s' % (shape, lique)
1002 if copy_existing_glyph(glyph_name):
1003 return
1004 thislen = draw_virga_in(right_queue, firstglyph, qtype, lique, stemshape)
1005 set_width(thislen)
1006 end_glyph(glyph_name)
1007
1008 def virga():
1009 "Creates virgas"
1010 message("virgas")
1011 write_virga(S_VIRGA, L_NOTHING, True, 'virgabase', 'short', S_VIRGA)
1012 write_virga(S_VIRGA_LONGQUEUE, L_NOTHING, True, 'virgabase', 'long', S_VIRGA)
1013 write_virga(S_VIRGA_OPENQUEUE, L_NOTHING, True, 'virgabase', 'open', S_VIRGA)
1014 write_virga(S_UPPER_VIRGA, L_NOTHING, True, 'VirgaBaseLineBL', 'short', S_VIRGA)
1015 write_virga(S_UPPER_VIRGA_LONGQUEUE, L_NOTHING, True, 'VirgaBaseLineBL', 'long', S_VIRGA)
1016 write_virga(S_UPPER_VIRGA_OPENQUEUE, L_NOTHING, True, 'VirgaBaseLineBL', 'open', S_VIRGA)
1017 write_virga(S_VIRGA_REVERSA, L_NOTHING, False, 'rvirgabase', 'short',
1018 S_VIRGA_REVERSA)
1019 write_virga(S_VIRGA_REVERSA_LONGQUEUE, L_NOTHING, False, 'rvirgabase',
1020 'long', S_VIRGA_REVERSA)
1021 write_virga(S_VIRGA_REVERSA_OPENQUEUE, L_NOTHING, False, 'rvirgabase',
1022 'open', S_VIRGA_REVERSA)
1023 write_virga(S_VIRGA_REVERSA, L_DESCENDENS, False, 'PunctumAuctusLineBL',
1024 'short', S_VIRGA)
1025 write_virga(S_VIRGA_REVERSA_LONGQUEUE, L_DESCENDENS, False,
1026 'PunctumAuctusLineBL', 'long', S_VIRGA)
1027 write_virga(S_VIRGA_REVERSA_OPENQUEUE, L_DESCENDENS, False,
1028 'PunctumAuctusLineBL', 'open', S_VIRGA)
1029 write_virga(S_VIRGA_REVERSA, L_ASCENDENS, False, 'auctusa2', 'short',
1030 S_VIRGA)
1031 write_virga(S_VIRGA_REVERSA_LONGQUEUE, L_ASCENDENS, False, 'auctusa2',
1032 'long', S_VIRGA)
1033 write_virga(S_VIRGA_REVERSA_OPENQUEUE, L_ASCENDENS, False, 'auctusa2',
1034 'open', S_VIRGA)
1035 write_virga(S_ASCENDENS_ORISCUS_SCAPUS, L_NOTHING, False,
1036 'AscendensOriscusLineBL', 'short', S_ASCENDENS_ORISCUS_SCAPUS)
1037 write_virga(S_ASCENDENS_ORISCUS_SCAPUS_LONGQUEUE, L_NOTHING, False,
1038 'AscendensOriscusLineBL', 'long', S_ASCENDENS_ORISCUS_SCAPUS)
1039 write_virga(S_ASCENDENS_ORISCUS_SCAPUS_OPENQUEUE, L_NOTHING, False,
1040 'AscendensOriscusLineBL', 'open', S_ASCENDENS_ORISCUS_SCAPUS)
1041 write_virga(S_DESCENDENS_ORISCUS_SCAPUS, L_NOTHING, False,
1042 'DescendensOriscusLineBL', 'short', S_DESCENDENS_ORISCUS_SCAPUS)
1043 write_virga(S_DESCENDENS_ORISCUS_SCAPUS_LONGQUEUE, L_NOTHING, False,
1044 'DescendensOriscusLineBL', 'long', S_DESCENDENS_ORISCUS_SCAPUS)
1045 write_virga(S_DESCENDENS_ORISCUS_SCAPUS_OPENQUEUE, L_NOTHING, False,
1046 'DescendensOriscusLineBL', 'open', S_DESCENDENS_ORISCUS_SCAPUS)
1047
1048 def draw_deminutus(i, j, length=0, tosimplify=0, firstbar=1):
1049 """As the glyph before a deminutus is not the same as a normal glyph,
1050 and always the same, we can call this function each
1051 time. Sometimes we have to simplify before building the last glyph
1052 (tosimplify=1), and length is the offset.
1053 """
1054 first_glyph_is_complete = False
1055 first_glyph = 'mademinutus' # firstbar == 2
1056 if firstbar == 1:
1057 first_glyph = 'mdeminutus'
1058 elif firstbar == 0:
1059 first_glyph = 'mnbdeminutus'
1060 if j == 1:
1061 if glyph_exists('%sam1flexus' % first_glyph):
1062 first_glyph = '%sam1flexus' % first_glyph
1063 first_glyph_is_complete = True
1064 elif glyph_exists('%sam1' % first_glyph):
1065 first_glyph = '%sam1flexus' % first_glyph
1066 paste_glyph(first_glyph, length, i*FONT_CONFIG['base height'])
1067 if not first_glyph_is_complete:
1068 draw_line(j, length+get_width(first_glyph)-get_width('line2'),
1069 (i-j+1)*FONT_CONFIG['base height'])
1070 if tosimplify:
1071 simplify()
1072 if not first_glyph_is_complete:
1073 paste_glyph("deminutus",
1074 length+get_width(first_glyph)-get_width('deminutus'),
1075 (i-j)*FONT_CONFIG['base height'])
1076 return get_width(first_glyph)
1077
1078 def measures():
1079 "Creates glyphs used only for measurement."
1080 message("glyphs for measurement")
1081 new_glyph()
1082 first_glyph = 'PunctumLineBLBR'
1083 second_glyph = 'PunctumLineTL'
1084 paste_glyph(first_glyph)
1085 draw_line(1, get_width(first_glyph) - get_width('line2'), -FONT_CONFIG['base height'])
1086 paste_glyph(second_glyph, get_width(first_glyph) - get_width('line2'),
1087 -FONT_CONFIG['base height'])
1088 set_width(get_width(first_glyph)+get_width(second_glyph)-get_width('line2'))
1089 end_glyph('FlexusLineBL')
1090 new_glyph()
1091 first_glyph = 'PunctumLineBL'
1092 second_glyph = 'Punctum'
1093 paste_glyph(first_glyph)
1094 paste_glyph(second_glyph, get_width(first_glyph), -FONT_CONFIG['base height'])
1095 set_width(get_width(first_glyph)+get_width(second_glyph))
1096 end_glyph('FlexusAmOneLineBL')
1097
1098 HEPISEMA_GLYPHS = {
1099 'HEpisemaPunctum': 'Punctum',
1100 'HEpisemaFlexusDeminutus': 'mpdeminutus',
1101 'HEpisemaDebilis': 'idebilis',
1102 'HEpisemaInclinatum': 'DescendensPunctumInclinatum',
1103 'HEpisemaInclinatumDeminutus': 'PunctumInclinatumDeminutus',
1104 'HEpisemaStropha': 'Stropha',
1105 'HEpisemaQuilisma': 'Quilisma',
1106 'HEpisemaQuilismaLineTR': 'QuilismaLineTR',
1107 'HEpisemaHighPes': 'PunctumSmall',
1108 'HEpisemaAscendensOriscus': 'AscendensOriscus',
1109 'HEpisemaVirga': 'rvirgabase',
1110 'HEpisemaVirgaBaseLineBL': 'VirgaBaseLineBL',
1111 'HEpisemaAscendensOriscusLineTR': 'AscendensOriscusLineTR',
1112 'HEpisemaPunctumLineBR': 'PunctumLineBR',
1113 'HEpisemaPunctumLineBL': 'PunctumLineBL',
1114 'HEpisemaPunctumLineTL': 'PunctumLineTL',
1115 'HEpisemaPunctumLineTR': 'PunctumLineTR',
1116 'HEpisemaPunctumLineBLBR': 'PunctumLineBLBR',
1117 'HEpisemaPunctumAuctusLineBL': 'PunctumAuctusLineBL',
1118 'HEpisemaAscendensOriscusLineBLTR': 'AscendensOriscusLineBLTR',
1119 'HEpisemaFlat': 'Flat',
1120 'HEpisemaSharp': 'Sharp',
1121 'HEpisemaNatural': 'Natural',
1122 'HEpisemaBarStandard': 'DivisioMinimaTwo',
1123 'HEpisemaBarVirgula': 'VirgulaTwo',
1124 'HEpisemaBarParen': 'DivisioMinimaParenTwo',
1125 'HEpisemaBarVirgulaParen': 'VirgulaParenTwo',
1126 'HEpisemaFlatParen': 'FlatParen',
1127 'HEpisemaSharpParen': 'SharpParen',
1128 'HEpisemaNaturalParen': 'NaturalParen',
1129 }
1130
1131 def hepisema():
1132 "Creates horizontal episemata."
1133 message("horizontal episema")
1134 for target, source in list(HEPISEMA_GLYPHS.items()):
1135 write_hepisema(get_width(source), target)
1136 write_hepisema(get_width(source) * 2.0 / 3.0, target + "Reduced")
1137 reduction = get_width('PunctumSmall')
1138 for i in ALL_AMBITUS:
1139 write_hepisema(get_width("porrectus%d"%i),
1140 'HEpisemaPorrectus%s' % AMBITUS[i], reduction)
1141 for i in ALL_AMBITUS:
1142 if glyph_exists("porrectusam1%d"%i):
1143 write_hepisema(get_width("porrectusam1%d"%i),
1144 'HEpisemaPorrectusAmOne%s' % AMBITUS[i], reduction)
1145 else:
1146 write_hepisema(get_width("porrectus%d"%i),
1147 'HEpisemaPorrectusAmOne%s' % AMBITUS[i], reduction)
1148 # porrectus flexus does not get reduced because the note after is to the right
1149 for i in ALL_AMBITUS:
1150 write_hepisema(get_width("porrectusflexus%d"%i),
1151 'HEpisemaPorrectusFlexus%s' % AMBITUS[i])
1152
1153 def write_hepisema(shape_width, glyphname, reduction=0):
1154 "Writes the horizontal episema glyphs."
1155 global FONT_CONFIG
1156 new_glyph()
1157 if not cavum:
1158 paste_glyph("hepisema_base", has_cavum=False)
1159 drawn_width = shape_width - reduction
1160 scale(drawn_width + 2*FONT_CONFIG['hepisema additional width'], 1)
1161 move(-FONT_CONFIG['hepisema additional width'], 0)
1162 if glyph_exists('hepisemaleft'):
1163 paste_glyph("hepisemaleft", -FONT_CONFIG['hepisema additional width'],
1164 0, False)
1165 if glyph_exists('hepisemaright'):
1166 paste_glyph("hepisemaright",
1167 drawn_width + FONT_CONFIG['hepisema additional width'], 0,
1168 False)
1169 # use the original width for the glyph for the sake of ledger lines
1170 set_width(shape_width)
1171 end_glyph(glyphname)
1172
1173 def pes():
1174 "Creates the pes."
1175 message("pes")
1176 precise_message("pes")
1177 write_all_pes("p2base", S_PES)
1178 precise_message("pes deminutus")
1179 write_all_pes_deminutus("pesdeminutus", S_PES, L_DEMINUTUS)
1180 precise_message("pes quilisma")
1181 write_all_pes("QuilismaLineTR", S_QUILISMA_PES)
1182 precise_message("pes quilisma deminutus")
1183 write_all_pes_deminutus("QuilismaLineTR", S_QUILISMA_PES, L_DEMINUTUS)
1184 precise_message("pes quassus deminutus")
1185 write_all_pes_deminutus("AscendensOriscusLineTR", S_PES_QUASSUS, L_DEMINUTUS)
1186 write_all_pes_deminutus("DescendensOriscusLineTR", S_PES_QUASSUS_INUSITATUS,
1187 L_DEMINUTUS)
1188 precise_message("pes initio debilis")
1189 write_all_pes_debilis(S_PES, L_INITIO_DEBILIS)
1190 precise_message("pes initio debilis deminutus")
1191 write_all_pes_debilis_deminutus(S_PES, L_INITIO_DEBILIS_DEMINUTUS)
1192
1193 def fusion_pes():
1194 "Creates the fusion pes."
1195 message("fusion pes")
1196 precise_message("fusion pes")
1197 write_all_pes("msdeminutus", S_UPPER_PES)
1198 precise_message("fusion pes deminutus")
1199 write_all_pes_deminutus("msdeminutus", S_UPPER_PES, L_DEMINUTUS)
1200 write_all_pes_deminutus("mpdeminutus", S_LOWER_PES, L_DEMINUTUS)
1201 precise_message("fusion pes quassus deminutus")
1202 write_all_pes_deminutus("AscendensOriscusLineBLTR", S_UPPER_PES_QUASSUS,
1203 L_DEMINUTUS)
1204 write_all_pes_deminutus(FLATTENED_ORISCUS["AscendensOriscusLineTRFlatBottom"],
1205 S_UPPER_OBLATUS_PES_QUASSUS, L_DEMINUTUS)
1206 write_all_pes_deminutus("DescendensOriscusLineBLTR",
1207 S_UPPER_PES_QUASSUS_INUSITATUS, L_DEMINUTUS)
1208 write_all_pes_deminutus("AscendensOriscusLineTLTR", S_LOWER_PES_QUASSUS,
1209 L_DEMINUTUS)
1210 write_all_pes_deminutus("DescendensOriscusLineTLTR",
1211 S_LOWER_PES_QUASSUS_INUSITATUS, L_DEMINUTUS)
1212 write_all_pes_deminutus(FLATTENED_ORISCUS["DescendensOriscusLineTRFlatTop"],
1213 S_LOWER_OBLATUS_PES_QUASSUS_INUSITATUS, L_DEMINUTUS)
1214
1215 def write_all_pes(first_glyph, shape, lique=L_NOTHING, i_range=ALL_AMBITUS):
1216 for i in i_range:
1217 write_pes(i, first_glyph, shape, lique)
1218
1219 def write_pes(i, first_glyph, shape, lique=L_NOTHING):
1220 "Writes the pes glyphs."
1221 new_glyph()
1222 glyph_name = '%s%s%s' % (shape, AMBITUS[i], lique)
1223 if copy_existing_glyph(glyph_name):
1224 return
1225 get_width('QuilismaLineTR')
1226 temp_width = 0
1227 width_difference = get_width(first_glyph)-get_width('PunctumSmall')
1228 if width_difference < 0:
1229 paste_glyph(first_glyph, -width_difference, 0)
1230 else:
1231 paste_glyph(first_glyph)
1232 temp_width = get_width(first_glyph)-get_width('line2')
1233 if width_difference < 0:
1234 temp_width = temp_width-width_difference
1235 draw_line(i, temp_width, FONT_CONFIG['base height'])
1236 if width_difference != 0:
1237 paste_glyph('PunctumSmall', width_difference,
1238 i*FONT_CONFIG['base height'])
1239 else:
1240 paste_glyph('PunctumSmall', 0, i*FONT_CONFIG['base height'])
1241 if width_difference < 0:
1242 set_width(get_width('PunctumSmall'))
1243 else:
1244 set_width(get_width(first_glyph))
1245 end_glyph(glyph_name)
1246
1247 def write_all_pes_debilis(shape, lique=L_NOTHING, i_range=ALL_AMBITUS):
1248 for i in i_range:
1249 write_pes_debilis(i, shape, lique)
1250
1251 def write_pes_debilis(i, shape, lique=L_NOTHING):
1252 "Writes the pes debilis glyphs."
1253 new_glyph()
1254 glyph_name = '%s%s%s' % (shape, AMBITUS[i], lique)
1255 if copy_existing_glyph(glyph_name):
1256 return
1257 # with a deminutus it is much more beautiful than with a idebilis
1258 paste_glyph("deminutus")
1259 draw_line(i, get_width('deminutus')-get_width('line2'), FONT_CONFIG['base height'])
1260 simplify()
1261 paste_glyph("PunctumLineBL", get_width('deminutus')-get_width('line2'),
1262 i*FONT_CONFIG['base height'])
1263 set_width(get_width('deminutus')+get_width('PunctumLineBL')-get_width('line2'))
1264 end_glyph(glyph_name)
1265
1266 def write_all_pes_deminutus(first_glyph, shape, lique=L_NOTHING,
1267 i_range=ALL_AMBITUS):
1268 for i in i_range:
1269 write_pes_deminutus(i, first_glyph, shape, lique)
1270
1271 def write_pes_deminutus(i, first_glyph, shape, lique=L_NOTHING):
1272 "Writes the pes deminutus glyphs."
1273 new_glyph()
1274 glyph_name = '%s%s%s' % (shape, AMBITUS[i], lique)
1275 if copy_existing_glyph(glyph_name):
1276 return
1277 paste_glyph(first_glyph)
1278 temp_width = get_width(first_glyph)-get_width('line2')
1279 draw_line(i, temp_width, FONT_CONFIG['base height'])
1280 paste_glyph("rdeminutus",
1281 get_width(first_glyph)-get_width('rdeminutus'),
1282 i*FONT_CONFIG['base height'])
1283 set_width(get_width(first_glyph))
1284 end_glyph(glyph_name)
1285
1286 def write_all_pes_debilis_deminutus(shape, lique=L_NOTHING, i_range=ALL_AMBITUS):
1287 for i in i_range:
1288 write_pes_debilis_deminutus(i, shape, lique)
1289
1290 def write_pes_debilis_deminutus(i, shape, lique=L_NOTHING):
1291 "Writes the pes debilis deminutus glyphs."
1292 new_glyph()
1293 glyph_name = '%s%s%s' % (shape, AMBITUS[i], lique)
1294 if copy_existing_glyph(glyph_name):
1295 return
1296 paste_glyph("deminutus")
1297 draw_line(i, get_width('deminutus')-get_width('line2'), FONT_CONFIG['base height'])
1298 simplify()
1299 paste_glyph("rdeminutus", 0, i*FONT_CONFIG['base height'])
1300 set_width(get_width('deminutus'))
1301 end_glyph(glyph_name)
1302
1303 def pes_quadratum():
1304 "Makes the pes quadratum."
1305 message("pes quadratum")
1306 precise_message("pes quadratum")
1307 write_all_pes_quadratum("PunctumLineTR", "VirgaBaseLineBL", S_PES_QUADRATUM,
1308 stemshape=S_PES_QUADRATUM, qtype='short')
1309 write_all_pes_quadratum("PunctumLineTR", "VirgaBaseLineBL",
1310 S_PES_QUADRATUM_LONGQUEUE, stemshape=S_PES_QUADRATUM, qtype='long')
1311 write_pes_quadratum(1, "PunctumLineTR", "VirgaBaseLineBL",
1312 S_PES_QUADRATUM_OPENQUEUE, stemshape=S_PES_QUADRATUM, qtype='open')
1313 write_all_pes_quadratum("idebilis", "VirgaBaseLineBL", S_PES_QUADRATUM,
1314 lique=L_INITIO_DEBILIS, stemshape=S_PES_QUADRATUM, qtype='short')
1315 write_all_pes_quadratum("idebilis", "VirgaBaseLineBL",
1316 S_PES_QUADRATUM_LONGQUEUE, lique=L_INITIO_DEBILIS,
1317 stemshape=S_PES_QUADRATUM, qtype='long')
1318 write_pes_quadratum(1, "idebilis", "VirgaBaseLineBL",
1319 S_PES_QUADRATUM_OPENQUEUE, lique=L_INITIO_DEBILIS,
1320 stemshape=S_PES_QUADRATUM, qtype='open')
1321 precise_message("pes quassus")
1322 write_all_pes_quadratum("AscendensOriscusLineTR", "VirgaBaseLineBL",
1323 S_PES_QUASSUS, stemshape=S_PES_QUASSUS, qtype='short')
1324 write_all_pes_quadratum("AscendensOriscusLineTR", "VirgaBaseLineBL",
1325 S_PES_QUASSUS_LONGQUEUE, stemshape=S_PES_QUASSUS, qtype='long')
1326 write_pes_quadratum(1, "AscendensOriscusLineTR", "VirgaBaseLineBL",
1327 S_PES_QUASSUS_OPENQUEUE, stemshape=S_PES_QUASSUS, qtype='open')
1328 write_all_pes_quadratum("DescendensOriscusLineTR", "VirgaBaseLineBL",
1329 S_PES_QUASSUS_INUSITATUS, stemshape=S_PES_QUASSUS, qtype='short')
1330 write_all_pes_quadratum("DescendensOriscusLineTR", "VirgaBaseLineBL",
1331 S_PES_QUASSUS_INUSITATUS_LONGQUEUE, stemshape=S_PES_QUASSUS,
1332 qtype='long')
1333 write_pes_quadratum(1, "DescendensOriscusLineTR", "VirgaBaseLineBL",
1334 S_PES_QUASSUS_INUSITATUS_OPENQUEUE, stemshape=S_PES_QUASSUS,
1335 qtype='open')
1336 precise_message("pes quilisma quadratum")
1337 write_all_pes_quadratum("QuilismaLineTR", "VirgaBaseLineBL",
1338 S_QUILISMA_PES_QUADRATUM, stemshape=S_QUILISMA_PES_QUADRATUM,
1339 qtype='short')
1340 write_all_pes_quadratum("QuilismaLineTR", "VirgaBaseLineBL",
1341 S_QUILISMA_PES_QUADRATUM_LONGQUEUE, stemshape=S_QUILISMA_PES_QUADRATUM,
1342 qtype='long')
1343 write_pes_quadratum(1, "QuilismaLineTR", "VirgaBaseLineBL",
1344 S_QUILISMA_PES_QUADRATUM_OPENQUEUE,
1345 stemshape=S_QUILISMA_PES_QUADRATUM, qtype='open')
1346 precise_message("pes auctus ascendens")
1347 write_all_pes_quadratum("PunctumLineTR", "auctusa2", S_PES_QUADRATUM,
1348 L_ASCENDENS)
1349 precise_message("pes initio debilis auctus ascendens")
1350 write_all_pes_quadratum("idebilis", "auctusa2", S_PES_QUADRATUM,
1351 L_INITIO_DEBILIS_ASCENDENS)
1352 precise_message("pes quassus auctus ascendens")
1353 write_all_pes_quadratum("AscendensOriscusLineTR", "auctusa2", S_PES_QUASSUS,
1354 L_ASCENDENS)
1355 write_all_pes_quadratum("DescendensOriscusLineTR", "auctusa2",
1356 S_PES_QUASSUS_INUSITATUS, L_ASCENDENS)
1357 precise_message("pes quilisma auctus ascendens")
1358 write_all_pes_quadratum("QuilismaLineTR", "auctusa2",
1359 S_QUILISMA_PES_QUADRATUM, L_ASCENDENS)
1360 precise_message("pes auctus descendens")
1361 write_all_pes_quadratum("PunctumLineTR", "PunctumAuctusLineBL",
1362 S_PES_QUADRATUM, L_DESCENDENS)
1363 precise_message("pes initio debilis auctus descendens")
1364 write_all_pes_quadratum("idebilis", "PunctumAuctusLineBL", S_PES_QUADRATUM,
1365 L_INITIO_DEBILIS_DESCENDENS)
1366 precise_message("pes quassus auctus descendens")
1367 write_all_pes_quadratum("AscendensOriscusLineTR", "PunctumAuctusLineBL",
1368 S_PES_QUASSUS, L_DESCENDENS)
1369 write_all_pes_quadratum("DescendensOriscusLineTR", "PunctumAuctusLineBL",
1370 S_PES_QUASSUS_INUSITATUS, L_DESCENDENS)
1371 precise_message("pes quilisma auctus descendens")
1372 write_all_pes_quadratum("QuilismaLineTR", "PunctumAuctusLineBL",
1373 S_QUILISMA_PES_QUADRATUM, L_DESCENDENS)
1374
1375 def fusion_pes_quadratum():
1376 "Makes the fusion pes quadratum."
1377 message("fusion pes quadratum")
1378 precise_message("fusion pes quadratum")
1379 write_all_pes_quadratum("msdeminutus", "VirgaBaseLineBL",
1380 S_UPPER_PES_QUADRATUM, stemshape=S_UPPER_PES_QUADRATUM,
1381 qtype='short')
1382 write_all_pes_quadratum("PunctumLineTLTR", "VirgaBaseLineBL", S_LOWER_PES_QUADRATUM,
1383 stemshape=S_LOWER_PES_QUADRATUM, qtype='short')
1384 write_all_pes_quadratum("msdeminutus", "VirgaBaseLineBL",
1385 S_UPPER_PES_QUADRATUM_LONGQUEUE, stemshape=S_UPPER_PES_QUADRATUM,
1386 qtype='long')
1387 write_pes_quadratum(1, "msdeminutus", "VirgaBaseLineBL",
1388 S_UPPER_PES_QUADRATUM_OPENQUEUE, stemshape=S_UPPER_PES_QUADRATUM,
1389 qtype='open')
1390 write_all_pes_quadratum("PunctumLineTLTR", "VirgaBaseLineBL",
1391 S_LOWER_PES_QUADRATUM_LONGQUEUE, stemshape=S_LOWER_PES_QUADRATUM,
1392 qtype='long')
1393 write_pes_quadratum(1, "PunctumLineTLTR", "VirgaBaseLineBL",
1394 S_LOWER_PES_QUADRATUM_OPENQUEUE, stemshape=S_LOWER_PES_QUADRATUM,
1395 qtype='open')
1396 precise_message("fusion pes quassus")
1397 write_all_pes_quadratum("AscendensOriscusLineBLTR", "VirgaBaseLineBL",
1398 S_UPPER_PES_QUASSUS, stemshape=S_UPPER_PES_QUASSUS, qtype='short')
1399 write_all_pes_quadratum("AscendensOriscusLineBLTR", "VirgaBaseLineBL",
1400 S_UPPER_PES_QUASSUS_LONGQUEUE, stemshape=S_UPPER_PES_QUASSUS,
1401 qtype='long')
1402 write_pes_quadratum(1, "AscendensOriscusLineBLTR", "VirgaBaseLineBL",
1403 S_UPPER_PES_QUASSUS_OPENQUEUE, stemshape=S_UPPER_PES_QUASSUS,
1404 qtype='open')
1405 write_all_pes_quadratum(FLATTENED_ORISCUS["AscendensOriscusLineTRFlatBottom"],
1406 "VirgaBaseLineBL", S_UPPER_OBLATUS_PES_QUASSUS,
1407 stemshape=S_UPPER_OBLATUS_PES_QUASSUS, qtype='short')
1408 write_all_pes_quadratum(FLATTENED_ORISCUS["AscendensOriscusLineTRFlatBottom"],
1409 "VirgaBaseLineBL", S_UPPER_OBLATUS_PES_QUASSUS_LONGQUEUE,
1410 stemshape=S_UPPER_OBLATUS_PES_QUASSUS, qtype='long')
1411 write_pes_quadratum(1, FLATTENED_ORISCUS["AscendensOriscusLineTRFlatBottom"],
1412 "VirgaBaseLineBL", S_UPPER_OBLATUS_PES_QUASSUS_OPENQUEUE,
1413 stemshape=S_UPPER_OBLATUS_PES_QUASSUS, qtype='open')
1414 write_all_pes_quadratum("DescendensOriscusLineBLTR", "VirgaBaseLineBL",
1415 S_UPPER_PES_QUASSUS_INUSITATUS, stemshape=S_UPPER_PES_QUASSUS,
1416 qtype='short')
1417 write_all_pes_quadratum("DescendensOriscusLineBLTR", "VirgaBaseLineBL",
1418 S_UPPER_PES_QUASSUS_INUSITATUS_LONGQUEUE,
1419 stemshape=S_UPPER_PES_QUASSUS, qtype='long')
1420 write_pes_quadratum(1, "DescendensOriscusLineBLTR", "VirgaBaseLineBL",
1421 S_UPPER_PES_QUASSUS_INUSITATUS_OPENQUEUE,
1422 stemshape=S_UPPER_PES_QUASSUS, qtype='open')
1423 write_all_pes_quadratum("AscendensOriscusLineTLTR", "VirgaBaseLineBL",
1424 S_LOWER_PES_QUASSUS, stemshape=S_LOWER_PES_QUASSUS, qtype='short')
1425 write_all_pes_quadratum("AscendensOriscusLineTLTR", "VirgaBaseLineBL",
1426 S_LOWER_PES_QUASSUS_LONGQUEUE, stemshape=S_LOWER_PES_QUASSUS,
1427 qtype='long')
1428 write_pes_quadratum(1, "AscendensOriscusLineTLTR", "VirgaBaseLineBL",
1429 S_LOWER_PES_QUASSUS_OPENQUEUE, stemshape=S_LOWER_PES_QUASSUS,
1430 qtype='open')
1431 write_all_pes_quadratum("DescendensOriscusLineTLTR", "VirgaBaseLineBL",
1432 S_LOWER_PES_QUASSUS_INUSITATUS, stemshape=S_LOWER_PES_QUASSUS,
1433 qtype='short')
1434 write_all_pes_quadratum(FLATTENED_ORISCUS["DescendensOriscusLineTRFlatTop"],
1435 "VirgaBaseLineBL", S_LOWER_OBLATUS_PES_QUASSUS_INUSITATUS,
1436 stemshape=S_LOWER_PES_QUASSUS, qtype='short')
1437 write_all_pes_quadratum("DescendensOriscusLineTLTR", "VirgaBaseLineBL",
1438 S_LOWER_PES_QUASSUS_INUSITATUS_LONGQUEUE,
1439 stemshape=S_LOWER_PES_QUASSUS, qtype='long')
1440 write_all_pes_quadratum(FLATTENED_ORISCUS["DescendensOriscusLineTRFlatTop"],
1441 "VirgaBaseLineBL", S_LOWER_OBLATUS_PES_QUASSUS_INUSITATUS_LONGQUEUE,
1442 stemshape=S_LOWER_PES_QUASSUS, qtype='long')
1443 write_pes_quadratum(1, "DescendensOriscusLineTLTR", "VirgaBaseLineBL",
1444 S_LOWER_PES_QUASSUS_INUSITATUS_OPENQUEUE,
1445 stemshape=S_LOWER_PES_QUASSUS, qtype='open')
1446 write_pes_quadratum(1, FLATTENED_ORISCUS["DescendensOriscusLineTRFlatTop"],
1447 "VirgaBaseLineBL", S_LOWER_OBLATUS_PES_QUASSUS_INUSITATUS_OPENQUEUE,
1448 stemshape=S_LOWER_PES_QUASSUS, qtype='open')
1449 precise_message("fusion pes auctus ascendens")
1450 write_all_pes_quadratum("msdeminutus", "auctusa2", S_UPPER_PES_QUADRATUM,
1451 L_ASCENDENS)
1452 write_all_pes_quadratum("PunctumLineTLTR", "auctusa2", S_LOWER_PES_QUADRATUM,
1453 L_ASCENDENS)
1454 precise_message("fusion pes quassus auctus ascendens")
1455 write_all_pes_quadratum("AscendensOriscusLineBLTR", "auctusa2",
1456 S_UPPER_PES_QUASSUS, L_ASCENDENS)
1457 write_all_pes_quadratum("DescendensOriscusLineBLTR", "auctusa2",
1458 S_UPPER_PES_QUASSUS_INUSITATUS, L_ASCENDENS)
1459 write_all_pes_quadratum(FLATTENED_ORISCUS["AscendensOriscusLineTRFlatBottom"],
1460 "auctusa2", S_UPPER_OBLATUS_PES_QUASSUS, L_ASCENDENS)
1461 write_all_pes_quadratum("AscendensOriscusLineTLTR", "auctusa2",
1462 S_LOWER_PES_QUASSUS, L_ASCENDENS)
1463 write_all_pes_quadratum("DescendensOriscusLineTLTR", "auctusa2",
1464 S_LOWER_PES_QUASSUS_INUSITATUS, L_ASCENDENS)
1465 write_all_pes_quadratum(FLATTENED_ORISCUS["DescendensOriscusLineTRFlatTop"],
1466 "auctusa2", S_LOWER_OBLATUS_PES_QUASSUS_INUSITATUS, L_ASCENDENS)
1467 precise_message("fusion pes auctus descendens")
1468 write_all_pes_quadratum("msdeminutus", "PunctumAuctusLineBL",
1469 S_UPPER_PES_QUADRATUM, L_DESCENDENS)
1470 write_all_pes_quadratum("PunctumLineTLTR", "PunctumAuctusLineBL",
1471 S_LOWER_PES_QUADRATUM, L_DESCENDENS)
1472 precise_message("fusion pes quassus auctus descendens")
1473 write_all_pes_quadratum("AscendensOriscusLineBLTR", "PunctumAuctusLineBL",
1474 S_UPPER_PES_QUASSUS, L_DESCENDENS)
1475 write_all_pes_quadratum(FLATTENED_ORISCUS["AscendensOriscusLineTRFlatBottom"],
1476 "PunctumAuctusLineBL", S_UPPER_OBLATUS_PES_QUASSUS, L_DESCENDENS)
1477 write_all_pes_quadratum("DescendensOriscusLineBLTR", "PunctumAuctusLineBL",
1478 S_UPPER_PES_QUASSUS_INUSITATUS, L_DESCENDENS)
1479 write_all_pes_quadratum("AscendensOriscusLineTLTR", "PunctumAuctusLineBL",
1480 S_LOWER_PES_QUASSUS, L_DESCENDENS)
1481 write_all_pes_quadratum("DescendensOriscusLineTLTR", "PunctumAuctusLineBL",
1482 S_LOWER_PES_QUASSUS_INUSITATUS, L_DESCENDENS)
1483 write_all_pes_quadratum(FLATTENED_ORISCUS["DescendensOriscusLineTRFlatTop"],
1484 "PunctumAuctusLineBL", S_LOWER_OBLATUS_PES_QUASSUS_INUSITATUS,
1485 L_DESCENDENS)
1486
1487 def write_all_pes_quadratum(first_glyph, last_glyph, shape, lique=L_NOTHING,
1488 stemshape=None, qtype=None, i_range=ALL_AMBITUS):
1489 for i in i_range:
1490 write_pes_quadratum(i, first_glyph, last_glyph, shape, lique, stemshape,
1491 qtype)
1492
1493 def write_pes_quadratum(i, first_glyph, last_glyph, shape, lique=L_NOTHING,
1494 stemshape=None, qtype=None):
1495 "Writes the pes quadratum glyphs."
1496 new_glyph()
1497 glyph_name = '%s%s%s' % (shape, AMBITUS[i], lique)
1498 if copy_existing_glyph(glyph_name):
1499 return
1500 if i == 1 and first_glyph != 'idebilis' and first_glyph != 'QuilismaLineTR':
1501 if first_glyph == 'PunctumLineTR':
1502 first_glyph = 'Punctum'
1503 elif first_glyph == 'msdeminutus':
1504 first_glyph = 'PunctumLineBL'
1505 elif first_glyph == 'PunctumLineTLTR':
1506 first_glyph = 'PunctumLineTL'
1507 elif 'OriscusLine' in first_glyph:
1508 if first_glyph.endswith('LineTRFlatTop'):
1509 first_glyph = FLATTENED_ORISCUS[first_glyph[:-13] + 'Flattened']
1510 elif first_glyph.endswith('LineTRFlatBottom'):
1511 first_glyph = FLATTENED_ORISCUS[first_glyph[:-16] + 'Flattened']
1512 elif first_glyph.endswith('LineTR'):
1513 first_glyph = FLATTENED_ORISCUS[first_glyph[:-6] + 'FlatTop']
1514 else:
1515 first_glyph = FLATTENED_ORISCUS[first_glyph[:-2] + 'FlatTop']
1516
1517 if last_glyph == 'PunctumLineTL':
1518 last_glyph = 'Punctum'
1519 elif last_glyph == 'auctusa2':
1520 last_glyph = 'PunctumAscendens'
1521 elif last_glyph == 'PunctumAuctusLineBL':
1522 last_glyph = 'PunctumDescendens'
1523 elif last_glyph == 'VirgaBaseLineBL':
1524 last_glyph = 'virgabase'
1525
1526 first_width = get_width(first_glyph)
1527 else:
1528 first_width = get_width(first_glyph)-get_width('line2')
1529 paste_glyph(first_glyph)
1530 if i != 1:
1531 draw_line(i, first_width, FONT_CONFIG['base height'])
1532 paste_glyph(last_glyph, first_width, i*FONT_CONFIG['base height'])
1533 width = first_width+get_width(last_glyph)
1534 if qtype:
1535 draw_right_queue(i, width-get_width('line2'), qtype, stemshape, lique,
1536 shift=i*FONT_CONFIG['base height'])
1537 set_width(width)
1538 end_glyph(glyph_name)
1539
1540 def pes_oriscus():
1541 "Creates the pes oriscus."
1542 precise_message("pes oriscus")
1543 write_all_pes_oriscus("PunctumLineTR", "AscendensOriscusLineBL",
1544 S_PES_ASCENDENS_ORISCUS)
1545 write_all_pes_oriscus("PunctumLineTR", "DescendensOriscusLineBL",
1546 S_PES_DESCENDENS_ORISCUS)
1547
1548 def write_all_pes_oriscus(first_glyph, last_glyph, shape, lique=L_NOTHING,
1549 i_range=ALL_AMBITUS):
1550 for i in i_range:
1551 write_pes_oriscus(i, first_glyph, last_glyph, shape, lique)
1552
1553 def write_pes_oriscus(i, first_glyph, last_glyph, shape, lique=L_NOTHING):
1554 "Writes the pes oriscus glyphs."
1555 new_glyph()
1556 glyph_name = '%s%s%s' % (shape, AMBITUS[i], lique)
1557 if copy_existing_glyph(glyph_name):
1558 return
1559 if i == 1:
1560 first_glyph = 'Punctum'
1561 first_width = get_width(first_glyph)
1562 if last_glyph == 'AscendensOriscusLineBL':
1563 last_glyph = FLATTENED_ORISCUS['AscendensOriscusFlatBottom']
1564 elif last_glyph == 'DescendensOriscusLineBL':
1565 last_glyph = FLATTENED_ORISCUS['DescendensOriscusFlatBottom']
1566 else:
1567 first_width = get_width(first_glyph)-get_width('line2')
1568 paste_glyph(first_glyph)
1569 if i != 1:
1570 draw_line(i, first_width, FONT_CONFIG['base height'])
1571 paste_glyph(last_glyph, first_width, i*FONT_CONFIG['base height'])
1572 set_width(first_width+get_width(last_glyph))
1573 end_glyph(glyph_name)
1574
1575 def salicus():
1576 "Creates the salicus."
1577 message("salicus")
1578 write_all_salicus("VirgaBaseLineBL", S_SALICUS, qtype='short')
1579 write_all_salicus("VirgaBaseLineBL", S_SALICUS_LONGQUEUE, qtype='long')
1580 write_all_salicus("rdeminutus", S_SALICUS, L_DEMINUTUS)
1581 write_all_salicus("auctusa2", S_SALICUS, L_ASCENDENS)
1582 write_all_salicus("PunctumAuctusLineBL", S_SALICUS, L_DESCENDENS)
1583
1584 def write_all_salicus(last_glyph, shape, lique=L_NOTHING, qtype=None,
1585 i_range=ALL_AMBITUS, j_range=ALL_AMBITUS):
1586 for i in i_range:
1587 for j in j_range:
1588 write_salicus(i, j, last_glyph, shape, lique, qtype)
1589
1590 def write_salicus(i, j, last_glyph, shape, lique=L_NOTHING, qtype=None):
1591 "Writes the salicus glyphs."
1592 new_glyph()
1593 glyph_name = '%s%s%s%s' % (shape, AMBITUS[i], AMBITUS[j], lique)
1594 if copy_existing_glyph(glyph_name):
1595 return
1596 length = draw_salicus(i, j, last_glyph, lique, qtype)
1597 set_width(length)
1598 end_glyph(glyph_name)
1599
1600 def draw_salicus(i, j, last_glyph, lique=L_NOTHING, qtype=None):
1601 "Draw a salicus in current glyph."
1602 deminutus = last_glyph == 'rdeminutus'
1603 no_third_glyph = False
1604 if j == 1 and not deminutus and last_glyph == 'VirgaBaseLineBL':
1605 last_glyph = 'virgabase'
1606 if i == 1 and j == 1 and not deminutus:
1607 first_glyph = 'Punctum'
1608 first_width = get_width(first_glyph)
1609 middle_glyph = FLATTENED_ORISCUS['AscendensOriscusFlattened']
1610 middle_width = get_width(middle_glyph)
1611 elif i == 1 and (not deminutus or not glyph_exists('PesQuassusOneDeminutus')):
1612 first_glyph = 'Punctum'
1613 first_width = get_width(first_glyph)
1614 middle_glyph = FLATTENED_ORISCUS['AscendensOriscusLineTRFlatBottom']
1615 middle_width = get_width(middle_glyph)-get_width('line2')
1616 elif j == 1 and not deminutus:
1617 first_glyph = 'PunctumLineTR'
1618 first_width = get_width(first_glyph)-get_width('line2')
1619 middle_glyph = FLATTENED_ORISCUS['AscendensOriscusLineBLFlatTop']
1620 middle_width = get_width(middle_glyph)
1621 elif (j == 1 and deminutus and glyph_exists('PesQuassusOneDeminutus') and
1622 glyph_exists('UpperPesQuassusOneDeminutus')):
1623 if i == 1:
1624 first_glyph = 'Punctum'
1625 first_width = get_width(first_glyph)
1626 middle_glyph = 'PesQuassusOneDeminutus'
1627 middle_width = get_width(middle_glyph)
1628 else:
1629 first_glyph = 'PunctumLineTR'
1630 first_width = get_width(first_glyph)-get_width('line2')
1631 middle_glyph = 'UpperPesQuassusOneDeminutus'
1632 middle_width = get_width(middle_glyph)
1633 no_third_glyph = True
1634 else:
1635 first_glyph = 'PunctumLineTR'
1636 first_width = get_width(first_glyph)-get_width('line2')
1637 middle_glyph = 'AscendensOriscusLineBLTR'
1638 middle_width = get_width(middle_glyph)-get_width('line2')
1639 paste_glyph(first_glyph)
1640 if i != 1:
1641 draw_line(i, first_width, FONT_CONFIG['base height'])
1642 paste_glyph(middle_glyph, first_width, i*FONT_CONFIG['base height'])
1643 length = first_width+middle_width
1644 if not no_third_glyph:
1645 if j != 1:
1646 draw_line(j, length, (i+1)*FONT_CONFIG['base height'])
1647 elif not deminutus:
1648 length = length-0.01
1649 if last_glyph == 'auctusa2':
1650 last_glyph = 'PunctumAscendens'
1651 elif last_glyph == 'PunctumAuctusLineBL':
1652 last_glyph = 'PunctumDescendens'
1653 elif last_glyph == 'VirgaBaseLineBL':
1654 last_glyph = 'virgabase'
1655 elif last_glyph == 'PunctumLineBLBR':
1656 last_glyph = 'PunctumLineBR'
1657 elif last_glyph == 'PunctumLineBL':
1658 last_glyph = 'Punctum'
1659 if not last_glyph:
1660 return length
1661 if not deminutus:
1662 paste_glyph(last_glyph, length, (i+j)*FONT_CONFIG['base height'])
1663 length = length + get_width(last_glyph)
1664 if qtype:
1665 draw_right_queue(j, length-get_width('line2'), qtype, S_SALICUS,
1666 lique, i, (i+j)*FONT_CONFIG['base height'])
1667 else:
1668 length = length+get_width('line2')
1669 paste_glyph(last_glyph, (length-get_width(last_glyph)),
1670 (i+j)*FONT_CONFIG['base height'])
1671 return length
1672
1673 def salicus_flexus():
1674 "Creates the salicus flexus."
1675 message("salicus flexus")
1676 write_all_salicus_flexus("PunctumLineTL")
1677 write_all_salicus_flexus("deminutus", L_DEMINUTUS)
1678 write_all_salicus_flexus("auctusa1", L_ASCENDENS)
1679 write_all_salicus_flexus("auctusd1", L_DESCENDENS)
1680
1681 def write_all_salicus_flexus(last_glyph, lique=L_NOTHING, i_range=ALL_AMBITUS,
1682 j_range=ALL_AMBITUS, k_range=ALL_AMBITUS):
1683 for i in i_range:
1684 for j in j_range:
1685 for k in k_range:
1686 write_salicus_flexus(i, j, k, last_glyph, lique)
1687
1688 def write_salicus_flexus(i, j, k, last_glyph, lique=L_NOTHING):
1689 "Writes the salicus glyphs."
1690 new_glyph()
1691 glyph_name = '%s%s%s%s%s' % (S_SALICUS_FLEXUS, AMBITUS[i], AMBITUS[j],
1692 AMBITUS[k], lique)
1693 if copy_existing_glyph(glyph_name):
1694 return
1695 is_deminutus = last_glyph == 'deminutus'
1696 if is_deminutus:
1697 penult_glyph = None
1698 elif k == 1:
1699 penult_glyph = 'PunctumLineBL'
1700 else:
1701 penult_glyph = 'PunctumLineBLBR'
1702 length = draw_salicus(i, j, penult_glyph)
1703 if is_deminutus:
1704 width_dem = draw_deminutus(j+i, k, length,
1705 firstbar = 0 if j == 1 else 1)
1706 length = length + width_dem
1707 else:
1708 if k == 1 and not is_deminutus:
1709 length = length-0.01
1710 if last_glyph == 'PunctumLineTL':
1711 last_glyph = 'Punctum'
1712 elif last_glyph == 'auctusa1':
1713 last_glyph = 'PunctumAscendens'
1714 elif last_glyph == 'auctusd1':
1715 last_glyph = 'PunctumDescendens'
1716 if k != 1:
1717 length = length - get_width('line2')
1718 draw_line(k, length, (1+i+j-k)*FONT_CONFIG['base height'])
1719 paste_glyph(last_glyph, length, (i+j-k)*FONT_CONFIG['base height'])
1720 length = length + get_width(last_glyph)
1721 set_width(length)
1722 end_glyph(glyph_name)
1723
1724 def flexus():
1725 "Creates the flexus."
1726 message("flexus")
1727 precise_message("flexus")
1728 write_all_flexus("PunctumLineBR", 'PunctumLineTL', S_FLEXUS_NOBAR)
1729 write_all_flexus("DescendensOriscusLineBR", 'PunctumLineTL',
1730 S_FLEXUS_ORISCUS)
1731 write_all_flexus("AscendensOriscusLineBR", 'PunctumLineTL',
1732 S_FLEXUS_ORISCUS_INUSITATUS)
1733 write_all_flexus("rvbase", 'PunctumLineTL', S_FLEXUS, qtype='short')
1734 write_all_flexus("rvbase", 'PunctumLineTL', S_FLEXUS_LONGQUEUE, qtype='long')
1735 write_flexus(1, "rvbase", 'PunctumLineTL', S_FLEXUS_OPENQUEUE, qtype='open')
1736 write_all_flexus("DescendensOriscusLineBLBR", 'PunctumLineTL',
1737 S_FLEXUS_ORISCUS_SCAPUS, stemshape=S_FLEXUS_ORISCUS_SCAPUS,
1738 qtype='short')
1739 write_all_flexus("DescendensOriscusLineBLBR", 'PunctumLineTL',
1740 S_FLEXUS_ORISCUS_SCAPUS_LONGQUEUE,
1741 stemshape=S_FLEXUS_ORISCUS_SCAPUS, qtype='long')
1742 write_flexus(1, "DescendensOriscusLineBLBR", 'PunctumLineTL',
1743 S_FLEXUS_ORISCUS_SCAPUS_OPENQUEUE, stemshape=S_FLEXUS_ORISCUS_SCAPUS,
1744 qtype='open')
1745 write_all_flexus("AscendensOriscusLineBLBR", 'PunctumLineTL',
1746 S_FLEXUS_ORISCUS_SCAPUS_INUSITATUS,
1747 stemshape=S_FLEXUS_ORISCUS_SCAPUS, qtype='short')
1748 write_all_flexus("AscendensOriscusLineBLBR", 'PunctumLineTL',
1749 S_FLEXUS_ORISCUS_SCAPUS_INUSITATUS_LONGQUEUE,
1750 stemshape=S_FLEXUS_ORISCUS_SCAPUS, qtype='long')
1751 write_flexus(1, "AscendensOriscusLineBLBR", 'PunctumLineTL',
1752 S_FLEXUS_ORISCUS_SCAPUS_INUSITATUS_OPENQUEUE,
1753 stemshape=S_FLEXUS_ORISCUS_SCAPUS, qtype='open')
1754 precise_message("flexus deminutus")
1755 write_all_flexus("mdeminutus", 'PunctumLineTL', S_FLEXUS_NOBAR, L_DEMINUTUS)
1756 write_all_flexus("DescendensOriscusLineBR", 'deminutus', S_FLEXUS_ORISCUS,
1757 L_DEMINUTUS)
1758 write_all_flexus("AscendensOriscusLineBR", 'deminutus',
1759 S_FLEXUS_ORISCUS_INUSITATUS, L_DEMINUTUS)
1760 write_all_flexus("mdeminutus", 'PunctumLineTL', S_FLEXUS, L_DEMINUTUS,
1761 qtype='short')
1762 write_all_flexus("mdeminutus", 'PunctumLineTL', S_FLEXUS_LONGQUEUE,
1763 L_DEMINUTUS, qtype='long')
1764 write_flexus(1, "mdeminutus", 'PunctumLineTL', S_FLEXUS_OPENQUEUE,
1765 L_DEMINUTUS, qtype='open')
1766 precise_message("flexus auctus ascendens")
1767 write_all_flexus("PunctumLineBR", 'auctusa1', S_FLEXUS_NOBAR, L_ASCENDENS)
1768 write_all_flexus("DescendensOriscusLineBR", 'auctusa1', S_FLEXUS_ORISCUS,
1769 L_ASCENDENS)
1770 write_all_flexus("AscendensOriscusLineBR", 'auctusa1',
1771 S_FLEXUS_ORISCUS_INUSITATUS, L_ASCENDENS)
1772 write_all_flexus("rvbase", 'auctusa1', S_FLEXUS, L_ASCENDENS, qtype='short')
1773 write_all_flexus("rvbase", 'auctusa1', S_FLEXUS_LONGQUEUE, L_ASCENDENS,
1774 qtype='long')
1775 write_flexus(1, "rvbase", 'auctusa1', S_FLEXUS_OPENQUEUE, L_ASCENDENS,
1776 qtype='open')
1777 write_all_flexus("DescendensOriscusLineBLBR", 'auctusa1',
1778 S_FLEXUS_ORISCUS_SCAPUS, L_ASCENDENS,
1779 stemshape=S_FLEXUS_ORISCUS_SCAPUS, qtype='short')
1780 write_all_flexus("DescendensOriscusLineBLBR", 'auctusa1',
1781 S_FLEXUS_ORISCUS_SCAPUS_LONGQUEUE, L_ASCENDENS,
1782 stemshape=S_FLEXUS_ORISCUS_SCAPUS, qtype='long')
1783 write_flexus(1, "DescendensOriscusLineBLBR", 'auctusa1',
1784 S_FLEXUS_ORISCUS_SCAPUS_OPENQUEUE, L_ASCENDENS,
1785 stemshape=S_FLEXUS_ORISCUS_SCAPUS, qtype='open')
1786 write_all_flexus("AscendensOriscusLineBLBR", 'auctusa1',
1787 S_FLEXUS_ORISCUS_SCAPUS_INUSITATUS, L_ASCENDENS,
1788 stemshape=S_FLEXUS_ORISCUS_SCAPUS, qtype='short')
1789 write_all_flexus("AscendensOriscusLineBLBR", 'auctusa1',
1790 S_FLEXUS_ORISCUS_SCAPUS_INUSITATUS_LONGQUEUE, L_ASCENDENS,
1791 stemshape=S_FLEXUS_ORISCUS_SCAPUS, qtype='long')
1792 write_flexus(1, "AscendensOriscusLineBLBR", 'auctusa1',
1793 S_FLEXUS_ORISCUS_SCAPUS_INUSITATUS_OPENQUEUE, L_ASCENDENS,
1794 stemshape=S_FLEXUS_ORISCUS_SCAPUS, qtype='open')
1795 precise_message("flexus auctus descendens")
1796 write_all_flexus("PunctumLineBR", 'auctusd1', S_FLEXUS_NOBAR, L_DESCENDENS)
1797 write_all_flexus("DescendensOriscusLineBR", 'auctusd1', S_FLEXUS_ORISCUS,
1798 L_DESCENDENS)
1799 write_all_flexus("AscendensOriscusLineBR", 'auctusd1',
1800 S_FLEXUS_ORISCUS_INUSITATUS, L_DESCENDENS)
1801 write_all_flexus("rvbase", 'auctusd1', S_FLEXUS, L_DESCENDENS, qtype='short')
1802 write_all_flexus("rvbase", 'auctusd1', S_FLEXUS_LONGQUEUE, L_DESCENDENS,
1803 qtype='long')
1804 write_flexus(1, "rvbase", 'auctusd1', S_FLEXUS_OPENQUEUE, L_DESCENDENS,
1805 qtype='open')
1806 write_all_flexus("DescendensOriscusLineBLBR", 'auctusd1',
1807 S_FLEXUS_ORISCUS_SCAPUS, L_DESCENDENS, S_FLEXUS_ORISCUS_SCAPUS,
1808 stemshape=S_FLEXUS_ORISCUS_SCAPUS, qtype='short')
1809 write_all_flexus("DescendensOriscusLineBLBR", 'auctusd1',
1810 S_FLEXUS_ORISCUS_SCAPUS_LONGQUEUE, L_DESCENDENS,
1811 S_FLEXUS_ORISCUS_SCAPUS, stemshape=S_FLEXUS_ORISCUS_SCAPUS,
1812 qtype='long')
1813 write_flexus(1, "DescendensOriscusLineBLBR", 'auctusd1',
1814 S_FLEXUS_ORISCUS_SCAPUS_OPENQUEUE, L_DESCENDENS,
1815 S_FLEXUS_ORISCUS_SCAPUS, stemshape=S_FLEXUS_ORISCUS_SCAPUS,
1816 qtype='open')
1817 write_all_flexus("AscendensOriscusLineBLBR", 'auctusd1',
1818 S_FLEXUS_ORISCUS_SCAPUS_INUSITATUS, L_DESCENDENS,
1819 S_FLEXUS_ORISCUS_SCAPUS, stemshape=S_FLEXUS_ORISCUS_SCAPUS,
1820 qtype='short')
1821 write_all_flexus("AscendensOriscusLineBLBR", 'auctusd1',
1822 S_FLEXUS_ORISCUS_SCAPUS_INUSITATUS_LONGQUEUE, L_DESCENDENS,
1823 S_FLEXUS_ORISCUS_SCAPUS, stemshape=S_FLEXUS_ORISCUS_SCAPUS,
1824 qtype='long')
1825 write_flexus(1, "AscendensOriscusLineBLBR", 'auctusd1',
1826 S_FLEXUS_ORISCUS_SCAPUS_INUSITATUS_OPENQUEUE, L_DESCENDENS,
1827 S_FLEXUS_ORISCUS_SCAPUS, stemshape=S_FLEXUS_ORISCUS_SCAPUS,
1828 qtype='open')
1829
1830 def fusion_flexus():
1831 "Creates the fusion flexus."
1832 message("fusion flexus")
1833 precise_message("fusion flexus")
1834 write_all_flexus("mademinutus", 'PunctumLineTL', S_LOWER_FLEXUS)
1835 write_all_flexus("rvbase", 'PunctumLineTL', S_UPPER_FLEXUS)
1836 write_all_flexus("DescendensOriscusLineBLBR", 'PunctumLineTL',
1837 S_UPPER_FLEXUS_ORISCUS)
1838 write_all_flexus("DescendensOriscusLineTLBR", 'PunctumLineTL',
1839 S_LOWER_FLEXUS_ORISCUS)
1840 write_all_flexus(FLATTENED_ORISCUS["DescendensOriscusLineBRFlatTop"],
1841 'PunctumLineTL', S_LOWER_OBLATUS_FLEXUS_ORISCUS)
1842 write_all_flexus("AscendensOriscusLineBLBR", 'PunctumLineTL',
1843 S_UPPER_FLEXUS_ORISCUS_INUSITATUS)
1844 write_all_flexus(FLATTENED_ORISCUS["AscendensOriscusLineBRFlatBottom"],
1845 'PunctumLineTL', S_UPPER_OBLATUS_FLEXUS_ORISCUS_INUSITATUS)
1846 write_all_flexus("AscendensOriscusLineTLBR", 'PunctumLineTL',
1847 S_LOWER_FLEXUS_ORISCUS_INUSITATUS)
1848 precise_message("fusion flexus deminutus")
1849 write_all_flexus("mademinutus", 'deminutus', S_LOWER_FLEXUS, L_DEMINUTUS)
1850 write_all_flexus("mdeminutus", 'deminutus', S_UPPER_FLEXUS, L_DEMINUTUS)
1851 write_all_flexus("DescendensOriscusLineBLBR", 'deminutus',
1852 S_UPPER_FLEXUS_ORISCUS, L_DEMINUTUS)
1853 write_all_flexus("DescendensOriscusLineTLBR", 'deminutus',
1854 S_LOWER_FLEXUS_ORISCUS, L_DEMINUTUS)
1855 write_all_flexus(FLATTENED_ORISCUS["DescendensOriscusLineBRFlatTop"],
1856 'deminutus', S_LOWER_OBLATUS_FLEXUS_ORISCUS, L_DEMINUTUS)
1857 write_all_flexus("AscendensOriscusLineBLBR", 'deminutus',
1858 S_UPPER_FLEXUS_ORISCUS_INUSITATUS, L_DEMINUTUS)
1859 write_all_flexus(FLATTENED_ORISCUS["AscendensOriscusLineBRFlatBottom"],
1860 'deminutus', S_UPPER_OBLATUS_FLEXUS_ORISCUS_INUSITATUS, L_DEMINUTUS)
1861 write_all_flexus("AscendensOriscusLineTLBR", 'deminutus',
1862 S_LOWER_FLEXUS_ORISCUS_INUSITATUS, L_DEMINUTUS)
1863 precise_message("fusion flexus auctus ascendens")
1864 write_all_flexus("mademinutus", 'auctusa1', S_LOWER_FLEXUS, L_ASCENDENS)
1865 write_all_flexus("rvbase", 'auctusa1', S_UPPER_FLEXUS, L_ASCENDENS)
1866 write_all_flexus("DescendensOriscusLineBLBR", 'auctusa1',
1867 S_UPPER_FLEXUS_ORISCUS, L_ASCENDENS)
1868 write_all_flexus("DescendensOriscusLineTLBR", 'auctusa1',
1869 S_LOWER_FLEXUS_ORISCUS, L_ASCENDENS)
1870 write_all_flexus(FLATTENED_ORISCUS["DescendensOriscusLineBRFlatTop"],
1871 'auctusa1', S_LOWER_OBLATUS_FLEXUS_ORISCUS, L_ASCENDENS)
1872 write_all_flexus("AscendensOriscusLineBLBR", 'auctusa1',
1873 S_UPPER_FLEXUS_ORISCUS_INUSITATUS, L_ASCENDENS)
1874 write_all_flexus(FLATTENED_ORISCUS["AscendensOriscusLineBRFlatBottom"],
1875 'auctusa1', S_UPPER_OBLATUS_FLEXUS_ORISCUS_INUSITATUS, L_ASCENDENS)
1876 write_all_flexus("AscendensOriscusLineTLBR", 'auctusa1',
1877 S_LOWER_FLEXUS_ORISCUS_INUSITATUS, L_ASCENDENS)
1878 precise_message("fusion flexus auctus descendens")
1879 write_all_flexus("mademinutus", 'auctusd1', S_LOWER_FLEXUS, L_DESCENDENS)
1880 write_all_flexus("rvbase", 'auctusd1', S_UPPER_FLEXUS, L_DESCENDENS)
1881 write_all_flexus("DescendensOriscusLineBLBR", 'auctusd1',
1882 S_UPPER_FLEXUS_ORISCUS, L_DESCENDENS)
1883 write_all_flexus("DescendensOriscusLineTLBR", 'auctusd1',
1884 S_LOWER_FLEXUS_ORISCUS, L_DESCENDENS)
1885 write_all_flexus(FLATTENED_ORISCUS["DescendensOriscusLineBRFlatTop"],
1886 'auctusd1', S_LOWER_OBLATUS_FLEXUS_ORISCUS, L_DESCENDENS)
1887 write_all_flexus("AscendensOriscusLineBLBR", 'auctusd1',
1888 S_UPPER_FLEXUS_ORISCUS_INUSITATUS, L_DESCENDENS)
1889 write_all_flexus(FLATTENED_ORISCUS["AscendensOriscusLineBRFlatBottom"],
1890 'auctusd1', S_UPPER_OBLATUS_FLEXUS_ORISCUS_INUSITATUS, L_DESCENDENS)
1891 write_all_flexus("AscendensOriscusLineTLBR", 'auctusd1',
1892 S_LOWER_FLEXUS_ORISCUS_INUSITATUS, L_DESCENDENS)
1893
1894 def write_all_flexus(first_glyph, last_glyph, shape, lique=L_NOTHING,
1895 firstglyph_amone=None, lastglyph_amone=None, stemshape=S_FLEXUS,
1896 qtype=None, i_range=ALL_AMBITUS):
1897 for i in i_range:
1898 write_flexus(i, first_glyph, last_glyph, shape, lique, firstglyph_amone,
1899 lastglyph_amone, stemshape, qtype)
1900
1901 def write_flexus(i, first_glyph, last_glyph, shape, lique=L_NOTHING,
1902 firstglyph_amone=None, lastglyph_amone=None, stemshape=S_FLEXUS,
1903 qtype=None):
1904 # pylint: disable=too-many-statements
1905 "Writes the flexus glyphs."
1906 new_glyph()
1907 glyph_name = '%s%s%s' % (shape, AMBITUS[i], lique)
1908 if copy_existing_glyph(glyph_name):
1909 return
1910 # we add a queue if it is a deminutus
1911 if first_glyph == "mdeminutus" and shape != S_UPPER_FLEXUS:
1912 if shape == S_FLEXUS_NOBAR:
1913 length = draw_deminutus(0, i, length=0, tosimplify=1, firstbar=0)
1914 else:
1915 draw_left_queue(i, qtype, stemshape, lique)
1916 length = draw_deminutus(0, i, length=0, tosimplify=1, firstbar=1)
1917 elif last_glyph == 'deminutus' and (shape == S_UPPER_FLEXUS or shape == S_LOWER_FLEXUS):
1918 firstbar = 1 if first_glyph == 'mdeminutus' else 2
1919 length = draw_deminutus(0, i, length=0, tosimplify=1, firstbar=firstbar)
1920 elif last_glyph == 'deminutus':
1921 paste_glyph(first_glyph)
1922 draw_line(i, get_width(first_glyph) - get_width('line2'),
1923 (1-i)*FONT_CONFIG['base height'])
1924 simplify()
1925 paste_glyph("deminutus",
1926 get_width(first_glyph) -
1927 get_width(last_glyph), (-i)*FONT_CONFIG['base height'])
1928 length = get_width(first_glyph)
1929 else:
1930 if qtype:
1931 draw_left_queue(i, qtype, stemshape, lique)
1932 if i == 1 and first_glyph != 'DescendensOriscusLineTLBR':
1933 if last_glyph == 'PunctumLineTL':
1934 last_glyph = 'Punctum'
1935 elif last_glyph == 'auctusa1':
1936 last_glyph = 'PunctumAscendens'
1937 elif last_glyph == 'auctusd1':
1938 last_glyph = 'PunctumDescendens'
1939
1940 if first_glyph == 'PunctumLineBR':
1941 first_glyph = 'Punctum'
1942 elif 'OriscusLine' in first_glyph:
1943 if first_glyph.endswith('LineBRFlatBottom'):
1944 first_glyph = FLATTENED_ORISCUS[first_glyph[:-16] + 'Flattened']
1945 elif first_glyph.endswith('LineBRFlatTop'):
1946 first_glyph = FLATTENED_ORISCUS[first_glyph[:-13] + 'Flattened']
1947 elif first_glyph.endswith('LineBR'):
1948 first_glyph = FLATTENED_ORISCUS[first_glyph[:-6] + 'FlatBottom']
1949 else:
1950 first_glyph = FLATTENED_ORISCUS[first_glyph[:-2] + 'FlatBottom']
1951 elif first_glyph == 'VirgaLineBR':
1952 first_glyph = 'VirgaReversa'
1953 elif first_glyph == 'rvbase':
1954 first_glyph = 'rvirgabase'
1955 elif first_glyph == 'mademinutus':
1956 first_glyph = 'PunctumLineTL'
1957 elif first_glyph == 'PunctumLineBLBR':
1958 first_glyph = 'PunctumLineBL'
1959
1960 length = get_width(first_glyph)
1961 else:
1962 length = get_width(first_glyph)-get_width('line2')
1963 paste_glyph(first_glyph)
1964 if i != 1:
1965 draw_line(i, length, (1-i)*FONT_CONFIG['base height'])
1966 paste_glyph(last_glyph, length, (-i)*FONT_CONFIG['base height'])
1967 length = length + get_width(last_glyph)
1968 set_width(length)
1969 end_glyph(glyph_name)
1970
1971 def porrectus():
1972 "Creates the porrectus."
1973 message("porrectus")
1974 precise_message("porrectus")
1975 write_all_porrectus('PunctumSmall', S_PORRECTUS, qtype='short')
1976 write_all_porrectus('PunctumSmall', S_PORRECTUS_LONGQUEUE, qtype='long',
1977 i_range=AMBITUS_ONE_ONLY)
1978 write_all_porrectus('PunctumSmall', S_PORRECTUS_NOBAR)
1979 precise_message("porrectus auctus ascendens")
1980 write_all_porrectus("auctusa2", S_PORRECTUS, L_ASCENDENS, qtype='short')
1981 write_all_porrectus("auctusa2", S_PORRECTUS_LONGQUEUE, L_ASCENDENS,
1982 qtype='long', i_range=AMBITUS_ONE_ONLY)
1983 write_all_porrectus("auctusa2", S_PORRECTUS_NOBAR, L_ASCENDENS)
1984 precise_message("porrectus auctus descendens")
1985 write_all_porrectus("PunctumAuctusLineBL", S_PORRECTUS, L_DESCENDENS,
1986 qtype='short')
1987 write_all_porrectus("PunctumAuctusLineBL", S_PORRECTUS_LONGQUEUE,
1988 L_DESCENDENS, qtype='long', i_range=AMBITUS_ONE_ONLY)
1989 write_all_porrectus("PunctumAuctusLineBL", S_PORRECTUS_NOBAR, L_DESCENDENS)
1990 precise_message("porrectus deminutus")
1991 write_all_porrectus("rdeminutus", S_PORRECTUS, L_DEMINUTUS, qtype='short')
1992 write_all_porrectus("rdeminutus", S_PORRECTUS_LONGQUEUE, L_DEMINUTUS,
1993 qtype='long')
1994 write_all_porrectus("rdeminutus", S_PORRECTUS_NOBAR, L_DEMINUTUS)
1995 precise_message("porrectus deminutus alt")
1996 write_all_alt_porrectus_deminutus()
1997 write_all_alt_porrectus_deminutus(qtype='long')
1998
1999 def fusion_porrectus():
2000 "Write fusion porrectus."
2001 precise_message("porrectus-like fusion")
2002 write_all_porrectus('', S_FLEXUS, L_UP, qtype='short')
2003 write_all_porrectus('', S_FLEXUS_LONGQUEUE, L_UP, qtype='long',
2004 i_range=AMBITUS_ONE_ONLY)
2005 write_all_porrectus('', S_FLEXUS_NOBAR, L_UP)
2006
2007 def write_all_porrectus(last_glyph, shape, lique=L_NOTHING, qtype=None,
2008 i_range=ALL_AMBITUS, j_range=ALL_AMBITUS):
2009 for i in i_range:
2010 for j in j_range:
2011 write_porrectus(i, j, last_glyph, shape, lique, qtype)
2012
2013 def write_porrectus(i, j, last_glyph, shape, lique=L_NOTHING, qtype=None):
2014 "Writes the porrectus glyphs."
2015 new_glyph()
2016 glyph_name = '%s%s%s%s' % (shape, AMBITUS[i], AMBITUS[j], lique)
2017 if copy_existing_glyph(glyph_name):
2018 return
2019 first_glyph = "porrectus%d" % i
2020 if j == 1 and glyph_exists("porrectusam1%d" % i):
2021 first_glyph = "porrectusam1%d" % i
2022 if last_glyph == 'auctusa2' or last_glyph == 'PunctumAuctusLineBL' or last_glyph == '':
2023 if j == 1:
2024 first_glyph = "porrectusflexusnb%d" % i
2025 if last_glyph == 'auctusa2':
2026 last_glyph = 'PunctumAscendens'
2027 elif last_glyph == 'PunctumAuctusLineBL':
2028 last_glyph = 'PunctumDescendens'
2029 else:
2030 first_glyph = "porrectusflexus%d" % i
2031 if not glyph_exists(first_glyph):
2032 return
2033 if qtype:
2034 draw_left_queue(i, qtype, S_PORRECTUS, L_NOTHING)
2035 length = get_width(first_glyph)
2036 paste_glyph(first_glyph)
2037 draw_line(j, length-get_width('line2'), (-i+1)*FONT_CONFIG['base height'])
2038 length = length-get_width('line2')
2039 if qtype:
2040 simplify()
2041 if last_glyph == 'rdeminutus':
2042 length = length+get_width('line2')
2043 paste_glyph(last_glyph, (length-get_width(last_glyph)),
2044 (j-i)*FONT_CONFIG['base height'])
2045 elif (last_glyph == 'auctusa2' or last_glyph == 'PunctumAuctusLineBL' or
2046 last_glyph == 'PunctumAscendens' or last_glyph == 'PunctumDescendens'):
2047 if j == 1:
2048 length = length+get_width('line2')
2049 paste_glyph(last_glyph, length, (j-i)*FONT_CONFIG['base height'])
2050
2051 length = length + get_width(last_glyph)
2052 elif last_glyph != '':
2053 paste_glyph(last_glyph,
2054 (length-get_width(last_glyph)+get_width('line2')),
2055 (j-i)*FONT_CONFIG['base height'])
2056 length = length+get_width('line2')
2057 elif last_glyph == '' and j == 1:
2058 length = length+get_width('line2')
2059 set_width(length)
2060 end_glyph(glyph_name)
2061
2062 def write_all_alt_porrectus_deminutus(qtype='short', i_range=ALL_AMBITUS,
2063 j_range=ALL_AMBITUS):
2064 for i in i_range:
2065 for j in j_range:
2066 write_alt_porrectus_deminutus(i, j, qtype)
2067
2068 def write_alt_porrectus_deminutus(i, j, qtype='short'):
2069 "Writes the alternate porrectur deminutus glyphs."
2070 new_glyph()
2071 if qtype=='long':
2072 glyph_name = 'PorrectusLongqueue%s%sDeminutus.alt' % (AMBITUS[i], AMBITUS[j])
2073 else:
2074 glyph_name = 'Porrectus%s%sDeminutus.alt' % (AMBITUS[i], AMBITUS[j])
2075 if copy_existing_glyph(glyph_name):
2076 return
2077 draw_left_queue(i, qtype, S_PORRECTUS_DEMINUTUS_ALT, L_NOTHING)
2078 if i == 1:
2079 first_glyph = 'PunctumLineBR'
2080 else:
2081 first_glyph = 'PunctumLineBLBR'
2082 paste_glyph(first_glyph)
2083 draw_line(i, get_width(first_glyph)-get_width('line2'), (-i+1)*FONT_CONFIG['base height'])
2084 simplify()
2085 paste_glyph('mpdeminutus', (get_width(first_glyph)-get_width('line2')),
2086 (-i)*FONT_CONFIG['base height'])
2087 draw_line(j,
2088 get_width(first_glyph)+get_width('mpdeminutus')-
2089 2*get_width('line2'), (-i+1)*FONT_CONFIG['base height'])
2090 paste_glyph('rdeminutus', (get_width(first_glyph)
2091 + get_width('mpdeminutus') -
2092 get_width('line2') -
2093 get_width(('rdeminutus'))),
2094 (j-i)*FONT_CONFIG['base height'])
2095 set_width(get_width(first_glyph)+get_width('mpdeminutus')-
2096 get_width('line2'))
2097 end_glyph(glyph_name)
2098
2099
2100 def porrectusflexus():
2101 "Creates the porrectusflexus."
2102 message("porrectus flexus")
2103 precise_message("porrectus flexus")
2104 write_all_porrectusflexus("PunctumLineTL", S_PORRECTUS_FLEXUS_NOBAR)
2105 write_all_porrectusflexus("PunctumLineTL", S_PORRECTUS_FLEXUS, qtype='short')
2106 write_all_porrectusflexus("PunctumLineTL", S_PORRECTUS_FLEXUS_LONGQUEUE,
2107 qtype='long', i_range=AMBITUS_ONE_ONLY)
2108 precise_message("porrectus flexus auctus descendens")
2109 write_all_porrectusflexus("auctusd1", S_PORRECTUS_FLEXUS_NOBAR, L_DESCENDENS)
2110 write_all_porrectusflexus("auctusd1", S_PORRECTUS_FLEXUS, L_DESCENDENS,
2111 qtype='short')
2112 write_all_porrectusflexus("auctusd1", S_PORRECTUS_FLEXUS_LONGQUEUE,
2113 L_DESCENDENS, qtype='long', i_range=AMBITUS_ONE_ONLY)
2114 precise_message("porrectus flexus auctus ascendens")
2115 write_all_porrectusflexus("auctusa1", S_PORRECTUS_FLEXUS_NOBAR, L_ASCENDENS)
2116 write_all_porrectusflexus("auctusa1", S_PORRECTUS_FLEXUS, L_ASCENDENS,
2117 qtype='short')
2118 write_all_porrectusflexus("auctusa1", S_PORRECTUS_FLEXUS_LONGQUEUE,
2119 L_ASCENDENS, qtype='long', i_range=AMBITUS_ONE_ONLY)
2120 precise_message("porrectus flexus deminutus")
2121 write_all_porrectusflexus("deminutus", S_PORRECTUS_FLEXUS_NOBAR, L_DEMINUTUS)
2122 write_all_porrectusflexus("deminutus", S_PORRECTUS_FLEXUS, L_DEMINUTUS,
2123 qtype='short')
2124 write_all_porrectusflexus("deminutus", S_PORRECTUS_FLEXUS_LONGQUEUE,
2125 L_DEMINUTUS, qtype='long', i_range=AMBITUS_ONE_ONLY)
2126
2127 def write_all_porrectusflexus(last_glyph, shape, lique=L_NOTHING, qtype=None,
2128 i_range=ALL_AMBITUS, j_range=ALL_AMBITUS, k_range=ALL_AMBITUS):
2129 for i in i_range:
2130 for j in j_range:
2131 for k in k_range:
2132 write_porrectusflexus(i, j, k, last_glyph, shape, lique, qtype)
2133
2134 def write_porrectusflexus(i, j, k, last_glyph, shape, lique=L_NOTHING,
2135 qtype=None):
2136 "Writes the porrectusflexus glyphs."
2137 new_glyph()
2138 glyph_name = '%s%s%s%s%s' % (shape, AMBITUS[i], AMBITUS[j], AMBITUS[k], lique)
2139 if copy_existing_glyph(glyph_name):
2140 return
2141 if j == 1:
2142 first_glyph = "porrectusflexusnb%d" % i
2143 else:
2144 first_glyph = "porrectusflexus%d" % i
2145 if not glyph_exists(first_glyph):
2146 return
2147 if qtype:
2148 draw_left_queue(i, qtype, S_PORRECTUS_FLEXUS, L_NOTHING)
2149 length = get_width(first_glyph)
2150 paste_glyph(first_glyph)
2151 draw_line(j, length-get_width('line2'), (-i+1)*FONT_CONFIG['base height'])
2152 if last_glyph == "deminutus":
2153 width_dem = draw_deminutus(j-i, k, length-get_width('line2'),
2154 qtype != None, firstbar=1)
2155 length = length+width_dem-get_width('line2')
2156 else:
2157 simplify()
2158 middle_glyph = 'PunctumLineBLBR'
2159 if j == 1:
2160 if k == 1:
2161 middle_glyph = 'Punctum'
2162 else:
2163 middle_glyph = 'PunctumLineBR'
2164 else:
2165 length = length-get_width('line2')
2166 if k == 1:
2167 middle_glyph = 'PunctumLineBL'
2168 paste_glyph(middle_glyph, length, (j-i)*FONT_CONFIG['base height'])
2169 if k == 1:
2170 if last_glyph == 'PunctumLineTL':
2171 last_glyph = 'Punctum'
2172 elif last_glyph == 'auctusa1':
2173 last_glyph = 'PunctumAscendens'
2174 elif last_glyph == 'auctusd1':
2175 last_glyph = 'PunctumDescendens'
2176 length = length+get_width(middle_glyph)
2177 else:
2178 draw_line(k, length + get_width(middle_glyph) - get_width('line2'),
2179 (j-i-k+1)*FONT_CONFIG['base height'])
2180 length = length + get_width(middle_glyph) - get_width('line2')
2181 paste_glyph(last_glyph, length, (j-i-k)*FONT_CONFIG['base height'])
2182 length = length+get_width(last_glyph)
2183 set_width(length)
2184 end_glyph(glyph_name)
2185
2186 def torculus():
2187 "Creates the torculus."
2188 message("torculus")
2189 precise_message("torculus")
2190 write_all_torculus("PunctumLineTR", "PunctumLineTL", S_TORCULUS)
2191 write_all_torculus("QuilismaLineTR", "PunctumLineTL", S_TORCULUS_QUILISMA)
2192 precise_message("torculus initio debilis")
2193 write_all_torculus("idebilis", "PunctumLineTL", S_TORCULUS, L_INITIO_DEBILIS)
2194 precise_message("torculus auctus descendens")
2195 write_all_torculus("PunctumLineTR", "auctusd1", S_TORCULUS, L_DESCENDENS)
2196 write_all_torculus("QuilismaLineTR", "auctusd1", S_TORCULUS_QUILISMA,
2197 L_DESCENDENS)
2198 precise_message("torculus initio debilis auctus descendens")
2199 write_all_torculus("idebilis", "auctusd1", S_TORCULUS,
2200 L_INITIO_DEBILIS_DESCENDENS)
2201 precise_message("torculus auctus ascendens")
2202 write_all_torculus("PunctumLineTR", "auctusa1", S_TORCULUS, L_ASCENDENS)
2203 write_all_torculus("QuilismaLineTR", "auctusa1", S_TORCULUS_QUILISMA,
2204 L_ASCENDENS)
2205 precise_message("torculus initio debilis auctus ascendens")
2206 write_all_torculus("idebilis", "auctusa1", S_TORCULUS,
2207 L_INITIO_DEBILIS_ASCENDENS)
2208 precise_message("torculus deminutus")
2209 write_all_torculus("PunctumLineTR", "deminutus", S_TORCULUS, L_DEMINUTUS)
2210 write_all_torculus("QuilismaLineTR", "deminutus", S_TORCULUS_QUILISMA,
2211 L_DEMINUTUS)
2212 precise_message("torculus initio debilis deminutus")
2213 write_all_torculus("idebilis", "deminutus", S_TORCULUS,
2214 L_INITIO_DEBILIS_DEMINUTUS)
2215
2216 def write_all_torculus(first_glyph, last_glyph, shape, lique=L_NOTHING,
2217 i_range=ALL_AMBITUS, j_range=ALL_AMBITUS):
2218 for i in i_range:
2219 for j in j_range:
2220 write_torculus(i, j, first_glyph, last_glyph, shape, lique)
2221
2222 def write_torculus(i, j, first_glyph, last_glyph, shape, lique=L_NOTHING):
2223 "Writes the torculus glyphs."
2224 new_glyph()
2225 glyph_name = '%s%s%s%s' % (shape, AMBITUS[i], AMBITUS[j], lique)
2226 if copy_existing_glyph(glyph_name):
2227 return
2228 length = get_width(first_glyph)-get_width('line2')
2229 if first_glyph == "QuilismaLineTR":
2230 if i == 1:
2231 first_glyph = 'Quilisma'
2232 length = get_width(first_glyph)
2233 elif i == 1 and first_glyph == 'PunctumLineTR':
2234 first_glyph = 'Punctum'
2235 length = length = get_width(first_glyph)+0.1
2236 paste_glyph(first_glyph)
2237 if i != 1:
2238 draw_line(i, length, FONT_CONFIG['base height'])
2239 if last_glyph == "deminutus":
2240 if i == 1:
2241 width_dem = draw_deminutus(i, j, length, firstbar=0)
2242 else:
2243 width_dem = draw_deminutus(i, j, length, firstbar=1)
2244 length = length+ width_dem
2245 else:
2246 if j == 1:
2247 if i == 1:
2248 second_glyph = 'Punctum'
2249 else:
2250 second_glyph = 'PunctumLineBL'
2251 paste_glyph(second_glyph, length, i*FONT_CONFIG['base height'])
2252 length = length+get_width(second_glyph)
2253 if last_glyph == 'PunctumLineTL':
2254 last_glyph = 'Punctum'
2255 elif last_glyph == 'auctusa1':
2256 last_glyph = 'PunctumAscendens'
2257 elif last_glyph == 'auctusd1':
2258 last_glyph = 'PunctumDescendens'
2259 else:
2260 if i == 1:
2261 second_glyph = 'PunctumLineBR'
2262 else:
2263 second_glyph = 'PunctumLineBLBR'
2264 paste_glyph(second_glyph, length, i*FONT_CONFIG['base height'])
2265 length = length+get_width(second_glyph)-get_width('line2')
2266 draw_line(j, length, (i-j+1)*FONT_CONFIG['base height'])
2267 paste_glyph(last_glyph, length, (i-j)*FONT_CONFIG['base height'])
2268 length = length+get_width(last_glyph)
2269 set_width(length)
2270 end_glyph(glyph_name)
2271
2272 def torculus_liquescens():
2273 "Creates the torculus liquescens."
2274 precise_message("torculus liquescens")
2275 write_all_torculus_liquescens('PunctumLineTR', S_TORCULUS_LIQUESCENS,
2276 L_DEMINUTUS)
2277 precise_message("torculus liquescens quilisma")
2278 write_all_torculus_liquescens('QuilismaLineTR',
2279 S_TORCULUS_LIQUESCENS_QUILISMA, L_DEMINUTUS)
2280
2281 def write_all_torculus_liquescens(first_glyph, shape, lique='deminutus',
2282 i_range=ALL_AMBITUS, j_range=ALL_AMBITUS, k_range=ALL_AMBITUS):
2283 for i in i_range:
2284 for j in j_range:
2285 for k in k_range:
2286 write_torculus_liquescens(i, j, k, first_glyph, shape, lique)
2287
2288 def write_torculus_liquescens(i, j, k, first_glyph, shape, lique='deminutus'):
2289 "Writes the torculus liquescens glyphs."
2290 new_glyph()
2291 glyph_name = '%s%s%s%s%s' % (shape, AMBITUS[i], AMBITUS[j], AMBITUS[k], lique)
2292 if copy_existing_glyph(glyph_name):
2293 return
2294 length = get_width(first_glyph)-get_width('line2')
2295 if first_glyph == "QuilismaLineTR":
2296 if i == 1:
2297 first_glyph = 'Quilisma'
2298 length = get_width(first_glyph)
2299 elif i == 1:
2300 first_glyph = 'Punctum'
2301 length = get_width(first_glyph)+0.1
2302 paste_glyph(first_glyph)
2303 if i != 1:
2304 draw_line(i, length, FONT_CONFIG['base height'])
2305 flexus_firstbar = 2
2306 if j == 1:
2307 flexus_firstbar = 0
2308 if i == 1:
2309 second_glyph = 'Punctum'
2310 else:
2311 second_glyph = 'PunctumLineBL'
2312 paste_glyph(second_glyph, length, i*FONT_CONFIG['base height'])
2313 length = length+get_width(second_glyph)
2314 else:
2315 if i == 1:
2316 second_glyph = 'PunctumLineBR'
2317 else:
2318 second_glyph = 'PunctumLineBLBR'
2319 paste_glyph(second_glyph, length, i*FONT_CONFIG['base height'])
2320 length = length+get_width(second_glyph)-get_width('line2')
2321 draw_line(j, length, (i-j+1)*FONT_CONFIG['base height'])
2322 width_dem = draw_deminutus(i-j, k, length, firstbar=flexus_firstbar)
2323 length = length+width_dem
2324 set_width(length)
2325 end_glyph(glyph_name)
2326
2327 def torculusresupinus():
2328 "Creates the torculusresupinus."
2329 message("torculus resupinus")
2330 precise_message("torculus resupinus")
2331 write_all_torculusresupinus('PunctumLineTR', 'PunctumSmall',
2332 S_TORCULUS_RESUPINUS)
2333 write_all_torculusresupinus('idebilis', 'PunctumSmall', S_TORCULUS_RESUPINUS,
2334 L_INITIO_DEBILIS)
2335 write_all_torculusresupinus('QuilismaLineTR', 'PunctumSmall',
2336 S_TORCULUS_RESUPINUS_QUILISMA)
2337 precise_message("torculus resupinus deminutus")
2338 write_all_torculusresupinus('PunctumLineTR', 'rdeminutus',
2339 S_TORCULUS_RESUPINUS, L_DEMINUTUS)
2340 write_all_torculusresupinus('idebilis', 'rdeminutus', S_TORCULUS_RESUPINUS,
2341 L_INITIO_DEBILIS_DEMINUTUS)
2342 write_all_torculusresupinus('QuilismaLineTR', 'rdeminutus',
2343 S_TORCULUS_RESUPINUS_QUILISMA, L_DEMINUTUS)
2344 precise_message("torculus resupinus deminutus alt")
2345 write_all_alt_torculusresupinusdeminutus('PunctumLineTR',
2346 S_TORCULUS_RESUPINUS, L_DEMINUTUS)
2347 write_all_alt_torculusresupinusdeminutus('idebilis', S_TORCULUS_RESUPINUS,
2348 L_INITIO_DEBILIS_DEMINUTUS)
2349 write_all_alt_torculusresupinusdeminutus('QuilismaLineTR',
2350 S_TORCULUS_RESUPINUS_QUILISMA, L_DEMINUTUS)
2351 precise_message("torculus resupinus auctus ascendens")
2352 write_all_torculusresupinus('PunctumLineTR', "auctusa2",
2353 S_TORCULUS_RESUPINUS, L_ASCENDENS)
2354 write_all_torculusresupinus('idebilis', "auctusa2", S_TORCULUS_RESUPINUS,
2355 L_INITIO_DEBILIS_ASCENDENS)
2356 write_all_torculusresupinus('QuilismaLineTR', "auctusa2",
2357 S_TORCULUS_RESUPINUS_QUILISMA, L_ASCENDENS)
2358 precise_message("torculus resupinus auctus descendens")
2359 write_all_torculusresupinus('PunctumLineTR', "PunctumAuctusLineBL",
2360 S_TORCULUS_RESUPINUS, L_DESCENDENS)
2361 write_all_torculusresupinus('idebilis', "PunctumAuctusLineBL",
2362 S_TORCULUS_RESUPINUS, L_INITIO_DEBILIS_DESCENDENS)
2363 write_all_torculusresupinus('QuilismaLineTR', "PunctumAuctusLineBL",
2364 S_TORCULUS_RESUPINUS_QUILISMA, L_DESCENDENS)
2365
2366 def write_all_torculusresupinus(first_glyph, last_glyph, shape, lique=L_NOTHING,
2367 i_range=ALL_AMBITUS, j_range=ALL_AMBITUS, k_range=ALL_AMBITUS):
2368 for i in i_range:
2369 for j in j_range:
2370 for k in k_range:
2371 write_torculusresupinus(i, j, k, first_glyph, last_glyph, shape,
2372 lique)
2373
2374 def write_torculusresupinus(i, j, k, first_glyph, last_glyph, shape,
2375 lique=L_NOTHING):
2376 "Writes the torculusresupinus glyphs."
2377 new_glyph()
2378 glyph_name = '%s%s%s%s%s' % (shape, AMBITUS[i], AMBITUS[j], AMBITUS[k], lique)
2379 if copy_existing_glyph(glyph_name):
2380 return
2381 middle_glyph = "porrectus%d" % j
2382 if k == 1 and glyph_exists("porrectusam1%d" % j):
2383 middle_glyph = "porrectusam1%d" % j
2384 if last_glyph == 'auctusa2' or last_glyph == 'PunctumAuctusLineBL':
2385 middle_glyph = "porrectusflexus%d" % j
2386 if k == 1:
2387 middle_glyph = "porrectusflexusnb%d" % j
2388 if last_glyph == 'auctusa2':
2389 last_glyph = 'PunctumAscendens'
2390 elif last_glyph == 'PunctumAuctusLineBL':
2391 last_glyph = 'PunctumDescendens'
2392 if not glyph_exists(middle_glyph):
2393 return
2394 if i == 1 and first_glyph != 'idebilis':
2395 if first_glyph == 'PunctumLineTR':
2396 first_glyph = 'Punctum'
2397 elif first_glyph == 'QuilismaLineTR':
2398 first_glyph = 'Quilisma'
2399 length = get_width(first_glyph)+0.1
2400 else:
2401 length = get_width(first_glyph)-get_width('line2')
2402 paste_glyph(first_glyph)
2403 if i != 1:
2404 draw_line(i, length, FONT_CONFIG['base height'])
2405 paste_glyph(middle_glyph, length, i*FONT_CONFIG['base height'])
2406 length = length + get_width(middle_glyph)
2407 if k != 1:
2408 draw_line(k, length-get_width('line2'), (i-j+1)*FONT_CONFIG['base height'])
2409 simplify()
2410 if last_glyph == "rdeminutus":
2411 paste_glyph(last_glyph,
2412 (length-get_width('rdeminutus')),
2413 (i-j+k)*FONT_CONFIG['base height'])
2414 elif (last_glyph == 'auctusa2' or last_glyph == 'PunctumAuctusLineBL' or
2415 last_glyph == 'PunctumAscendens' or last_glyph == 'PunctumDescendens'):
2416 if k > 1:
2417 length = length-get_width('line2')
2418 paste_glyph(last_glyph, length, (i-j+k)*FONT_CONFIG['base height'])
2419 length = length + get_width(last_glyph)
2420 else:
2421 paste_glyph(last_glyph, (length-get_width(last_glyph)),
2422 (i-j+k)*FONT_CONFIG['base height'])
2423 set_width(length)
2424 end_glyph(glyph_name)
2425
2426 def write_all_alt_torculusresupinusdeminutus(first_glyph, shape, lique=L_NOTHING,
2427 i_range=ALL_AMBITUS, j_range=ALL_AMBITUS, k_range=ALL_AMBITUS):
2428 for i in i_range:
2429 for j in j_range:
2430 for k in k_range:
2431 write_alt_torculusresupinusdeminutus(i, j, k, first_glyph,
2432 shape, lique)
2433
2434 def write_alt_torculusresupinusdeminutus(i, j, k, first_glyph, shape,
2435 lique=L_NOTHING):
2436 # pylint: disable=invalid-name
2437 "Writes the torculusresupinusdeminutus glyphs."
2438 new_glyph()
2439 glyph_name = '%s%s%s%s%s.alt' % (shape, AMBITUS[i], AMBITUS[j], AMBITUS[k], lique)
2440 if copy_existing_glyph(glyph_name):
2441 return
2442 length = get_width(first_glyph)-get_width('line2')
2443 if i == 1:
2444 if first_glyph == 'PunctumLineTR':
2445 first_glyph = 'Punctum'
2446 length = get_width(first_glyph)+0.1
2447 elif first_glyph == 'QuilismaLineTR':
2448 first_glyph = 'Quilisma'
2449 length = get_width(first_glyph)+0.1
2450 paste_glyph(first_glyph)
2451 if i != 1:
2452 draw_line(i, length, FONT_CONFIG['base height'])
2453 if j == 1 and i == 1:
2454 if first_glyph == "idebilis":
2455 second_glyph = 'PunctumLineBL'
2456 last_glyph = 'mnbpdeminutus'
2457 else:
2458 second_glyph = 'Punctum'
2459 last_glyph = 'mnbpdeminutus'
2460 paste_glyph(second_glyph, length, i*FONT_CONFIG['base height'])
2461 length = length + get_width(second_glyph)
2462 elif j == 1:
2463 second_glyph = 'PunctumLineBL'
2464 paste_glyph(second_glyph, length, i*FONT_CONFIG['base height'])
2465 length = length + get_width(second_glyph)
2466 last_glyph = 'mnbpdeminutus'
2467 elif i == 1 and first_glyph != "idebilis":
2468 second_glyph = 'PunctumLineBR'
2469 paste_glyph(second_glyph, length, i*FONT_CONFIG['base height'])
2470 length = length + get_width(second_glyph)-get_width('line2')
2471 draw_line(j, length, (i-j+1)*FONT_CONFIG['base height'])
2472 last_glyph = 'mpdeminutus'
2473 else:
2474 second_glyph = 'PunctumLineBLBR'
2475 paste_glyph(second_glyph, length, i*FONT_CONFIG['base height'])
2476 length = length + get_width(second_glyph)-get_width('line2')
2477 draw_line(j, length, (i-j+1)*FONT_CONFIG['base height'])
2478 last_glyph = 'mpdeminutus'
2479 paste_glyph(last_glyph, length, (i-j)*FONT_CONFIG['base height'])
2480 length = length+get_width(last_glyph)
2481 draw_line(k, length-get_width('line2'), (i-j+1)*FONT_CONFIG['base height'])
2482 paste_glyph('rdeminutus',
2483 length-get_width('rdeminutus'), (i-j+k)*FONT_CONFIG['base height'])
2484 set_width(length)
2485 end_glyph(glyph_name)
2486
2487 def scandicus():
2488 "Creates the scandicus."
2489 message("scandicus")
2490 write_all_scandicus('PunctumSmall')
2491 write_all_scandicus('rdeminutus', L_DEMINUTUS)
2492
2493 def write_all_scandicus(last_glyph, lique=L_NOTHING, i_range=ALL_AMBITUS,
2494 j_range=ALL_AMBITUS):
2495 for i in i_range:
2496 for j in j_range:
2497 write_scandicus(i, j, last_glyph, lique)
2498
2499 def write_scandicus(i, j, last_glyph, lique=L_NOTHING):
2500 "Writes the scandicus glyphs."
2501 new_glyph()
2502 final_vertical_shift = 0
2503 glyph_name = '%s%s%s%s' % (S_SCANDICUS, AMBITUS[i], AMBITUS[j], lique)
2504 if copy_existing_glyph(glyph_name):
2505 return
2506 # special case of i=j=1, we use glyph 1025 directly
2507 if i == 1 and j == 1 and lique == L_NOTHING:
2508 paste_glyph('Punctum')
2509 second_glyph = 'PesOneNothing'
2510 paste_glyph(second_glyph, get_width('Punctum'), FONT_CONFIG['base height'])
2511 set_width(get_width('PesOneNothing')+get_width('Punctum'))
2512 end_glyph(glyph_name)
2513 return
2514 if i == 1:
2515 paste_glyph('Punctum')
2516 length = get_width('Punctum')
2517 second_glyph = 'p2base'
2518 if lique == L_DEMINUTUS:
2519 second_glyph = 'mnbpdeminutus'
2520 if j == 1:
2521 final_vertical_shift = FONT_CONFIG['deminutus vertical shift']
2522 else:
2523 paste_glyph('PunctumLineTR')
2524 length = get_width('PunctumLineTR') - get_width('line2')
2525 draw_line(i, length, FONT_CONFIG['base height'])
2526 second_glyph = 'msdeminutus'
2527 if j == 1 and glyph_exists('msdeminutusam1'):
2528 second_glyph = 'msdeminutusam1'
2529 if j == 1:
2530 final_vertical_shift = FONT_CONFIG['deminutus vertical shift']
2531 if j == 1 and lique == L_NOTHING and glyph_exists('UpperPesOneNothing'):
2532 paste_glyph('UpperPesOneNothing', length, i * FONT_CONFIG['base height'])
2533 set_width(length + get_width('UpperPesOneNothing'))
2534 end_glyph(glyph_name)
2535 return
2536 paste_glyph(second_glyph, length, i*FONT_CONFIG['base height'])
2537 if (i == 1) and lique == L_NOTHING:
2538 length = length + get_width('Punctum')
2539 else:
2540 length = length + get_width(second_glyph)
2541 if j != 1:
2542 draw_line(j, length - get_width('line2'), (i+1) * FONT_CONFIG['base height'])
2543 if last_glyph == 'rdeminutus':
2544 paste_glyph('rdeminutus', length -
2545 get_width('rdeminutus'), (i+j)*FONT_CONFIG['base height']+
2546 final_vertical_shift)
2547 else:
2548 paste_glyph(last_glyph, length - get_width(last_glyph),
2549 (i+j)*FONT_CONFIG['base height']+final_vertical_shift)
2550 set_width(length)
2551 end_glyph(glyph_name)
2552
2553 def ancus():
2554 "Creates the ancus."
2555 message("ancus")
2556 write_all_ancus('rvbase', S_ANCUS, 'short')
2557 write_all_ancus('rvbase', S_ANCUS_LONGQUEUE, 'long')
2558
2559 def write_all_ancus(first_glyph, glyph_type, qtype, i_range=ALL_AMBITUS,
2560 j_range=ALL_AMBITUS):
2561 for i in i_range:
2562 for j in j_range:
2563 write_ancus(i, j, first_glyph, glyph_type, qtype)
2564
2565 def write_ancus(i, j, first_glyph, glyph_type, qtype):
2566 "Writes the ancus glyphs."
2567 new_glyph()
2568 glyph_name = '%s%s%s%s' % (glyph_type, AMBITUS[i], AMBITUS[j], L_DEMINUTUS)
2569 if copy_existing_glyph(glyph_name):
2570 return
2571 draw_left_queue(i, qtype, S_ANCUS, L_NOTHING, j)
2572 if i == 1:
2573 first_glyph = 'rvirgabase'
2574 length = get_width(first_glyph)
2575 else:
2576 length = get_width(first_glyph) - get_width('line2')
2577 paste_glyph(first_glyph)
2578 if i != 1:
2579 draw_line(i, length, (-i+1)*FONT_CONFIG['base height'])
2580 width_dem = draw_deminutus(-i, j, length,
2581 firstbar = 0 if i == 1 else 2)
2582 set_width(length+width_dem)
2583 end_glyph(glyph_name)
2584
2585 def leading():
2586 "Creates the leading fusion glyphs."
2587 message("leading fusion glyphs")
2588 write_all_leading('PunctumLineTR', S_LEADING_PUNCTUM)
2589 write_all_leading('idebilis', S_LEADING_PUNCTUM, L_INITIO_DEBILIS)
2590 write_all_leading('QuilismaLineTR', S_LEADING_QUILISMA)
2591 write_all_leading('AscendensOriscusLineTR', S_LEADING_ORISCUS)
2592
2593 # lique has a slightly different meaning here
2594 def write_all_leading(first_glyph, glyph_type, lique='', i_range=ALL_AMBITUS):
2595 for i in i_range:
2596 write_leading(i, first_glyph, glyph_type, lique)
2597
2598 def write_leading(i, first_glyph, glyph_type, lique=''):
2599 "Writes the leading fusion glyphs."
2600 new_glyph()
2601 glyph_name = '%s%s%s' % (glyph_type, AMBITUS[i], lique)
2602 if copy_existing_glyph(glyph_name):
2603 return
2604 length = -get_width('line2')
2605 if i == 1 and first_glyph != 'idebilis':
2606 length = 0.1
2607 if first_glyph == 'PunctumLineTR':
2608 first_glyph = 'Punctum'
2609 elif first_glyph == 'QuilismaLineTR':
2610 first_glyph = 'Quilisma'
2611 elif first_glyph == 'AscendensOriscusLineTR':
2612 first_glyph = FLATTENED_ORISCUS['AscendensOriscusFlatTop']
2613 length = get_width(first_glyph) + length
2614 paste_glyph(first_glyph, 0, -i * FONT_CONFIG['base height'])
2615 if i != 1:
2616 draw_line(i, length, -(i-1) * FONT_CONFIG['base height'])
2617 simplify()
2618 set_width(length)
2619 end_glyph(glyph_name)
2620
2621 def fusion():
2622 "Creates the fusion glyphs."
2623 message("simple fusion glyphs")
2624 write_all_fusion_leading('PunctumLineTR', S_PUNCTUM, L_UP)
2625 write_all_fusion_leading('msdeminutus', S_UPPER_PUNCTUM, L_UP)
2626 write_all_fusion_leading('PunctumLineTLTR', S_LOWER_PUNCTUM, L_UP)
2627 write_all_fusion_leading('idebilis', S_PUNCTUM, L_INITIO_DEBILIS_UP)
2628 write_all_fusion_leading('QuilismaLineTR', S_QUILISMA, L_UP)
2629 write_all_fusion_leading('AscendensOriscusLineTR', S_ASCENDENS_ORISCUS, L_UP)
2630 write_all_fusion_leading('DescendensOriscusLineTR', S_DESCENDENS_ORISCUS,
2631 L_UP)
2632 write_all_fusion_leading('AscendensOriscusLineBLTR',
2633 S_UPPER_ASCENDENS_ORISCUS, L_UP)
2634 write_all_fusion_leading(FLATTENED_ORISCUS['AscendensOriscusLineTRFlatBottom'],
2635 S_UPPER_OBLATUS_ASCENDENS_ORISCUS, L_UP)
2636 write_all_fusion_leading('DescendensOriscusLineBLTR',
2637 S_UPPER_DESCENDENS_ORISCUS, L_UP)
2638 write_all_fusion_leading('AscendensOriscusLineTLTR',
2639 S_LOWER_ASCENDENS_ORISCUS, L_UP)
2640 write_all_fusion_leading('DescendensOriscusLineTLTR',
2641 S_LOWER_DESCENDENS_ORISCUS, L_UP)
2642 write_all_fusion_leading(FLATTENED_ORISCUS['DescendensOriscusLineTRFlatTop'],
2643 S_LOWER_OBLATUS_DESCENDENS_ORISCUS, L_UP)
2644 write_all_fusion_leading('AscendensOriscusLineBLTR',
2645 S_ASCENDENS_ORISCUS_SCAPUS, L_UP, qtype='short',
2646 stemshape=S_FLEXUS_ORISCUS_SCAPUS)
2647 write_all_fusion_leading('AscendensOriscusLineBLTR',
2648 S_ASCENDENS_ORISCUS_SCAPUS_LONGQUEUE, L_UP, qtype='long',
2649 stemshape=S_FLEXUS_ORISCUS_SCAPUS)
2650 write_fusion_leading(1, 'AscendensOriscusLineBLTR',
2651 S_ASCENDENS_ORISCUS_SCAPUS_OPENQUEUE, L_UP, qtype='open',
2652 stemshape=S_FLEXUS_ORISCUS_SCAPUS)
2653 write_all_fusion_leading('DescendensOriscusLineBLTR',
2654 S_DESCENDENS_ORISCUS_SCAPUS, L_UP, qtype='short',
2655 stemshape=S_FLEXUS_ORISCUS_SCAPUS)
2656 write_all_fusion_leading('DescendensOriscusLineBLTR',
2657 S_DESCENDENS_ORISCUS_SCAPUS_LONGQUEUE, L_UP, qtype='long',
2658 stemshape=S_FLEXUS_ORISCUS_SCAPUS)
2659 write_fusion_leading(1, 'DescendensOriscusLineBLTR',
2660 S_DESCENDENS_ORISCUS_SCAPUS_OPENQUEUE, L_UP, qtype='open',
2661 stemshape=S_FLEXUS_ORISCUS_SCAPUS)
2662 write_all_fusion_leading('AscendensOriscusLineBR', S_ASCENDENS_ORISCUS,
2663 L_DOWN)
2664 write_all_fusion_leading('DescendensOriscusLineBR', S_DESCENDENS_ORISCUS,
2665 L_DOWN)
2666 write_all_fusion_leading('AscendensOriscusLineBLBR',
2667 S_UPPER_ASCENDENS_ORISCUS, L_DOWN)
2668 write_all_fusion_leading(FLATTENED_ORISCUS['AscendensOriscusLineBRFlatBottom'],
2669 S_UPPER_OBLATUS_ASCENDENS_ORISCUS, L_DOWN)
2670 write_all_fusion_leading('DescendensOriscusLineBLBR',
2671 S_UPPER_DESCENDENS_ORISCUS, L_DOWN)
2672 write_all_fusion_leading('AscendensOriscusLineTLBR',
2673 S_LOWER_ASCENDENS_ORISCUS, L_DOWN)
2674 write_all_fusion_leading('DescendensOriscusLineTLBR',
2675 S_LOWER_DESCENDENS_ORISCUS, L_DOWN)
2676 write_all_fusion_leading(FLATTENED_ORISCUS['DescendensOriscusLineBRFlatTop'],
2677 S_LOWER_OBLATUS_DESCENDENS_ORISCUS, L_DOWN)
2678 write_all_fusion_leading("AscendensOriscusLineBLBR",
2679 S_ASCENDENS_ORISCUS_SCAPUS, L_DOWN, qtype='short',
2680 stemshape=S_FLEXUS_ORISCUS_SCAPUS)
2681 write_all_fusion_leading("AscendensOriscusLineBLBR",
2682 S_ASCENDENS_ORISCUS_SCAPUS_LONGQUEUE, L_DOWN, qtype='long',
2683 stemshape=S_FLEXUS_ORISCUS_SCAPUS)
2684 write_fusion_leading(1, "AscendensOriscusLineBLBR",
2685 S_ASCENDENS_ORISCUS_SCAPUS_OPENQUEUE, L_DOWN, qtype='open',
2686 stemshape=S_FLEXUS_ORISCUS_SCAPUS)
2687 write_all_fusion_leading("DescendensOriscusLineBLBR",
2688 S_DESCENDENS_ORISCUS_SCAPUS, L_DOWN, qtype='short',
2689 stemshape=S_FLEXUS_ORISCUS_SCAPUS)
2690 write_all_fusion_leading("DescendensOriscusLineBLBR",
2691 S_DESCENDENS_ORISCUS_SCAPUS_LONGQUEUE, L_DOWN, qtype='long',
2692 stemshape=S_FLEXUS_ORISCUS_SCAPUS)
2693 write_fusion_leading(1, "DescendensOriscusLineBLBR",
2694 S_DESCENDENS_ORISCUS_SCAPUS_OPENQUEUE, L_DOWN, qtype='open',
2695 stemshape=S_FLEXUS_ORISCUS_SCAPUS)
2696 write_all_fusion_leading('PunctumLineBR', S_PUNCTUM, L_DOWN)
2697 write_all_fusion_leading('PunctumLineBLBR', S_UPPER_PUNCTUM, L_DOWN)
2698 write_all_fusion_leading('mademinutus', S_LOWER_PUNCTUM, L_DOWN)
2699 write_all_fusion_leading('VirgaBaseLineBL', S_VIRGA_REVERSA, L_DOWN,
2700 qtype='short', stemshape=S_FLEXUS)
2701 write_all_fusion_leading('VirgaBaseLineBL', S_VIRGA_REVERSA_LONGQUEUE,
2702 L_DOWN, qtype='long', stemshape=S_FLEXUS)
2703 write_fusion_leading(1, 'VirgaBaseLineBL', S_VIRGA_REVERSA_OPENQUEUE,
2704 L_DOWN, qtype='open', stemshape=S_FLEXUS)
2705
2706 # lique is only for initio debilis here
2707 def write_all_fusion_leading(first_glyph, glyph_type, lique, qtype=None,
2708 stemshape=None, i_range=ALL_AMBITUS):
2709 for i in i_range:
2710 write_fusion_leading(i, first_glyph, glyph_type, lique, qtype,
2711 stemshape)
2712
2713 def write_fusion_leading(i, first_glyph, glyph_type, lique, qtype=None,
2714 stemshape=None):
2715 "Writes the fusion glyphs."
2716 new_glyph()
2717 glyph_name = '%s%s%s' % (glyph_type, AMBITUS[i], lique)
2718 if copy_existing_glyph(glyph_name):
2719 return
2720 length = -get_width('line2')
2721 if i == 1 and first_glyph != 'idebilis':
2722 length = 0.1
2723 if first_glyph == 'PunctumLineTR' or first_glyph == 'PunctumLineBR':
2724 first_glyph = 'Punctum'
2725 elif first_glyph == 'QuilismaLineTR':
2726 first_glyph = 'Quilisma'
2727 elif 'Oriscus' in first_glyph and 'Line' in first_glyph:
2728 if 'Flat' in first_glyph:
2729 if first_glyph.endswith('LineBRFlatTop'):
2730 first_glyph = FLATTENED_ORISCUS[first_glyph[:-13] + 'Flattened']
2731 elif first_glyph.endswith('LineTRFlatBottom'):
2732 first_glyph = FLATTENED_ORISCUS[first_glyph[:-16] + 'Flattened']
2733 else:
2734 first_glyph = FLATTENED_ORISCUS[
2735 first_glyph.replace('LineTR','').replace('LineBR','')]
2736 elif first_glyph.endswith('LineTR') or first_glyph.endswith('LineBR'):
2737 first_glyph = first_glyph[:-6]
2738 if first_glyph.startswith('Ascendens') and lique == L_UP:
2739 first_glyph = FLATTENED_ORISCUS[first_glyph + 'FlatTop']
2740 elif first_glyph.startswith('Descendens') and lique == L_DOWN:
2741 first_glyph = FLATTENED_ORISCUS[first_glyph + 'FlatBottom']
2742 else:
2743 first_glyph = first_glyph[:-2]
2744 if first_glyph.startswith('Ascendens') and lique == L_UP:
2745 first_glyph = FLATTENED_ORISCUS[first_glyph + 'FlatTop']
2746 elif first_glyph.startswith('Descendens') and lique == L_DOWN:
2747 first_glyph = FLATTENED_ORISCUS[first_glyph + 'FlatBottom']
2748 elif first_glyph == 'msdeminutus' or first_glyph == 'PunctumLineBLBR':
2749 first_glyph = 'PunctumLineBL'
2750 elif first_glyph == 'mademinutus' or first_glyph == 'PunctumLineTLTR':
2751 first_glyph = 'PunctumLineTL'
2752 elif first_glyph == 'VirgaBaseLineBL':
2753 first_glyph = 'rvirgabase'
2754 length = get_width(first_glyph) + length
2755 if qtype:
2756 draw_left_queue(i, qtype, stemshape, lique)
2757 paste_glyph(first_glyph)
2758 if i != 1:
2759 if lique == L_UP or lique == L_INITIO_DEBILIS_UP:
2760 draw_line(i, length, FONT_CONFIG['base height'])
2761 elif lique == L_DOWN:
2762 draw_line(i, length, -(i - 1) * FONT_CONFIG['base height'])
2763 simplify()
2764 set_width(length)
2765 end_glyph(glyph_name)
2766
2767 def brackets():
2768 for i in range(0, 15):
2769 write_bracket(i, 'Left')
2770 for i in range(0, 15):
2771 write_bracket(i, 'Left', 'Short')
2772 for i in range(0, 15, 2):
2773 write_bracket(i, 'Left', 'Long')
2774 for i in range(0, 15):
2775 write_bracket(i, 'Right')
2776 for i in range(0, 15):
2777 write_bracket(i, 'Right', 'Short')
2778 for i in range(0, 15, 2):
2779 write_bracket(i, 'Right', 'Long')
2780
2781 def write_bracket(i, direction, size = ''):
2782 "Writes a bracket glyph"
2783 new_glyph()
2784 if not cavum:
2785 glyph_name = 'Bracket%s%s%s' % (direction, size, AMBITUS[i])
2786 line = 'Bracket%sLine' % direction
2787 base_height = FONT_CONFIG['base height']
2788 if copy_existing_glyph(glyph_name):
2789 return
2790 paste_glyph('Bracket' + direction + 'Bottom')
2791 for j in range(0, i+1):
2792 paste_glyph(line, 0, j*base_height)
2793 if size == 'Short':
2794 paste_glyph('Bracket' + direction + 'Top', 0,
2795 i*base_height-FONT_CONFIG['bracket shift'])
2796 elif size == 'Long':
2797 paste_glyph('Bracket' + direction + 'Top', 0,
2798 i*base_height+FONT_CONFIG['bracket shift'])
2799 else:
2800 paste_glyph('Bracket' + direction + 'Top', 0, i*base_height)
2801 simplify()
2802 set_width(get_width(line))
2803 end_glyph(glyph_name)
2804
2805 if __name__ == "__main__":
2806 main()