microsoft / microsoft/maker.js
time to compute combineUnion
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 302
- Avg merge
- 21h 28m
- Merged PRs (30d)
- 5
Description
we are building a too for a Vinyl printing shop and we need to optmize a lot of text in a model.
few of our font have complicated geometry like below , and the text overlap, we are using "combineUnionfor" for every letter in the text , but its taking too long to get an output ,

so the Question is does combineUnion take this long to compute the path (very long about 20-30 seconds for the below code which can be tested in playgraound )
here is my code
var makerjs = require('makerjs');
var computeLayout = require('opentype-layout');
function DraftText(font, text, fontSize) `{`
var textModel = { models: {} };
var scale = 1 / font.unitsPerEm * fontSize;
var layoutOptions = {
lineHeight: 1 * font.unitsPerEm,
width: 500 / 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.simplify(character, { pointMatchingDistance: 0.001 });
makerjs.model.combineUnion(textModel, character);
makerjs.model.addModel(textModel, character, i);
});
return textModel;
}
function Nameplate(font,font_scale, text,icon ) {
var textModel = DraftText(font, text, font_scale);
this.models = {
text: textModel
};
makerjs.model.zero(this);
this.units = makerjs.unitType.Millimeter;
}
Nameplate.metaParameters = [
{ title: "font", type: "font", value: '*' },
{ title: "font size", type: "range", min: 10, max: 200, value: 20},
{ title: "text", type: "text", value: 'Hello World! This box should start word-wrapping!' }
];
module.exports = Nameplate;
am i doing something wrong?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the provided JavaScript example in the linked Maker.js playground, focusing on model.combineUnion and Text.glyphToModel for the supplied font and text. Profile the combineUnion calls to determine where the 20–30 second runtime comes from; done means a documented explanation of the behavior or a confirmed, measurable improvement.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- computer-graphics, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100