itwinjs-core icon indicating copy to clipboard operation
itwinjs-core copied to clipboard

textblock

Open edemiaochu opened this issue 7 months ago • 3 comments

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?

Image

edemiaochu avatar May 29 '25 08:05 edemiaochu

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?

claudiaareneee avatar May 30 '25 14:05 claudiaareneee

(I'll link to the issue when I can find it, we might not have made one yet)

claudiaareneee avatar May 30 '25 14:05 claudiaareneee

See Issue Issue 8178 in itwinjs-core

claudiaareneee avatar Jun 04 '25 20:06 claudiaareneee

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.

edemiaochu avatar Jul 04 '25 01:07 edemiaochu

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)

claudiaareneee avatar Jul 09 '25 14:07 claudiaareneee

Thank you !

edemiaochu avatar Jul 10 '25 08:07 edemiaochu