Increasing Font size in DynamicTexture in Babylon React-Native Application

Hello,

Adding a text using DynamicTexture like this:

const dynamicTexture = new DynamicTexture("text", {width:128, height:256}, this.scene),
const context = dynamicTexture.getContext();
context.font = "bold 40px Bebas Neue";
context.fillStyle = "white";
context.textAlign = "center";
context.textBaseline = "middle";
context.fillText(text, 10, 10);
dynamicTexture.update(true);

const spriteManager = new SpriteManager("text-sprites", null, 1, {width: n, height: n}, this.scene);
spriteManager.texture = dynamicTexture;
const sprite = new Sprite("text", spriteManager);
sprite.width = .7;
sprite.height = 1.5;
sprite.position = new Vector3(0,0,0);

Text is showing , but not able to Increase the font size. also, I’m already Tried with dynamicTexture.drawText(***);

Is this is a bug or I miss something else?

Thanks

cc @BabylonNative

Have you tried to replace
context.font = "bold 40px Bebas Neue";

with

context.font = "bold 80px Bebas Neue"; for example?

Yes I have tried that.

by font size, do you mean the size of the text on screen?

Yes. But need to keep expected resolution.

if you want bigger glyph on screen with same texel density then you’ll have to load the font with bigger font ( context.font = “bold 80px Bebas Neue”; for example ) and change the sprite size ( sprite.width = .7 * 2; )

1 Like