Jump to content

Recommended Posts

Posted

Hey there. For my custom gui/screen, I'm wanting to print a String to the screen. I'm doing that like so:

AbstractGui.drawString(matrixStack, Minecraft.getInstance().font, "Test String", x, y, this.color);

It's working, but the text is incredibly small (this probably has to do with the game settings option for gui scale. Is there any way I can actually increase the font size or even just 'scale' the string? I've tried both the following right before making the AbstractGui#drawString call and neither worked:

matrixStack.scale(2.f, 2.f, 2.f);

GL13.glScalef(2.f, 2.f, 2.f);

Any help would be appreciated! Thanks!

Posted (edited)

Sure thing. So in my custom screen class, here's all the logic related to printing to the screen:

//Ensure screen always takes up the same amount of 'screen space' regardless of gui scale setting
final float scale = 1.f / guiScale;
pMatrixStack.scale(scale, scale, scale);

//Create screen texture
AbstractGui.blit(pMatrixStack, pos.x(), pos.y(), 0, start.x(), start.y(), dimensions.x(), dimensions.y(), textureSize.y(), textureSize.x());

//Then call the string render
render(pMatrixStack, x, y);

Here's the string render method:

public void render(final MatrixStack matrixStack, final int x, final int y) {
        matrixStack.scale(2.f, 2.f, 2.f);
        AbstractGui.drawString(matrixStack, Minecraft.getInstance().font, "Test String", x, y, this.color);
}

All of this technically works, except for the string size being scaled at the end. My best guess is that perhaps I need to push or pop or flush or do something to the MatrixStack after the AbstractGui#blit call (of which I'll test right now --- unfortunately push and pop didn't solve the problem).

Edited by Jimmeh
Edit

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.