diff --git a/webscrambles/src/main/kotlin/org/worldcubeassociation/tnoodle/server/webscrambles/pdf/FmcScrambleCutoutSheet.kt b/webscrambles/src/main/kotlin/org/worldcubeassociation/tnoodle/server/webscrambles/pdf/FmcScrambleCutoutSheet.kt index b8f8845f6..0f03b3912 100644 --- a/webscrambles/src/main/kotlin/org/worldcubeassociation/tnoodle/server/webscrambles/pdf/FmcScrambleCutoutSheet.kt +++ b/webscrambles/src/main/kotlin/org/worldcubeassociation/tnoodle/server/webscrambles/pdf/FmcScrambleCutoutSheet.kt @@ -47,20 +47,31 @@ class FmcScrambleCutoutSheet(scrambleSet: ScrambleSet, activityCode: ActivityCod val scrambleSuffix = Translate.translate("fmc.scrambleXofY", locale, substitutions) .takeIf { expectedAttemptNum > 1 } ?: "" - val attemptTitle = activityCode.compileTitleString(locale, includeGroupID = hasGroupID).trim() - val title = "$competitionTitle - $attemptTitle $scrambleSuffix" + val eventTitle = Translate.translate("fmc.event", locale) + val attemptDetails = activityCode.compileTitleString(locale, includeEvent = false, includeGroupID = hasGroupID) + val attemptTitle = "$eventTitle $attemptDetails".trim() + + val title = "$attemptTitle $scrambleSuffix" + + val font = Font(BASE_FONT, FONT_SIZE / 2) + val localBaseFont = FontUtil.getFontForLocale(locale) + val localFont = Font(localBaseFont, FONT_SIZE) // empty strings for space above and below - val textList = listOf("", title, scramble, "") - val alignList = List(textList.size) { Element.ALIGN_LEFT } + val textList = listOf( + "" to font, + competitionTitle to font, + title to localFont, + scramble to localFont, + "" to font) - val paddedTitleItems = textList.zip(alignList) + val alignList = List(textList.size) { Element.ALIGN_LEFT } - val font = Font(BASE_FONT, FONT_SIZE) + val paddedTitleItems = textList.zipTriple(alignList) for (i in 0 until SCRAMBLES_PER_SHEET) { val rect = Rectangle(LEFT.toFloat(), (top - i * availableScrambleHeight).toFloat(), (right - dim.width - SPACE_SCRAMBLE_IMAGE).toFloat(), (top - (i + 1) * availableScrambleHeight).toFloat()) - directContent.populateRect(rect, paddedTitleItems, font) + directContent.populateRect(rect, paddedTitleItems) directContent.addImage(Image.getInstance(tp), dim.width.toDouble(), 0.0, 0.0, dim.height.toDouble(), (right - dim.width).toDouble(), top.toDouble() - (i + 1) * availableScrambleHeight + (availableScrambleHeight - dim.getHeight()) / 2) @@ -82,5 +93,9 @@ class FmcScrambleCutoutSheet(scrambleSet: ScrambleSet, activityCode: ActivityCod val FONT_SIZE = 20f val SCRAMBLES_PER_SHEET = 8 + + private fun Iterable>.zipTriple(other: Iterable): List> { + return zip(other).map { Triple(it.first.first, it.first.second, it.second) } + } } } diff --git a/webscrambles/src/main/kotlin/org/worldcubeassociation/tnoodle/server/webscrambles/pdf/FmcSolutionSheet.kt b/webscrambles/src/main/kotlin/org/worldcubeassociation/tnoodle/server/webscrambles/pdf/FmcSolutionSheet.kt index fbf14bb69..c3fee5108 100644 --- a/webscrambles/src/main/kotlin/org/worldcubeassociation/tnoodle/server/webscrambles/pdf/FmcSolutionSheet.kt +++ b/webscrambles/src/main/kotlin/org/worldcubeassociation/tnoodle/server/webscrambles/pdf/FmcSolutionSheet.kt @@ -158,14 +158,17 @@ open class FmcSolutionSheet(scrambleSet: ScrambleSet, activityCode: ActivityCode val gradeRect = Rectangle((competitorInfoLeft + margin).toFloat(), competitorInfoBottom.toFloat(), (right - margin).toFloat(), gradeBottom.toFloat()) val scrambleImageRect = Rectangle((competitorInfoLeft + margin).toFloat(), gradeBottom.toFloat(), (right - margin).toFloat(), scrambleBorderTop.toFloat()) - cb.fitAndShowText(Translate.translate("fmc.event", locale), titleRect, titleFont, Element.ALIGN_CENTER) + val localEventTitle = Translate.translate("fmc.event", locale) + cb.fitAndShowText(localEventTitle, titleRect, titleFont, Element.ALIGN_CENTER) // Both competitor com competition details val compDetailItems = mutableListOf>() if (withScramble) { - val activityTitle = activityCode.copyParts(attemptNumber = null) - .compileTitleString(locale, includeGroupID = hasGroupID) + val activityTitleRaw = activityCode.copyParts(attemptNumber = null) + .compileTitleString(locale, includeEvent = false, includeGroupID = hasGroupID) + + val activityTitle = "$localEventTitle $activityTitleRaw" compDetailItems.add(competitionTitle to Element.ALIGN_CENTER) compDetailItems.add(activityTitle to Element.ALIGN_CENTER) diff --git a/webscrambles/src/main/kotlin/org/worldcubeassociation/tnoodle/server/webscrambles/pdf/util/PdfDrawUtil.kt b/webscrambles/src/main/kotlin/org/worldcubeassociation/tnoodle/server/webscrambles/pdf/util/PdfDrawUtil.kt index 9a22998da..009638b73 100644 --- a/webscrambles/src/main/kotlin/org/worldcubeassociation/tnoodle/server/webscrambles/pdf/util/PdfDrawUtil.kt +++ b/webscrambles/src/main/kotlin/org/worldcubeassociation/tnoodle/server/webscrambles/pdf/util/PdfDrawUtil.kt @@ -105,7 +105,7 @@ object PdfDrawUtil { for ((i, content) in itemsWithAlignment.withIndex()) { val height = slotHeights.subList(0, i).sum() - val proportionalFontSize = slotHeights[i] + val proportionalFontSize = -slotHeights[i] val temp = Rectangle(rect.left, rect.bottom + height - proportionalFontSize, rect.right, rect.bottom + height) fitAndShowText(content.first, temp, content.second, content.third, leadingMultiplier)