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 is not retina ready #12

Open
Cam opened this issue Jul 29, 2015 · 34 comments
Open

Text is not retina ready #12

Cam opened this issue Jul 29, 2015 · 34 comments

Comments

@Cam
Copy link

Cam commented Jul 29, 2015

The text on the SVG badge is blurry and pixelated on high resolution screens.

@twolfson
Copy link
Contributor

Where are you seeing this behavior?

@Cam
Copy link
Author

Cam commented Jul 29, 2015

Sorry... should have given you that info... On Safari latest on Mac. Generally that happens when the SVG file is actually coded as smaller than the final size it is displayed at.

@twolfson
Copy link
Contributor

Cool, would you be interested in opening a PR to patch it?

@Cam
Copy link
Author

Cam commented Jul 29, 2015

Sure thing! Will do as soon as I can :)

@twolfson
Copy link
Contributor

Great, thanks =D

@Cam
Copy link
Author

Cam commented Aug 3, 2015

Hi @twolfson. I have made quite a number of changes to clean things up and make them more cross-browser compatible. I used outlined SVG contents instead of the basic format (which doesn't yet have full browser support for fonts) previously used.

I haven't submitted a PR yet, because there are a number of things that would affect other areas of the repo, and I wanted to first get your thoughts on my approach.

I added aria and accessibility to the SVG version, removed unnecessary shadows, and changed the size to 200x50 rather than 201x49.

You can check it out here https://github.com/Cam/gratipay-badge

@twolfson
Copy link
Contributor

twolfson commented Aug 3, 2015

Cool, thanks for taking the time to work on this. I think the 2x PNG is a good idea (although a 2x SVG seems silly).

With respect to edits on the SVG itself, the badge's current size and style are based off of what GitHub uses. This goes to the extent that the CSS is ripped directly from GitHub. As a result, I would like to request that we don't define colors that aren't derived from the CSS somehow. I am open to other options like relocating the SVG template outside of HTML and dynamically loading it.

Outside of those changes, can you explain things like removing the text itself (I am guessing this is browser support as you mentioned but I would prefer articles/issues) and the text shadow?

@Cam
Copy link
Author

Cam commented Aug 3, 2015

Hey @twolfson. The SVG shouldn't be 2x. Where is that? I can fix it.

It may prove hard to get it to work across all current browsers without using more defined SVG, but I can look into options. Where is the GitHub badge you replicated? I'd love to take a look at what they have done, and how compatible it is.

@twolfson
Copy link
Contributor

twolfson commented Aug 3, 2015

Ah, sorry. I must have looked at the non-master version while comparing. It looks like you patched the 2x SVG name: Cam@b7b42ad#diff-04c6e90faac2675aa89e2176d2eec7d8

The source is a GitHub button, not a badge. For example, the "Comment" on an issue page.

selection_155

@Cam
Copy link
Author

Cam commented Aug 3, 2015

Ahhh... yep. The GitHub buttons use text inside the button, rather than a full SVG button. I can do something like that for you if you like, but the markup would be a little more complex. It could use an iframe, like the unofficial GitHub badges, but that doesn't seem perfect to me. Although, it does allow for updates to be pushed globally without people updating their code.

@twolfson
Copy link
Contributor

twolfson commented Aug 3, 2015

I think there was a context loss. The existing code on gratipay/master is already based off of it. We are generating PNGs and SVGs without issues except for our rasterization on retina displays.

The current SVG template was generated via Sketch which might be causing those issues. Maybe we could rewrite the retina incompatible parts and keep the CSS color extractions?

@Cam
Copy link
Author

Cam commented Aug 3, 2015

To get around it, the text element of the SVG should be "flattened" rather than actual text. That alone would remove the high res screen issues. I think adding the aria accessibility stuff too would be a good idea, as the text would no longer actually be machine readable text.

Could I have the sketch file, and the export method used, so I can create a compatible version?

@twolfson
Copy link
Contributor

twolfson commented Aug 3, 2015

The .sketch file was created by @lvillani. I only know about it due to a line inside of #9. @lvillani Do you still have the .sketch file used for gratipay-badge?

@twolfson
Copy link
Contributor

twolfson commented Aug 3, 2015

@Cam Can you explain why or link me to an article explaining why we need to rasterize a font for SVG? That seems counter-intuitive since fonts are vectors themselves.

@Cam
Copy link
Author

Cam commented Aug 3, 2015

@twolfson It's just an issue with where SVG is at right now. It affects Safari and Chrome on high resolution displays. Hopefully the SVG standards will be updated soon to fix the issue.

@twolfson
Copy link
Contributor

twolfson commented Aug 3, 2015

This is starting to sound more like a problem with the browsers than our SVG. Upon researching what other sites do, it looks like their SVGs still use text (which is much more easy to maintain).

https://api.travis-ci.org/gratipay/inside.gratipay.com.svg

http://viewsource.in/https://api.travis-ci.org/gratipay/inside.gratipay.com.svg

<text x="62.5" y="14">passing</text>

https://img.shields.io/github/downloads/atom/atom/latest/total.svg

http://viewsource.in/https://img.shields.io/github/downloads/atom/atom/latest/total.svg

<text x="35" y="14">downloads</text>

@Cam
Copy link
Author

Cam commented Aug 3, 2015

It is... in a way. But it's best to have cross-browser compatibility. I'm having a look through your SVG code now to see if I can find the problem...

@Cam
Copy link
Author

Cam commented Aug 3, 2015

Interestingly, if I remove the shadow, the problem goes away. I think the problem must be filter="url(#filter-2)"

@twolfson
Copy link
Contributor

twolfson commented Aug 3, 2015

Hm, any idea if there's another way to generate a text shadow in SVG that's compatible (e.g. 2 sets of text)?

@Cam
Copy link
Author

Cam commented Aug 3, 2015

Just testing that now :)

@Cam
Copy link
Author

Cam commented Aug 3, 2015

Yep! I managed to make an almost identical facsimile using two layers and opacity :)

Check out the lib/index.html on this fork to see it in action https://github.com/Cam/gratipay-badge

@twolfson
Copy link
Contributor

twolfson commented Aug 3, 2015

@Cam
Copy link
Author

Cam commented Aug 4, 2015

Yeah, I wanted to see if you were happy with that method before spending any time on it ;)

EDIT: I've just noticed the HTML is also a bit of a mess in some ways. The HTML version isn't ready for zooming or accessibility either. I manually added accessibility stuff to the SVG. If you take a look at my fork, you can grab whatever elements you want from it. I feel you could probably simplify the whole thing though and make it more robust and elegant.

I didn't really try to attack the canvas js stuff either. Apparently there are issues with canvas and high resolution screens. It can be dealt with using extra CSS.

@rohitpaulk
Copy link

!m @Cam
!m @twolfson

@Cam
Copy link
Author

Cam commented Aug 4, 2015

@rohitpaulk :)

@Cam
Copy link
Author

Cam commented Aug 8, 2015

@twolfson What do you think? Is the new SVG and PNGs to your liking?

@twolfson
Copy link
Contributor

twolfson commented Aug 8, 2015

The rendering doesn't looks so good on Firefox in Linux (Linux Min 17.1 to be specific) =/

Current:

selection_167

New:

selection_166

@Cam
Copy link
Author

Cam commented Aug 8, 2015

Ha! Damn. At least that is the least used platform. But still, the share is substantial enough for it to still be important. Are you open to using more suitable methods for the current state of SVG support? Something with real text should work for everything.

@Cam
Copy link
Author

Cam commented Aug 8, 2015

What about modernising it a bit and removing the shadow? That would fix all of the issues. Or do you really want it to mimic the GitHub buttons? Unfortunately I don't think you can have the best of both worlds and keep it effective and properly formatted for popular platforms.

@twolfson
Copy link
Contributor

twolfson commented Aug 8, 2015

I am trying to find issues filed for Chrome and Safari about our issue but am failing to. It would be nice to get an ETA on their solve times before making a decision =/

Also, I have a feeling it isn't the shadow itself but the upscaling of the shadow itself. Maybe we could render the text as 2x size with a 1x shadow and downsize it?

@twolfson
Copy link
Contributor

twolfson commented Aug 8, 2015

@Cam
Copy link
Author

Cam commented Aug 8, 2015

Hmmm... the "-webkit-transform: translateZ(0);" thing looks promising.

@Cam
Copy link
Author

Cam commented Aug 12, 2015

@twolfson let me know what you think will suit your preferences best.

@twolfson
Copy link
Contributor

I have a strong preference to keeping the SVG close to what it currently is. As a result, we should prob try out the workarounds to see if they work in GitHub READMEs =/

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

3 participants