Skip to content

Commit b58d691

Browse files
committed
Font validator: Abbreviate long line lists
1 parent 7f08cba commit b58d691

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/main/kotlin/myaa/subkt/tasks/utils/fontvalidator.kt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ class FontReport {
229229
missingGlyphs.computeIfAbsent(font) { mutableSetOf() }.addAll(glyphs.toList())
230230
}
231231

232+
fun limitLines(lines: Collection<Int>, limit: Int = 10) =
233+
if (lines.size <= limit) lines.joinToString(" ")
234+
else lines.asSequence().take(limit).joinToString(" ") + " [...]"
235+
232236
fun printReport(
233237
onMissingFonts: ErrorMode, onFaux: ErrorMode,
234238
onStyleMismatch: ErrorMode, onMissingGlyphs: ErrorMode
@@ -238,7 +242,7 @@ class FontReport {
238242
if (onMissingFonts != ErrorMode.IGNORE) {
239243
missingFonts.forEach { (font, lines) ->
240244
println("warning: font '$font' not found on line(s): " +
241-
lines.joinToString(" "))
245+
limitLines(lines))
242246

243247
if (onMissingFonts == ErrorMode.FAIL) {
244248
fail = true
@@ -251,7 +255,7 @@ class FontReport {
251255
weightMap.forEach { (weight, lines) ->
252256
val (requested, actual) = weight
253257
println("warning: faux bold used for font $font (requested weight $requested, got $actual) " +
254-
"on line(s): ${lines.joinToString(" ")}")
258+
"on line(s): ${limitLines(lines)}")
255259
}
256260

257261
if (onFaux == ErrorMode.FAIL) {
@@ -260,7 +264,7 @@ class FontReport {
260264
}
261265

262266
fauxItalic.forEach { (font, lines) ->
263-
println("warning: faux italic used for font $font on line(s): ${lines.joinToString(" ")}")
267+
println("warning: faux italic used for font $font on line(s): ${limitLines(lines)}")
264268

265269
if (onFaux == ErrorMode.FAIL) {
266270
fail = true
@@ -273,7 +277,7 @@ class FontReport {
273277
weightMap.forEach { (weight, lines) ->
274278
val (requested, actual) = weight
275279
println("warning: requested weight $requested but got $actual for font $font " +
276-
"on line(s): ${lines.joinToString(" ")}")
280+
"on line(s): ${limitLines(lines)}")
277281
}
278282

279283
if (onStyleMismatch == ErrorMode.FAIL) {
@@ -283,7 +287,7 @@ class FontReport {
283287

284288
italicMismatch.forEach { (font, lines) ->
285289
println("requested non-italic but got italic for font $font " +
286-
"on line(s): ${lines.joinToString(" ")}")
290+
"on line(s): ${limitLines(lines)}")
287291

288292
if (onStyleMismatch == ErrorMode.FAIL) {
289293
fail = true
@@ -295,7 +299,7 @@ class FontReport {
295299
missingGlyphLines.forEach { (font, lines) ->
296300
val glyphs = missingGlyphs[font]?.joinToString("")
297301
println("warning: font $font missing glyphs $glyphs " +
298-
"on line(s): ${lines.joinToString(" ")}")
302+
"on line(s): ${limitLines(lines)}")
299303

300304
if (onMissingGlyphs == ErrorMode.FAIL) {
301305
fail = true

0 commit comments

Comments
 (0)