CreativeCore

CreativeCore

88M Downloads

Scalable Text using labels

SrRapero720 opened this issue ยท 11 comments

commented

scalling is possible using PoseStack#scale(0.75F, 0.75F, 0.75F)
whoever, this carries one issue, widgets dimensions is still keeped, so no the dimensions applied are still the same (wasting space)

this works on decorative/label texts just to enhance readability
this propotype shows the capability of scaling
image
image
image

commented

this can be applied on any kind of text, again it needs some precision and control over the position and the scaled dimensions

image
image

commented

Is this something I should add? Do you want to scale all text by 0.75 by default? Or do you mean it should be an option. It is actually quite easy to make it work with the dimensions as well.

commented

i mean it should be an option (method)
last time we talk about you said needs a better way to implement something like that (because 1.20.1 rewrites how font rendering works)

commented

What you can do is the scale the parent. That always works and will respect the dimensions as well. The question is do you want a scale config for labels for example?

commented

I tried scaling parents but seems like is not working? I didn't dig much in scaling parents.

And yes, a scale config for labels is a good addition.

commented

Create a parent, add the controls you want to scale. Do parent.setScale(0.75); and that's it.

commented

Released a new version which does fixes a few things about scaling and adds it to label and compiled text. Hope that works for you.

commented

scaling for some reason get texts cropped into a new line,
i assume is caused by the missing ceiling method

return (int) (calculateWidth(0, true, original) * scale);

image

GuiParents scaling on the other hands works perfectly fine

image

But clarifying, scaling is more like a feature for all widgets using text. In Labels, what you want (normally) is scale the text and also get a responsive width and height based on the scaled text size

Buttons on the other hand extends Label, but what i want when i scale GuiButtons i want to get scaled only the text and no the GuiButton dimensions.
To make this more clear, if i set a dimension of... lets say... 30 and i scale the Button 0.5f, it will also scale the dimensions, making that 30 into a 15

commented

If you use GuiLabel.setScale(scale) it will not effect the dimensions of the button if it has fixed ones. Will also release a fix for the missing ceil.

commented

about that, can be also implemented on GuiSliders and GuiTextFields?

commented

about that, can be also implemented on GuiSliders and GuiTextFields?

Actually that is a little bit more complicated. I think in that case it is better to wrap it inside a parent and scale that one.