abc2svg
Check-in [38dfd164cb]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:core: fit2box: better results
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | trunk
Files: files | file ages | folders
SHA1: 38dfd164cba812997e6dbbec2a040b45afdc64de
User & Date: jef 2025-05-30 09:16:59.690
Context
2025-05-30
09:16
core: fit2box: better results ... (Leaf check-in: 38dfd164cb user: jef tags: trunk)
2025-05-28
12:41
modules: equalbars: fix: lack of definition of the variable 'f' ... (check-in: 2dcad53240 user: jef tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to core/music.js.
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
	// take care of big key signatures at end of line
	if (s.fmt.keywarn && next
	 && next.type == C.KEY && !last.dur) {
		ws[0] += next.wr
		ws[1] += next.wr
	}

	// check if the symbols can enter in one line
	if (ws[0] + indent < lwidth) {
		if (next)
			next = set_nl(next)
		return next || last
	}

	/* loop on cutting the tune into music lines */
	wwidth = ws[0] + indent







|
|







2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
	// take care of big key signatures at end of line
	if (s.fmt.keywarn && next
	 && next.type == C.KEY && !last.dur) {
		ws[0] += next.wr
		ws[1] += next.wr
	}

	// check if the symbols can enter in one line (with max shrink)
	if (ws[1] + indent < lwidth) {
		if (next)
			next = set_nl(next)
		return next || last
	}

	/* loop on cutting the tune into music lines */
	wwidth = ws[0] + indent
Changes to modules/fit2box.js.
139
140
141
142
143
144
145



146
147
148
149
150
151
152
153
154
155
156
157
158
159
			w = +v[1]		// max width (thanks to trimsvg)
		h += +v[2]			// whole height
	}
//console.log("-- box:"+wb+"x"+hb+" w:"+w.toFixed(2)+" marg:"+marg.toFixed(2)
//+" h:"+h.toFixed(2)+" hh:"+hh.toFixed(2))

	sc = (hb - hh) / h			// height scale



	v = (wb - marg * 2) / w			// width scale
//console.log("     scw:"+v.toFixed(3)+" sch:"+sc.toFixed(3))

	if (v <= sc) {
		sc = v					// width constraint
	} else {					// height constraint
		v = Math.round((wb - w * v) / 2)	// margins
		if (v < marg)
			marg = v
	}

	setparm("pagewidth", wb)
	setparm("leftmargin", marg.toFixed(0))	// restore the margins
	setparm("rightmargin", marg.toFixed(0))







>
>
>






|







139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
			w = +v[1]		// max width (thanks to trimsvg)
		h += +v[2]			// whole height
	}
//console.log("-- box:"+wb+"x"+hb+" w:"+w.toFixed(2)+" marg:"+marg.toFixed(2)
//+" h:"+h.toFixed(2)+" hh:"+hh.toFixed(2))

	sc = (hb - hh) / h			// height scale

//fixme: magic value!
	w += 24
	v = (wb - marg * 2) / w			// width scale
//console.log("     scw:"+v.toFixed(3)+" sch:"+sc.toFixed(3))

	if (v <= sc) {
		sc = v					// width constraint
	} else {					// height constraint
		v = Math.round((wb - w * sc) / 2)	// margins
		if (v < marg)
			marg = v
	}

	setparm("pagewidth", wb)
	setparm("leftmargin", marg.toFixed(0))	// restore the margins
	setparm("rightmargin", marg.toFixed(0))