Generation
This commit is contained in:
@@ -24,6 +24,10 @@ def audit_layout(document: dict, layout: generator.engraving.types.LayoutDocumen
|
||||
fragments, primitives = {}, {}
|
||||
previous_end = fractions.Fraction()
|
||||
for page in layout.pages:
|
||||
if len(page.systems) != 2 and (page is not layout.pages[-1] or len(page.systems) != 1):
|
||||
raise generator.engraving.types.EngravingError('pages must contain two music systems, except an odd final system')
|
||||
if len(page.systems) == 2 and page.systems[0].box.bottom + layout.style.system_gap > page.systems[1].box.top + 0.01:
|
||||
raise generator.engraving.types.EngravingError('music systems overlap their page rows')
|
||||
audit_primitives(page.primitives, page.width, page.height, fonts)
|
||||
for item in page.primitives:
|
||||
for source in item.sources:
|
||||
@@ -36,7 +40,7 @@ def audit_layout(document: dict, layout: generator.engraving.types.LayoutDocumen
|
||||
for anchor in system.anchors:
|
||||
if anchor.fragment.kind == 'tone':
|
||||
expected = index.pitch_position(index.tones[anchor.source][1], anchor.time)
|
||||
if abs(anchor.y - (baseline - expected * layout.style.space / 2)) > 0.01:
|
||||
if abs(anchor.y - (baseline - expected * layout.style.space * system.scale / 2)) > 0.01:
|
||||
raise generator.engraving.types.EngravingError(f'{anchor.source}: displayed staff position changed pitch')
|
||||
role = 'head' if anchor.fragment.kind == 'tone' else anchor.fragment.kind
|
||||
candidates = [p for p in system.primitives if p.role == role and anchor.source in p.sources and abs(p.points[0][0] - anchor.x) < 0.01]
|
||||
@@ -51,7 +55,7 @@ def audit_layout(document: dict, layout: generator.engraving.types.LayoutDocumen
|
||||
tone = index.tones[anchor.source][1]
|
||||
tab = tone['tablature']
|
||||
tab_baseline = max(p.points[0][1] for p in system.primitives if p.role == 'tab-staff')
|
||||
expected_y = tab_baseline - (6 - tab['string']) * layout.style.space + 5
|
||||
expected_y = tab_baseline + (4 - (6 - tab['string']) * layout.style.tab_space) * system.scale
|
||||
expected_x = min(a.x for a in system.anchors if a.event == anchor.event and a.time == anchor.time)
|
||||
tabs = [p for p in system.primitives if p.role == 'tab' and anchor.source in p.sources]
|
||||
if len(tabs) != 1 or tabs[0].value != str(tab['fret']) or abs(tabs[0].points[0][1] - expected_y) > 0.01 or abs(tabs[0].points[0][0] - expected_x) > 0.01:
|
||||
@@ -67,7 +71,7 @@ def audit_layout(document: dict, layout: generator.engraving.types.LayoutDocumen
|
||||
continue
|
||||
if item.role != other.role and {item.role, other.role} - {'head', 'tab', 'accidental'}:
|
||||
continue
|
||||
if item.box.overlaps(other.box, 0.1):
|
||||
if item.box.overlaps(other.box, 0.1 * system.scale):
|
||||
raise generator.engraving.types.EngravingError(f'{item.sources} and {other.sources}: colliding {item.role}/{other.role}')
|
||||
if previous_end != index.end:
|
||||
raise generator.engraving.types.EngravingError('layout omits the end of the score')
|
||||
|
||||
Reference in New Issue
Block a user