Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SamsaGlyph.prototype.svg has hardcoded width and height #74

Open
wentin opened this issue Feb 10, 2022 · 3 comments
Open

SamsaGlyph.prototype.svg has hardcoded width and height #74

wentin opened this issue Feb 10, 2022 · 3 comments

Comments

@wentin
Copy link
Contributor

wentin commented Feb 10, 2022

Some fonts are not based on 1000 units, it would be better if the width and height of the SVG can be set dynamically, based on the font data, such as unitsPerEm
Right now it is being hardcoded as width="1000" height="1000"

SamsaGlyph.prototype.svg = function (style={}) {
	...
	return `<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="1000" height="1000">
	<g${style.transform ? ` transform="${style.transform}"` : ""}>
		<path d="${this.svgPath()}"${extra}></path>
	</g>
</svg>`;
}
@wentin
Copy link
Contributor Author

wentin commented Feb 10, 2022

#75
I submitted a Pull Request to solve this issue.
Please note: I think it would be better to set the svg width based on this glyph's actual canvas width, but don't know what is the best way to access it. I settled for unitsPerEm for now.

@wentin
Copy link
Contributor Author

wentin commented Feb 10, 2022

alternative pull request #76
use viewBox instead of width and height, this will make the SVG responsive

@Lorp
Copy link
Owner

Lorp commented Feb 10, 2022

Thanks for this! I’ve been meaning to improve the SVG sizing for a while. I’ll take a look soon and almost certainly accept your PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants