diff --git a/src/main/kotlin/gg/essential/elementa/constraints/Constraint.kt b/src/main/kotlin/gg/essential/elementa/constraints/Constraint.kt index fd263565..b7703609 100644 --- a/src/main/kotlin/gg/essential/elementa/constraints/Constraint.kt +++ b/src/main/kotlin/gg/essential/elementa/constraints/Constraint.kt @@ -109,7 +109,15 @@ interface HeightConstraint : SuperConstraint { getCachedDebuggable(component, ConstraintType.HEIGHT) { getHeightImpl(it).roundToRealPixels() } fun getTextScale(component: UIComponent): Float { - return getHeight(component) + return getCachedDebuggable(component, ConstraintType.TEXT_SCALE) { component -> + // We're explicitly skipping rounding for textScale 1 (which is the default) as otherwise, when using a + // fractional guiScale, it will be rounded to a non-1 value, and consequently all Elementa text will appear + // slightly bigger (or smaller) than vanilla text. + // This will result in some aliasing (rounding is technically the correct thing to do if we want to avoid + // that), but that's something to expect when using a fractional gui scale mod, and would be up to that mod + // to fix. + getHeightImpl(component).let { if (it == 1f) 1f else it.roundToRealPixels() } + } } } diff --git a/src/main/kotlin/gg/essential/elementa/constraints/debug/ConstraintDebugger.kt b/src/main/kotlin/gg/essential/elementa/constraints/debug/ConstraintDebugger.kt index 3f95b9f9..bee5dc69 100644 --- a/src/main/kotlin/gg/essential/elementa/constraints/debug/ConstraintDebugger.kt +++ b/src/main/kotlin/gg/essential/elementa/constraints/debug/ConstraintDebugger.kt @@ -20,6 +20,7 @@ internal interface ConstraintDebugger { ConstraintType.WIDTH -> (constraint as WidthConstraint).getWidthImpl(component).roundToRealPixels() ConstraintType.HEIGHT -> (constraint as HeightConstraint).getHeightImpl(component).roundToRealPixels() ConstraintType.RADIUS -> (constraint as RadiusConstraint).getRadiusImpl(component) + ConstraintType.TEXT_SCALE -> (constraint as HeightConstraint).getHeightImpl(component).let { if (it == 1f) 1f else it.roundToRealPixels() } else -> throw UnsupportedOperationException() } }