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

Issue when using -webkit-text-stroke #292

Closed
PolMrt opened this issue Jun 21, 2020 · 8 comments
Closed

Issue when using -webkit-text-stroke #292

PolMrt opened this issue Jun 21, 2020 · 8 comments

Comments

@PolMrt
Copy link

PolMrt commented Jun 21, 2020

Describe the bug
When using css class -webkit-text-stroke-color & -webkit-text-stroke-widthto put a border fitting the text, there are some unwantend border. Like this :

To Reproduce
Steps to reproduce the behavior:

  1. Create a <div>
  2. Put some text in it, especialy these characters : t, k, &, e
  3. Add these css classes : -webkit-text-stroke-color: red; -webkit-text-stroke-width: .8px; color: transparent (it also works when setting a color to the text)

Expected behavior
This should looks like this (here, using system font) :
Capture d’écran 2020-06-21 à 11 26 04

Environment

  • OS: macOS 10.14
  • App that renders the font : firefox
  • Version of font : 3.13
@thagxt
Copy link

thagxt commented Jun 24, 2020

I came here for the same reason! +1

@rsms
Copy link
Owner

rsms commented Jun 25, 2020

Did you by any chance use the fonts from Google Fonts?
If you did, can you please try with the official release from https://github.com/rsms/inter/releases/latest ?
If you didn't can you please provide information about what exact font files you are using? (otf, ttf, hinted or not, etc. And if you can, a sha or md5 checksum of the file data for the font file.)

@PolMrt
Copy link
Author

PolMrt commented Jun 25, 2020

I’m using the official files downloaded from your website.
Here is an example using the CDN https://jsfiddle.net/fc47r3b6/

@thagxt
Copy link

thagxt commented Jun 26, 2020

I also use the CDN: https://rsms.me/inter/inter.css

@rsms
Copy link
Owner

rsms commented Aug 17, 2020

I see! You are using the variable font.

TL;DR: Use static/constant fonts instead of the variable version.

Screen Shot 2020-08-17 at 09 47 43

This is unfortunately a bug (or really, a limitation) of the rendering engine in some web browsers. The variable font uses overlapping shapes to be able to be variable (technical reasons.) Most quality font renderers will apply what is usually called "boolean union" on the shapes of a glyph prior to rendering. Not doing this causes issues with regular "filled" rendering in addition to stroked rendering.

For example, Figma correctly applies the boolean union on the glyph's shapes before generating stroke geometry:
Screen Shot 2020-08-17 at 09 55 42

However, some design tools like Sketch fails, just like some web browsers:
Screen Shot 2020-08-17 at 09 54 52

So, this is unfortunately an issue with the software rendering the font.

@apodtele
Copy link

Would you know how "boolean union" is performed on outlines/contours? I bet it is not trivial.

@rsms
Copy link
Owner

rsms commented May 13, 2021

https://en.wikipedia.org/wiki/Boolean_operations_on_polygons

@apodtele
Copy link

The described algorithms operate on bitmaps or scan sweeps, i.e. during rendering not prior to it. It is rather expensive computationally. I was hoping that there was a good algorithm to merge outlines properly, which would be appropriate for this bug. Also, the overlap of the stroke paths is technically minute here unless you really track the winding number is a very special way.

To summarize, it is not a trivial problem and the overlaps were accepted in variable fonts rather hastily.

Repository owner locked as resolved and limited conversation to collaborators May 13, 2021
Repository owner unlocked this conversation May 13, 2021
Repository owner locked as off-topic and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants