Multi-stroke text effect in CSS

(yuanchuan.dev)

160 points | by cheeaun 9 hours ago

5 comments

  • HughParry 4 hours ago

    I wonder why the firefox CSS rendering engine prefers to smooth out. Looks like a dramatically different implementation, but maybe that's just because it's an edge case of rendering

    • zokier 2 hours ago

      While I don't entirely love the rounding effect of firefox, I feel Chrome interpretation is just wrong in creating spurious spikes. Intuitively for the asterisk shape I'd expect the outline to go towards a plain hexagon, something that neither browser accomplishes.

      • voidUpdate 2 hours ago

        firefox looks like an SDF (shortest distance to the object), I'm not sure what the chrome one is...

        • danbruc 2 hours ago

          I would assume they are just drawing the outline, not performing any distance calculations, and the differences are just a result of different linejoin choices. [1]

          [1] https://www.w3.org/TR/fill-stroke-3/#stroke-linejoin

          • voidUpdate 59 minutes ago

            I'd imagine that at some point during the text rendering process, they have to generate an SDF of the text they want to render (it's what I did when I wanted to manually render text anyway). If they do, then they can generate the extra text-width lines basically for free, just fill everything with distance less than the property.

            I may be entirely wrong though, I don't know in detail how browsers render stuff

        • npodbielski 1 hour ago

          Look at V in Love. It looks like bug in Chrome.

        • tiffanyh 1 hour ago

          OT: really love the design of this blog. Simple, clear and content first.

          • nicbou 6 hours ago

            Neat! It's unfortunate that the rendering is so different between browsers.

            Have you tried the same thing with shadows? They can also be stacked, I believe.

            • LoganDark 4 hours ago

              Shadows have to be spread in a circle to achieve an outline, so the general shape will converge to roughly a circle, barely following the shape of the text.

            • vjay15 1 hour ago

              This is so freaking cool

              • assimpleaspossi 3 hours ago

                People should quit trying to make CSS a drawing tool--it is not--and start learning how to use SVG instead or images.

                • wbobeirne 2 hours ago

                  Art is often made from clever use of things that were not intended to make art. Let them have fun.

                  • emaro 1 hour ago
                    • afavour 45 minutes ago

                      The article literally says "it's not well-suited for production usage" so I don't really see the reason for the objection here. It's an experiment.

                      • cafebabbe 3 hours ago

                        If you have a lot of "images" with such effects to generate from dynamic text, using SVG makes no sense, is vastly more complex and less flexible than the solution here.

                        • zarzavat 50 minutes ago

                          You don't generate images, you just embed SVG nodes in the DOM. From the browser's perspective SVG and HTML elements are just two different types of element.

                          SVG is not great for text - HTML has more features - but for display text it's OK.

                        • mpalmer 42 minutes ago

                          I would think that quite a few powerful new ideas have come purely from abusing and bashing around older ideas.

                          • echoangle 3 hours ago

                            This could actually be cool for display text like a headline. I don’t think that’s only for images.