candygraph icon indicating copy to clipboard operation
candygraph copied to clipboard

Loading two fonts causes corruption

Open thetooth opened this issue 1 year ago • 0 comments

When using two fonts on a single plot only the first loaded texture appears to be getting bound.

	async function loadFont(name: string): Promise<Font> {
		try {
			const img = new Image()
			img.src = URL.createObjectURL(await fetch(`./${name}.png`).then((res) => res.blob()))
			const config = await fetch(`./${name}.json`).then((res) => res.json())

			return new Font(cg, img, config)
		} catch (e) {
			console.log('Failed to load custom font, loading default font')
			return createDefaultFont(cg)
		}
	}

I'm using the above and passing the created Font objects to Text instances, you can see below that the glyph information from the second font is being applied to the first font's texture. I had a look through the font and text implementation but can't find anything obvious. download (10)

thetooth avatar Jan 19 '24 12:01 thetooth