Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text goes out of boundary #14

Open
orsinium opened this issue Jun 19, 2019 · 4 comments
Open

Text goes out of boundary #14

orsinium opened this issue Jun 19, 2019 · 4 comments

Comments

@orsinium
Copy link

orsinium commented Jun 19, 2019

image

Maybe, something wrong with my fonts

@nwtgck
Copy link
Owner

nwtgck commented Jun 23, 2019

@orsinium Thank you for reporting. Can I ask questions? The repository is https://github.com/dephell/dephell? The image type is SVG? I'd like to know about your environment if possible.

Here is a screenshot of a card of dephell/dephell in SVG in gh-card.dev in Safari in macOS.
image

@orsinium
Copy link
Author

Thank you for your reply :)

Both svg and png give the same bug on original site. However, when I pasted the link on it here, it would be rendered correctly. That's strange. I'll discover it a bit tomorrow.

@nwtgck
Copy link
Owner

nwtgck commented Jun 23, 2019

@orsinium Thanks.

That's strange. I'll discover it a bit tomorrow.

It's storage. But we have proof in the screenshot in the first issue comment. In PNG, I know some repos have the same problem.

@nwtgck
Copy link
Owner

nwtgck commented Jun 23, 2019

The purpose of this comment is to provide the current implementation causing this issue.

Details of implementation

In the current implementation, a description text of repo is not auto line-wrapped. Very poor implementation is here. It splits a description into lines which may go out of boundary.

// TODO: Make it declarative
// TODO: Support non-English description
private def descriptionToLines(description: String): List[String] = {
val splitter = " "
val words = description.split(splitter)
var line: String = ""
var lines: List[String] = List.empty
for(word <- words) {
line += word + splitter
if (line.length > 55) {
lines :+= line
line = ""
}
}
if (line != "") {
lines :+= line
}
lines
}

I don't think the hard-coded > 55 is good at all. But I found it works well in most cases which I investigated manually, so I use it.

Solution candidate

According to https://stackoverflow.com/a/4991339/2885946, text wrapping is not supported in SVG 1.1.

Text wrapping is not part of SVG1.1

The answer says <foreignObject> and HTML are a solution. It may be a general solution to solve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants