• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Martomate / Hexacraft / 7351367576

28 Dec 2023 06:50PM UTC coverage: 51.185% (-0.1%) from 51.312%
7351367576

push

github

Martomate
Refactor: Made Chunk not know if it has been saved to file

9 of 12 new or added lines in 2 files covered. (75.0%)

110 existing lines in 32 files now uncovered.

2829 of 5527 relevant lines covered (51.19%)

0.51 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.67
/game/src/main/scala/hexacraft/text/layout/LineBreaker.scala
1
package hexacraft.text.layout
2

3
import hexacraft.text.font.{Character, FontMetaData}
4

5
import scala.collection.mutable
6

7
class LineBreaker(maxLineWidth: Float) {
8

9
  /** Splits the text into lines no wider than the given max line width */
1✔
10
  def layout(text: String, font: FontMetaData): Seq[Line] =
1✔
11
    val lines = new mutable.ArrayBuffer[Line]
12

1✔
13
    var currentLine: Line = Line(font.spaceWidth, maxLineWidth)
14

15
    val words: Array[Word] =
×
16
      for s <- text.split(' ')
17
      yield
1✔
UNCOV
18
        val w = new Word
×
19
        for c <- s.toCharArray do
1✔
20
          val character: Character = font.getCharacter(c.toInt)
1✔
21
          w.addCharacter(character)
22
        w
23

1✔
24
    for w <- words do
1✔
25
      val added: Boolean = currentLine.attemptToAddWord(w)
26
      if !added then
×
27
        lines += currentLine
×
28
        currentLine = Line(font.spaceWidth, maxLineWidth)
×
29
        val couldFit = currentLine.attemptToAddWord(w)
30

31
        // The following is a workaround for auto-resizing texts to detect an overflow
32
        if !couldFit then lines += Line(font.spaceWidth, maxLineWidth)
33

1✔
34
    if currentLine.words.nonEmpty then lines += currentLine
35

1✔
36
    lines.toSeq
37

38
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc