Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/main/kotlin/gg/essential/elementa/constraints/Constraint.kt
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,15 @@ interface HeightConstraint : SuperConstraint<Float> {
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() }
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down