abc2svg
Check-in [c1fdec018d]
Not logged in

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

Overview
Comment:core: set more precision of the SVG heights to avoid page overflow with %%fit2box Reported by Laurent Yin.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c1fdec018d3e17b9cf4c30dacc7502bc3a03435e
User & Date: jef 2025-05-25 11:20:12.111
Context
2025-05-25
13:29
batch: tosvg: crash since previous commit ... (check-in: ff4e617199 user: jef tags: trunk)
11:20
core: set more precision of the SVG heights to avoid page overflow with %%fit2box ... (check-in: c1fdec018d user: jef tags: trunk)
2025-05-24
17:17
modules: fit2box: fix: keep the exact page scale to avoid page overflow ... (check-in: c0db0e2b00 user: jef tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to core/svg.js.
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
		' tune' + tunes.length + '"\n'	// tune index for play

	posy *= cfmt.scale
	if (user.imagesize != undefined)
		head += user.imagesize
	else
		head += ' width="' + w
			+ 'px" height="' + posy.toFixed(0) + 'px"'
	head += ' viewBox="0 0 ' + w + ' '
		+ posy.toFixed(0) + '">\n'
	head += fulldefs
	if (cfmt.bgcolor)
		head += '<rect width="100%" height="100%" fill="'
			+ cfmt.bgcolor + '"/>\n'

	if (style || font_style)
		head += '<style>' + font_style + style + '\n</style>\n'







|

|







1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
		' tune' + tunes.length + '"\n'	// tune index for play

	posy *= cfmt.scale
	if (user.imagesize != undefined)
		head += user.imagesize
	else
		head += ' width="' + w
			+ 'px" height="' + posy.toFixed(2) + 'px"'
	head += ' viewBox="0 0 ' + w + ' '
		+ posy.toFixed(2) + '">\n'
	head += fulldefs
	if (cfmt.bgcolor)
		head += '<rect width="100%" height="100%" fill="'
			+ cfmt.bgcolor + '"/>\n'

	if (style || font_style)
		head += '<style>' + font_style + style + '\n</style>\n'
Changes to modules/fit2box.js.
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
		user.img_out = io		// restore the normal output
		return				// no SVG
	}
	while (1) {
		sv = r.shift()			// next music line
		if (!sv)
			break
		v = sv.match(/viewBox="0 0 (\d+) (\d+)"/)
		cl = sv.match(/class="([^"]+)"/) // "
//console.log("- sv  ====\n"+sv+"\n      ====\n  cl:"+cl)
		if (!tit			// the first SVG is the tune header
		 || cl[1] == "header"
		 || cl[1] == "footer") {
			hh += +v[2]
			if (cl[1] != "header"







|







119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
		user.img_out = io		// restore the normal output
		return				// no SVG
	}
	while (1) {
		sv = r.shift()			// next music line
		if (!sv)
			break
		v = sv.match(/viewBox="0 0 ([\d.]+) ([\d.]+)"/)
		cl = sv.match(/class="([^"]+)"/) // "
//console.log("- sv  ====\n"+sv+"\n      ====\n  cl:"+cl)
		if (!tit			// the first SVG is the tune header
		 || cl[1] == "header"
		 || cl[1] == "footer") {
			hh += +v[2]
			if (cl[1] != "header"
Changes to modules/page.js.
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
				abc2svg.page.close_page(page)
			abc2svg.page.open_page(page, 0)
		}
		page.blk = []			// in block
		page.hb = page.h		// keep the offset of the start of tune
		break
	case "<svg":				// SVG image
		h = Number(p.match(/viewBox="0 0 \d+ (\d+)"/)[1])
		while (h + page.h >= page.hmax) { // if (still) page overflow
			ht = page.blk ? 0 :
				this.cfmt().topspace // tune continuation

			if (page.blk) {
				if (!page.hb) {	// overflow on the first page
					blkcpy(page)







|







353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
				abc2svg.page.close_page(page)
			abc2svg.page.open_page(page, 0)
		}
		page.blk = []			// in block
		page.hb = page.h		// keep the offset of the start of tune
		break
	case "<svg":				// SVG image
		h = Number(p.match(/viewBox="0 0 [\d.]+ ([\d.]+)"/)[1])
		while (h + page.h >= page.hmax) { // if (still) page overflow
			ht = page.blk ? 0 :
				this.cfmt().topspace // tune continuation

			if (page.blk) {
				if (!page.hb) {	// overflow on the first page
					blkcpy(page)