-
-
Notifications
You must be signed in to change notification settings - Fork 171
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
svg lettericons #55
svg lettericons #55
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done, looks really great, let's tackle improvement of the non A-Z's later, this is a great starting point, thank you 👍 Really just one comment not the svg lettericon paths.
besticon/iconserver/server_test.go
Outdated
@@ -188,6 +201,21 @@ func TestGetLetterIcon(t *testing.T) { | |||
assertIntegerInInterval(t, 1500, 1800, w.Body.Len()) | |||
} | |||
|
|||
func TestGetLetterIconSVG(t *testing.T) { | |||
req, err := http.NewRequest("GET", "/lettericons/M-144-EFC25D.svg", nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we even want to allow for the size
to be in the path for .svg
? I'm thinking the fact the we allow it is kind of ok by Postel's law on the one hand but could lead to misunderstanding one the other (we're not using this).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, let's turn off support for size entirely. We're not generating those with SVG so no need to parse them. Give me a sec here
vars := map[string]string{ | ||
"$BG_COLOR": ColorToHex(bgColor), | ||
"$FG_COLOR": ColorToHex(pickForegroundColor(bgColor)), | ||
"$LETTER": buf.String(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like the lightweight templating approach for this👍
OK, check out the latest commit. I reworked |
The server can generate SVG lettericons. Only enabled if
?formats=
includessvg
. Most of the action is inRenderSVG
. Also tweaks toIconPath
to support SVG. For example, an SVG lettericon path doesn't include the size in the filename.One thing to note. The A-Z lettericons look great (see below), but ф is a bit low. Right now we have
dy="0.10em"
hardcoded in the SVG template. Not sure if it would be possible/worthwhile to customize based on the letter. I could also imagine using Freetype to measure the Arial glyph height... The traco 1M doesn't include any IDN domains, unfortunately.