joekndy / MarqueeText

Marquee or "scrolling text" effect in SwiftUI
270 stars 43 forks source link

`lineLimit` appears to have no effect with newline characters #25

Open markst opened 2 months ago

markst commented 2 months ago

Some of my response JSON includes strings which contain carriage return (\r) followed by a newline (\n) characters.

  - some : "Songs for Swinging Subversives\r\n\r\nComical intervention on both sides by Vivian Stanshall....\r\nFrom Sir Henry at Ralinson End\"\r\n\r\nA Subtle Subversion Production...\r\n\r\nMixtape given to Paul McKee by Andrew. Reproduced by Stephen Hoare. Photo by Claire Doll"

Despite MarqueeText using .lineLimit(1) and my implementation the same:

MarqueeText(
    text: player.title,
    font: .systemFont(ofSize: 24, weight: .medium),
    leftFade: 10,
    rightFade: 10,
    startDelay: 3,
    alignment: .center
)
.allowsTightening(true)
.lineLimit(1)

My views appear to overflow:

markst commented 2 months ago

Replacing these characters will fix it for me:

content = download.content?
    .components(separatedBy: CharacterSet(charactersIn: "\r\n"))
    .joined() ?? ""