textblock
Hi, i create a textblock by this method,and it successfully created, but nothing appears in the viewport. Do you know what might be the reason?
Hi! Try putting the fontname in the style overrides in the individual runs.
We're currently working on reworking the style overrides, but right now there's a bug where you have to include them on each layer.
const styleOverrides = { fontName: fonts[0].name };
const textblock = TextBlock.create({ styleName: "", styleOverrides });
textblock.appendRun(TextRun.create({ content: "Test annotation", styleName: "", styleOverrides }));
textblock.appendRun(FractionRun.create({ numerator: "1", denominator: "2", styleName: "fraction", styleOverrides }));
After these changes are you able to see text?
(I'll link to the issue when I can find it, we might not have made one yet)
See Issue Issue 8178 in itwinjs-core
Hi! Try putting the fontname in the style overrides in the individual runs.
We're currently working on reworking the style overrides, but right now there's a bug where you have to include them on each layer.
const styleOverrides = { fontName: fonts[0].name }; const textblock = TextBlock.create({ styleName: "", styleOverrides }); textblock.appendRun(TextRun.create({ content: "Test annotation", styleName: "", styleOverrides })); textblock.appendRun(FractionRun.create({ numerator: "1", denominator: "2", styleName: "fraction", styleOverrides })); After these changes are you able to see text?
Yes, I can see the text this way. Thank you very much! By the way, I noticed that the text part has already been updated. Could you let me know which version includes the new API? I am using version 5.0.0 now.
I don't think there are any public releases yet, but the recent text changes should be available when version 5.1.x is released.
(The most recent release is 5.0.2.)
If you want to follow along with our recent progress when it comes to TextAnnotations here are a few issues to pay attention to:
- https://github.com/iTwin/itwinjs-core/issues/6746
- https://github.com/iTwin/itwinjs-core/issues/7675
- https://github.com/iTwin/itwinjs-core/issues/7676
- https://github.com/iTwin/itwinjs-core/issues/7677
- https://github.com/iTwin/itwinjs-core/issues/7678
- https://github.com/iTwin/itwinjs-core/issues/7679
- https://github.com/iTwin/itwinjs-core/issues/7680
- https://github.com/iTwin/itwinjs-core/issues/7681
- https://github.com/iTwin/itwinjs-core/issues/7718
- https://github.com/iTwin/itwinjs-core/issues/7830
- https://github.com/iTwin/itwinjs-core/issues/8178
(We file any text related issues under the drawing tag, so any new ones would be added here: itwinjs-core/issues > drawing tag)
Thank you !