-
Notifications
You must be signed in to change notification settings - Fork 138
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
Multiple text Line Support #22
Comments
This may also mean that there would need to be a line-height parameter. |
Yes exactly. They used opentype-layout Below is the code i used App.prototype.wrapText = function(font, text, fontSize, width, align, lineHeight) {
//sample from https://github.com/Jam3/opentype-layout
var scale = 1 / font.unitsPerEm * fontSize;
var layoutOptions = {
align,
lineHeight: lineHeight * font.unitsPerEm,
width: width / scale
};
var layout = computeLayout(font, text, layoutOptions);
layout.glyphs.forEach((glyph, i) => {
var character = makerjs.models.Text.glyphToModel(glyph.data, fontSize);
character.origin = makerjs.point.scale(glyph.position, scale);
makerjs.model.addModel(this, character, i);
});
//for seperate paths
for (var i in this.models) {
this.models[i].layer = i;
}
var svg = makerjs.exporter.toSVG(this);
this.renderDiv.innerHTML = svg;
this.outputTextarea.value = svg;
}; |
Oh, right, there also is a width parameter. But I wonder if it would be easier to have a mutli-line textbox as input, then use line breaks for newlines? |
Width will be main input needed for opentype-layout, if we are providing line break then we need to calculate the width of the text entered (width of longer line in the multi-line) and send that width as input to opentype-layout. |
Would also love this feature FWIW. Thanks. |
Hi, Are there any updates on this? |
Is there is any option or way to generate svg path for multiple text lines?
Please suggest.
The text was updated successfully, but these errors were encountered: