Skip to content

Commit

Permalink
In-progress unrevert of "Implementation of fused torculus resupinus f…
Browse files Browse the repository at this point in the history
…lexus." into microoptfonts.
  • Loading branch information
henryso committed May 7, 2015
1 parent 32377d0 commit 470b45a
Show file tree
Hide file tree
Showing 8 changed files with 460 additions and 286 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ As of v3.0.0 this project adheres to [Semantic Versioning](http://semver.org/).
### Fixed
- Handling of the first syllable in gabc is now more consistent with the all other syllables. This centers the syllable correctly when using latin syllable centering (see [#42](https://github.com/gregorio-project/gregorio/issues/42)) and makes the use of styles less surprising in the first syllable (see [#135](https://github.com/gregorio-project/gregorio/issues/135)).
- Handling of manually-placed custos is improved. In particular, a manual custos at the end of the score should no longer be lost when the bar happens to be at the end of the line.
- Improved rendering of torculus resupinus flexus figures (see [#18](https://github.com/gregorio-project/gregorio/issues/18)).

### Changed
- The spacing algorithm has completely changed, expect your scores to look quite different (better we hope).
Expand Down
4 changes: 4 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ EXTRA_DIST = README.md CHANGELOG.md CONTRIBUTING.md CONTRIBUTORS.md \
UPGRADE.md COPYING.md .gregorio-version VersionManager.py \
build.sh install.sh install-gtex.sh

fonts: make-fonts
make-fonts:
make -C fonts fonts

export TOP_LEVEL_MAKE = true
133 changes: 81 additions & 52 deletions fonts/squarize.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ def main():
porrectus(font_width)
porrectusflexus(font_width)
torculusresupinus(font_width)
leading(font_width)
# variants must be copied last!
copy_variant_glyphs()
newfont.generate(outfile)
Expand Down Expand Up @@ -275,15 +276,25 @@ def precise_message(glyph_name):
'PunctumAuctusLineBL',
]

def glyph_exists(glyphName, font):
def glyph_exists(glyph_name, font):
"returns if glyph named glyphName exists in font (boolean)"
result = True
try:
font.selection.select(glyphName)
font.selection.select(glyph_name)
except:
result = False
return result

def copy_existing_glyph(glyph_name):
"copies the named glyph, if it exists, and returns whether it was copied"
global oldfont
if glyph_exists(glyph_name, oldfont):
complete_paste(glyph_name)
set_glyph_name(glyph_name)
return True
else:
return False

# This will be populated by initialize_glyphs
COMMON_DIRECT_VARIANTS = {}

Expand Down Expand Up @@ -359,6 +370,11 @@ def get_width(widths, glyphName):
S_TORCULUS_LIQUESCENS_QUILISMA = 'TorculusLiquescensQuilisma'
S_FLEXUS_ORISCUS_SCAPUS = 'FlexusOriscusScapus'
S_FLEXUS_ORISCUS_SCAPUS_LONGQUEUE = 'FlexusOriscusScapusLongqueue'
S_LEADING_ZERO_SPACER = 'LeadingZeroSpacer'
S_LEADING_LINE_SPACER = 'LeadingLineSpacer'
S_LEADING_PUNCTUM = 'LeadingPunctum'
S_LEADING_QUILISMA = 'LeadingQuilisma'
S_LEADING_ORISCUS = 'LeadingOriscus'

# Liquescentiae
L_NOTHING = 'Nothing'
Expand Down Expand Up @@ -534,9 +550,7 @@ def write_pes(widths, i, first_glyph, shape, lique=L_NOTHING):
global oldfont
new_glyph()
glyph_name = '%s%s%s' % (shape, AMBITUS[i], lique)
if glyph_exists(glyph_name, oldfont):
complete_paste(glyph_name)
set_glyph_name(glyph_name)
if copy_existing_glyph(glyph_name):
return
get_width(widths, 'QuilismaLineTR')
temp_width = 0
Expand All @@ -563,8 +577,7 @@ def write_pes_debilis(widths, i, shape, lique=L_NOTHING):
"Writes the pes debilis glyphs."
new_glyph()
glyph_name = '%s%s%s' % (shape, AMBITUS[i], lique)
if glyph_exists(glyph_name, oldfont):
complete_paste(glyph_name)
if copy_existing_glyph(glyph_name):
return
# with a deminutus it is much more beautiful than with a idebilis
paste_and_move("deminutus", 0, 0)
Expand All @@ -578,9 +591,7 @@ def write_pes_deminutus(widths, i, first_glyph, shape, lique=L_NOTHING):
"Writes the pes deminutus glyphs."
new_glyph()
glyph_name = '%s%s%s' % (shape, AMBITUS[i], lique)
if glyph_exists(glyph_name, oldfont):
complete_paste(glyph_name)
set_glyph_name(glyph_name)
if copy_existing_glyph(glyph_name):
return
simple_paste(first_glyph)
temp_width = get_width(widths, first_glyph)-get_width(widths, 'line2')
Expand All @@ -595,9 +606,7 @@ def write_pes_debilis_deminutus(widths, i, shape, lique=L_NOTHING):
"Writes the pes debilis deminutus glyphs."
new_glyph()
glyph_name = '%s%s%s' % (shape, AMBITUS[i], lique)
if glyph_exists(glyph_name, oldfont):
complete_paste(glyph_name)
set_glyph_name(glyph_name)
if copy_existing_glyph(glyph_name):
return
simple_paste("deminutus")
write_line(i, get_width(widths, 'deminutus')-get_width(widths, 'line2'), BASE_HEIGHT)
Expand Down Expand Up @@ -665,9 +674,7 @@ def write_pes_quadratum(widths, i, first_glyph, last_glyph, shape, lique=L_NOTHI
"Writes the pes quadratum glyphs."
new_glyph()
glyph_name = '%s%s%s' % (shape, AMBITUS[i], lique)
if glyph_exists(glyph_name, oldfont):
complete_paste(glyph_name)
set_glyph_name(glyph_name)
if copy_existing_glyph(glyph_name):
return
if first_glyph == "idebilis":
first_width = get_width(widths, 'idebilis')-get_width(widths, 'line2')
Expand Down Expand Up @@ -707,9 +714,7 @@ def write_virga_strata(widths, i, first_glyph, last_glyph, shape, lique=L_NOTHIN
"Writes the virga strata glyphs."
new_glyph()
glyph_name = '%s%s%s' % (shape, AMBITUS[i], lique)
if glyph_exists(glyph_name, oldfont):
complete_paste(glyph_name)
set_glyph_name(glyph_name)
if copy_existing_glyph(glyph_name):
return
if i == 1:
first_glyph = 'Punctum'
Expand Down Expand Up @@ -739,9 +744,7 @@ def write_salicus(widths, i, j, last_glyph, shape, lique=L_NOTHING):
"Writes the salicus glyphs."
new_glyph()
glyph_name = '%s%s%s%s' % (shape, AMBITUS[i], AMBITUS[j], lique)
if glyph_exists(glyph_name, oldfont):
complete_paste(glyph_name)
set_glyph_name(glyph_name)
if copy_existing_glyph(glyph_name):
return
if j == 1:
if last_glyph == 'rvsbase':
Expand Down Expand Up @@ -872,9 +875,7 @@ def write_flexus(widths, i, first_glyph, last_glyph, shape, lique=L_NOTHING):
"Writes the flexus glyphs."
new_glyph()
glyph_name = '%s%s%s' % (shape, AMBITUS[i], lique)
if glyph_exists(glyph_name, oldfont):
complete_paste(glyph_name)
set_glyph_name(glyph_name)
if copy_existing_glyph(glyph_name):
return
# we add a queue if it is a deminutus
if first_glyph == "mdeminutus":
Expand Down Expand Up @@ -970,9 +971,7 @@ def write_porrectus(widths, i, j, last_glyph, with_bar, shape, lique=L_NOTHING):
global oldfont
new_glyph()
glyph_name = '%s%s%s%s' % (shape, AMBITUS[i], AMBITUS[j], lique)
if glyph_exists(glyph_name, oldfont):
complete_paste(glyph_name)
set_glyph_name(glyph_name)
if copy_existing_glyph(glyph_name):
return
first_glyph = "porrectus%d" % i
if j == 1 and glyph_exists("porrectusam1%d" % i, oldfont):
Expand Down Expand Up @@ -1008,9 +1007,7 @@ def write_alt_porrectus_deminutus(widths, i, j):
"Writes the alternate porrectur deminutus glyphs."
new_glyph()
glyph_name = 'Porrectus%s%sDeminutus.alt' % (AMBITUS[i], AMBITUS[j])
if glyph_exists(glyph_name, oldfont):
complete_paste(glyph_name)
set_glyph_name(glyph_name)
if copy_existing_glyph(glyph_name):
return
write_first_bar(i)
if i == 1:
Expand Down Expand Up @@ -1099,9 +1096,7 @@ def write_porrectusflexus(widths, i, j, k, last_glyph, with_bar,
global oldfont
new_glyph()
glyph_name = '%s%s%s%s%s' % (shape, AMBITUS[i], AMBITUS[j], AMBITUS[k], lique)
if glyph_exists(glyph_name, oldfont):
complete_paste(glyph_name)
set_glyph_name(glyph_name)
if copy_existing_glyph(glyph_name):
return
if j == 1:
first_glyph = "porrectusflexusnb%d" % i
Expand Down Expand Up @@ -1210,9 +1205,7 @@ def write_torculus(widths, i, j, first_glyph, last_glyph, shape, lique=L_NOTHING
"Writes the torculus glyphs."
new_glyph()
glyph_name = '%s%s%s%s' % (shape, AMBITUS[i], AMBITUS[j], lique)
if glyph_exists(glyph_name, oldfont):
complete_paste(glyph_name)
set_glyph_name(glyph_name)
if copy_existing_glyph(glyph_name):
return
length = get_width(widths, first_glyph)-get_width(widths, 'line2')
if first_glyph == "QuilismaLineTR":
Expand Down Expand Up @@ -1278,9 +1271,7 @@ def write_torculus_liquescens(widths, i, j, k, first_glyph, shape,
"Writes the torculus liquescens glyphs."
new_glyph()
glyph_name = '%s%s%s%s%s' % (shape, AMBITUS[i], AMBITUS[j], AMBITUS[k], lique)
if glyph_exists(glyph_name, oldfont):
complete_paste(glyph_name)
set_glyph_name(glyph_name)
if copy_existing_glyph(glyph_name):
return
length = get_width(widths, first_glyph)-get_width(widths, 'line2')
if first_glyph == "QuilismaLineTR":
Expand Down Expand Up @@ -1415,9 +1406,7 @@ def write_torculusresupinus(widths, i, j, k, first_glyph, last_glyph, shape,
global oldfont
new_glyph()
glyph_name = '%s%s%s%s%s' % (shape, AMBITUS[i], AMBITUS[j], AMBITUS[k], lique)
if glyph_exists(glyph_name, oldfont):
complete_paste(glyph_name)
set_glyph_name(glyph_name)
if copy_existing_glyph(glyph_name):
return
middle_glyph = "porrectus%d" % j
if k == 1 and glyph_exists("porrectusam1%d" % j, oldfont):
Expand Down Expand Up @@ -1461,9 +1450,7 @@ def write_alt_torculusresupinusdeminutus(widths, i, j, k, first_glyph,
"Writes the torculusresupinusdeminutus glyphs."
new_glyph()
glyph_name = '%s%s%s%s%s.alt' % (shape, AMBITUS[i], AMBITUS[j], AMBITUS[k], lique)
if glyph_exists(glyph_name, oldfont):
complete_paste(glyph_name)
set_glyph_name(glyph_name)
if copy_existing_glyph(glyph_name):
return
length = get_width(widths, first_glyph)-get_width(widths, 'line2')
if i == 1:
Expand Down Expand Up @@ -1526,9 +1513,7 @@ def write_scandicus(widths, i, j, last_glyph, lique=L_NOTHING):
new_glyph()
final_vertical_shift = 0
glyph_name = '%s%s%s%s' % (S_SCANDICUS, AMBITUS[i], AMBITUS[j], lique)
if glyph_exists(glyph_name, oldfont):
complete_paste(glyph_name)
set_glyph_name(glyph_name)
if copy_existing_glyph(glyph_name):
return
# special case of i=j=1, we use glyph 1025 directly
if i == 1 and j == 1 and lique == L_NOTHING:
Expand Down Expand Up @@ -1585,9 +1570,7 @@ def write_ancus(widths, i, j, first_glyph, glyph_type):
"Writes the ancus glyphs."
new_glyph()
glyph_name = '%s%s%s%s' % (glyph_type, AMBITUS[i], AMBITUS[j], L_DEMINUTUS)
if glyph_exists(glyph_name, oldfont):
complete_paste(glyph_name)
set_glyph_name(glyph_name)
if copy_existing_glyph(glyph_name):
return
if i == 1:
second_glyph = 'mnbdeminutus'
Expand All @@ -1611,5 +1594,51 @@ def write_ancus(widths, i, j, first_glyph, glyph_type):
set_width(length)
end_glyph(glyph_name)

def leading(widths):
"Creates the leading fusion glyphs."
message("leading fusion glyphs")
for i in range(1, MAX_INTERVAL+1):
write_leading(widths, i, 'PunctumLineTR', S_LEADING_PUNCTUM)
for i in range(1, MAX_INTERVAL+1):
write_leading(widths, i, 'idebilis', S_LEADING_PUNCTUM, L_INITIO_DEBILIS)
for i in range(1, MAX_INTERVAL+1):
write_leading(widths, i, 'qbase', S_LEADING_QUILISMA)
for i in range(1, MAX_INTERVAL+1):
write_leading(widths, i, 'obase', S_LEADING_ORISCUS)

def write_leading_spacer(widths, glyph_name, width):
"Writes the leading fusion spacer glyph."
new_glyph()
if copy_existing_glyph(glyph_name):
return
length = 0
write_line(2, length, 0)
set_width(width)
end_glyph(glyph_name)

# lique has a slightly different meaning here
def write_leading(widths, i, first_glyph, glyph_type, lique=''):
"Writes the leading fusion glyphs."
new_glyph()
glyph_name = '%s%s%s' % (glyph_type, AMBITUS[i], lique)
if copy_existing_glyph(glyph_name):
return
length = -get_width(widths, 'line2')
if i == 1 and first_glyph != 'idebilis':
length = 0.1
if first_glyph == 'PunctumLineTR':
first_glyph = 'Punctum'
elif first_glyph == 'qbase':
first_glyph = 'Quilisma'
elif first_glyph == 'obase':
first_glyph = 'Oriscus'
length = get_width(widths,first_glyph) + length
paste_and_move(first_glyph, 0, -i * BASE_HEIGHT)
if i != 1:
write_line(i, length, -(i-1) * BASE_HEIGHT)
simplify()
set_width(length)
end_glyph(glyph_name)

if __name__ == "__main__":
main()
Loading

0 comments on commit 470b45a

Please sign in to comment.