A Decade of Slug

(terathon.com)

700 points by mwkaufma21 hours ago

30 comments

  • miloignis21 hours ago
    This is wonderful news, and my sincere thanks to the author. I remember coming upon this algorithm several years ago, and thinking it was extremely elegant and very appealing, but being disappointed by the patent status making it unusable for FOSS work. I really appreciate the author&#x27;s choice to dedicate it to the public domain after a reasonable amount of time, and congratulations on the success it had while proprietary!<p>Now if I ever get around to writing that terminal emulator for fun, I&#x27;ll be tempted to do it with this algorithm for the code&#x27;s aesthetic appeal.
    • olejorgenb19 hours ago
      &gt; I was granted a patent for the Slug algorithm in 2019, and I legally have exclusive rights to it until the year 2038. But I think that’s too long. The patent has already served its purpose well, and I believe that holding on to it any longer benefits nobody. Therefore, effective today, I am permanently and irrevocably dedicating the Slug patent to the public domain.
      • convexhulled19 hours ago
        Yes, now that SDF font rendering is the industry&#x27;s preference, he drops the software patent. That is, he is dropping the patent because it isn&#x27;t a commercially viable piece of software, not because he is ethically opposed to it. Great virtue signaling though.
        • dwroberts19 hours ago
          Seems more like he had the patent long enough to build a sustainable business from his own work, and now he’s been able to earn enough from it that others’ implementations aren’t a risk to him.<p>Which is kind of the entire point of patents, just that they last way too long relative to the speed of technological progress
          • usefulcat2 hours ago
            He said &quot;holding on to it any longer benefits nobody&quot;, implicitly including himself. He may believe that it&#x27;s to his advantage for the patent to be more widely used.<p>Which makes sense--I don&#x27;t doubt that he is a subject matter expert where this patent is concerned. If this algorithm continues to be widely used or its use increases, then that would be likely be good for him.
        • flohofwoe9 hours ago
          SDF font rendering was common long before Slug, and Slug is supposed to be the better solution (I haven&#x27;t used it though, so cannot comment on its pros and cons vs SDF, but one obvious disadvantage of SDF is that you still need a font atlas texture, and that can get very big if you need to render some East Asian character sets).
        • skullt18 hours ago
          SDF font rendering has been around 20+ years though? Valve really popularized in their 2007 SIGGRAPH paper and Chlumský developed MSDF font rendering in a 2015 thesis.
        • flipgimble17 hours ago
          SDF font rendering was an industry standard maybe from 2007-2010. and you probably won’t believe what happened to OpenGL since then. Don’t even look into at what people are doing with GPUs these days, you won’t like it one bit!
        • ZeWaka19 hours ago
          You do realize he could&#x27;ve just kept it until 2038, right? This was completely unforced.
        • LoganDark15 hours ago
          SDF rendering is just a fuzzy blobby approximation.
          • flohofwoe9 hours ago
            For that it works surprisingly well though, unless you need tiny text.
    • actionfromafar20 hours ago
      Software patents valid for 8 years is actually something I could get behind.
      • teaearlgraycold14 hours ago
        Copyrights universally dropped to ~20 years as well while we&#x27;re at it.
        • dhosek1 hour ago
          My feeling is that copyrights should be infinitely renewable, with say a 20 year term, <i>but</i> the renewal fee should double with each term so that Disney can have their infinite copyright on Snow White but at an ever-increasing cost so that they will need to make a decision about whether it makes sense to keep it.<p>My utopian vision: First registration is free and automatic. Copyright holders get an automated notification of expiring copyright and renewal is, say $1000 for the first term (adjusting for inflation) and doubling thereafter (also adjusting for inflation, so you don’t get a $2000 renewal but more like $4400 with 4% inflation). For corporate-held and posthumous extensions, the term would be 10 years.
          • nicoburns49 minutes ago
            &gt; so that Disney can have their infinite copyright on Snow White<p>If copyright was inifinite, then Disney would never have been able to make Snow White in the first place. They didn&#x27;t invent the story!<p>Even if they did, it seems like a huge negative to society for copywright not to expire.
  • Lichtso6 hours ago
    There are two ways to get winding numbers and then decide on filled or empty by some rule like non-zero or even-odd:<p>a) The winding number of a point is the number of intersections of a scanline and a closed path.<p>b) The winding number around a point is the total angle subtended by the path at that point.<p>Slug uses approach a) and that comes with a lot of edge cases (see chart in the post) and numerical precision issues. The approach by loop &amp; blinn uses b) and is thus simpler and more robust. Likewise the patent on that one expired too: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=47416736#47420450">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=47416736#47420450</a>
    • jeremiahkellick1 hour ago
      Loop and blinn does not compute a winding number using the b) method. It avoids the issue of a winding number by assuming there&#x27;s only 1 bezier curve per triangle, which requires a complicated triangulation step. It can produce some nasty geometry in more complex cases. With Slug, you can use only 1 quad per glyph if you want.<p>Also just to clarify regarding this statement:<p>&gt; Slug uses approach a) and that comes with a lot of edge cases (see chart in the post) and numerical precision issues<p>Slug does not have numerical precision issues. It&#x27;s the breakdown into different cases that _solves_ those issues, whereas your statement makes it sound like slug has _both_ the case complexity and the precision issues.
  • cachius19 hours ago
    His latest project is <a href="https:&#x2F;&#x2F;radicalpie.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;radicalpie.com&#x2F;</a><p>A Professional Equation Editor for Windows 10&#x2F;11 for 60$ that uses Slug for rendering. Presumably he‘s using it to write his great FGED books.
    • amluto17 hours ago
      25 years ago I would have loved that. But I don&#x27;t actually know many people still doing any of this sort of work on Windows.<p>(I get it. It&#x27;s an awesome replacement for MathType. It uses OLE so that it embeds in Microsoft Word nicely. Still...)
      • quietbritishjim4 hours ago
        I agree that it&#x27;s a bit late but I don&#x27;t think the issue is use of Windows (or Word, if that&#x27;s what you&#x27;re implying).<p>&gt; It&#x27;s an awesome replacement for MathType. It uses OLE so that it embeds in Microsoft Word nicely.<p>But that&#x27;s the rub - OLE doesn&#x27;t embed particularly nicely. I haven&#x27;t used it in over a decade (maybe two?). It&#x27;s sort of very softly deprecated.<p>The new equation editor in Word which isn&#x27;t based on MathType, and doesn&#x27;t use OLE, works much more smoothly than the old one, even if it doesn&#x27;t support everything. (&quot;New&quot;? I just checked and it was introduced in 2007!) I think a typical user would have to be really desperate for extra functionality to abandon that level of integration, at which point you&#x27;d probably switch away from Word altogether.
      • delta_p_delta_x10 hours ago
        &gt; But I don&#x27;t actually know many people still doing any of this sort of work on Windows.<p>Most primary, secondary, and pre-university school teachers without an institutional understanding of LaTeX, which admittedly has an extremely high (technical, not financial) barrier to entry compared to Microsoft Word + MathType. This is what my secondary school teachers used, for instance. They&#x27;re given bog-standard laptops with Windows to work with.<p>Also exam setters and writers in places like Cambridge University Press and Assessment. If you took a GCSE, O-level, or A-level exam administered by them, it had pretty high quality typesetting for maths, physics diagrams, chemistry skeletal diagrams and reaction pathways... But almost none of it was done with LaTeX, and instead probably all add-ons to Microsoft Word or Adobe InDesign.
      • nikanj7 hours ago
        Depressingly I don&#x27;t actually know many people still doing any of this sort of work, on any platform.
      • mmooss16 hours ago
        What stack are those people using?
        • kibibu13 hours ago
          He has a post up: <a href="https:&#x2F;&#x2F;terathon.com&#x2F;blog&#x2F;radical-pie.html" rel="nofollow">https:&#x2F;&#x2F;terathon.com&#x2F;blog&#x2F;radical-pie.html</a><p>I&#x27;m pretty confident the &quot;stack&quot; is C++ on Win32, with a bunch of hand-rolled libraries and no stdlib.
          • Sammi10 hours ago
            Will probably run great in Proton.
          • mmooss13 hours ago
            Hmmm ... the GP says<p>&gt; I don&#x27;t actually know many people still doing any of this sort of work on Windows.
            • kibibu13 hours ago
              I think they meant writing complex equations on windows
              • mmooss11 hours ago
                Or doing work that regularly involves writing complex equations, which is what I was asking about - what field and what do they use?
                • amluto2 hours ago
                  LaTeX or its variants on your favorite OS, which is increasingly not Windows.<p>Most journals don’t want submissions in Word (there are notable exceptions, e.g. Nature), and conferences without massive editorial budgets want their submissions in a format that makes it easy for them to produce proceedings (again, not Word).<p>I don’t know to what extent Typst is taking off recently.<p>I personally wrote my thesis in LuaTeX with figures in TikZ. I have no great love for the TeX language [0] or TikZ, but there are three great properties of this stack that Word lacks:<p>1. It plays well with version control.<p>2. The output quality can be very high.<p>3. You can script the generation of figures, including text and equations that match the formatting of the containing document, in a real programming language, without absurd levels of complexity like scripting Word. So I had little Python programs that printed out TikZ.<p>No, I do not expect the average high school teacher to do this.<p>[0] In fact, I think both the language and the tooling are miserable to work with.
  • astroalex18 hours ago
    I used Slug at a previous job. It is an excellent, artfully crafted library; really the pinnacle of software engineering in my opinion. Thanks to the author for donating the algorithm to the public domain!
  • amagitakayosi15 hours ago
    Amazing, Thank you Eric!!<p>Also, Microsoft&#x27;s Loop-Blinn patent for cubic curves will expire on March 25. These might change the landscape of text rendering...
    • cylemons8 hours ago
      I thought loop-blinn expired a while ago, or is the cubic curves separate from quadratic?
      • amagitakayosi8 hours ago
        IIRC their patent is mainly for cubic curve filling. It&#x27;s still in effect: <a href="https:&#x2F;&#x2F;patents.google.com&#x2F;patent&#x2F;US7564459B2&#x2F;en" rel="nofollow">https:&#x2F;&#x2F;patents.google.com&#x2F;patent&#x2F;US7564459B2&#x2F;en</a>
  • tokyovigilante13 hours ago
    Thanks Eric, much appreciated. How would you compare your approach to something like Vello (<a href="https:&#x2F;&#x2F;github.com&#x2F;linebender&#x2F;vello" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;linebender&#x2F;vello</a>)?
    • elengyel11 hours ago
      Vello is intended more for general vector graphics and would probably perform better with pictures containing lots of large paths. Slug is designed specifically for rendering glyph-like objects and would perform better with lots of text and icons.
      • Ono-Sendai8 hours ago
        I was going to ask if Slug can be used as a general vector renderer. Or does it assume limits on e.g. number of curves&#x2F;paths per area that are typical of fonts?
        • kevthecoder7 hours ago
          Eric answered a similar question on the Discord channel saying Slug is suitable for generic vector graphics. He recommends checking out the demo at <a href="https:&#x2F;&#x2F;sluglibrary.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;sluglibrary.com&#x2F;</a> (you can cycle through the examples with the space bar).
        • Lichtso6 hours ago
          I think it is limited to integral quadratic bezier curves, which is sufficient for text rendering. But general purpose vector graphics almost certainly want rational cubic bezier curves too.
  • byearthithatius20 hours ago
    Love it when someone who makes complex, helpful software is rewarded for their efforts. More stories like this!
  • Benjamin_Dobell5 hours ago
    Thanks, Eric; for this, and for my start as a software engineer — my first commercial development work was consulting as an 18 year old building games with C4. I&#x27;m really glad Slug was able to find commercial success for you in the way that C4 unfortunately wasn&#x27;t able to.<p>For those of you who aren&#x27;t familiar with Eric&#x27;s work, he&#x27;s basically the Fabrice Bellard of computer graphics.
  • Vipitis20 hours ago
    I am sorta in a position where implementing a glyph renderer as a compute shader would be helpful. This is a great opportunity to use this as a reference... exciting weekend project!
  • Cthulhu_19 hours ago
    Damn, I worked with the author&#x27;s game engine (C4) about... 20 years ago now while still in school, didn&#x27;t know they were still active in that area!
  • sbinnee9 hours ago
    I am not at all familiar with game development. This article reminds me of Casey Muratori mentioning a font issue in game development environment from a random podcast. On web, you can just fetch a google font whatever. No problem. On a local machine, you tend to look a well-established software like harfbuzz. But then harfbuzz could be rather a big dependency. A game is self-contained and you want your font looks cool and unique to your game, like the Diablo font. So it becomes a design issue. It&#x27;s an awesome approach to let GPU render fonts. I cannot imagine how many game devs had font issues where they realized that they might have to learn how to render fonts as well not just characters and grass.
    • flohofwoe9 hours ago
      &gt; well-established software like harfbuzz<p>Harfbuzz is only one piece of the puzzle, it&#x27;s not a text renderer, only a &#x27;text shaper&#x27; (e.g. translating a sequence of UNICODE codepoints into a sequence of glyphs). The actual font handling and text rendering still needs to be done by some other code (e.g. the readme in Mikko Mononen&#x27;s Skribidi project gives a good overview about what&#x27;s needed besides the actual rendering engine: <a href="https:&#x2F;&#x2F;github.com&#x2F;memononen&#x2F;Skribidi&#x2F;" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;memononen&#x2F;Skribidi&#x2F;</a>)
  • VikingCoder20 hours ago
    Is it on ShaderToy yet? :D
  • weslleyskah9 hours ago
    So nice to see this here. The author&#x27;s books are awesome resources for graphics and C++. It&#x27;s a shame there seem to be fewer print editions available these days!?
  • andai14 hours ago
    This is super cool. A few years ago I was wondering if Ruffle could do something similar, incorporate some kind of GPU accelerated vector graphics.<p>At the time they were going with, approximating the curves out of triangles. I don&#x27;t know if they&#x27;re still doing that though.
  • amelius7 hours ago
    &gt; I was granted a patent for the Slug algorithm in 2019, and I legally have exclusive rights to it until the year 2038. But I think that’s too long.<p>This is cool but I did not know software patents were still a thing in the US.
  • lacoolj19 hours ago
    &gt; But I think that’s too long. The patent has already served its purpose well, and I believe that holding on to it any longer benefits nobody.<p>Damn dude didn&#x27;t you pay like ... over $10k for that patent?
    • elengyel18 hours ago
      I took care of the whole thing myself without lawyers, so I ended up paying something like $950 in various filing fees.
      • kzrdude18 hours ago
        How did you get that diploma&#x2F;plaque, is that something every patent author will have?
        • shrubble16 hours ago
          You can buy them from various manufacturers that make them; you often get unsolicited mail from them as your name and address is on the patent filings.
        • elengyel16 hours ago
          The plaque was a personal order from one of the many companies that make them. What you actually get from the USPTO looks like this: <a href="https:&#x2F;&#x2F;x.com&#x2F;EricLengyel&#x2F;status&#x2F;1159917092331642880&#x2F;photo&#x2F;1" rel="nofollow">https:&#x2F;&#x2F;x.com&#x2F;EricLengyel&#x2F;status&#x2F;1159917092331642880&#x2F;photo&#x2F;1</a>
  • Ono-Sendai5 hours ago
    So now the algorithm is patent-free, and the vertex and fragment shaders are open-sourced with the MIT license, what we presumably need is some open-source code to take Bezier curves from a font file (or from the loaded data from FreeType or whatever), and process them into the data format that Slug expects.<p>Also thank you to Eric Lengyel, I have had my eye on Slug for a while and wished it was open-source.
  • swiftcoder19 hours ago
    Lengyel continues to be standup dude, kudos!
  • valentinomici518 hours ago
    I&#x27;ve been following this project for a while. Nice to see the progress.
  • adamrezich18 hours ago
    Finally, some <i>good</i> video game development news!
  • Validark16 hours ago
    Awesome algorithm and thank you for donating it to open source!
  • leecommamichael19 hours ago
    Thank you!
  • maximilianburke19 hours ago
    Amazing! Thank you, Eric!
  • forrestthewoods20 hours ago
    Oh wow this is crazy. This was a project that was reasonably successful commercially. And now it’s just being given away open source? What an absolutely incredibly gift to the community!!
    • aseipp19 hours ago
      Not quite, just the pixel&#x2F;vertex shaders and the algorithm is public domain. Slug &quot;the software package&quot; is not open source (you can get a copy of it along with C4 Engine for $100 to take a peek if you want, though).
  • moralestapia20 hours ago
    Thank you for your service!
  • rrauenza20 hours ago
    Here&#x27;s an alternate if you&#x27;re also getting connection reset errors:<p><a href="https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20260317185928&#x2F;https:&#x2F;&#x2F;terathon.com&#x2F;blog&#x2F;decade-slug.html" rel="nofollow">https:&#x2F;&#x2F;web.archive.org&#x2F;web&#x2F;20260317185928&#x2F;https:&#x2F;&#x2F;terathon....</a>
    • dang20 hours ago
      We&#x27;ll put that link in the toptext as well. Thanks!
  • myylogic16 hours ago
    [dead]
  • Iamkkdasari7416 hours ago
    [flagged]
  • fasterik16 hours ago
    [flagged]
  • wei0328815 hours ago
    [flagged]
    • rhaen13 hours ago
      Please don’t post AI generated comments, it’s against the rules and also just a waste of people’s time.
    • elengyel14 hours ago
      Glyph complexity has no effect on the calculations done in the pixel shader and does not change how glyphs are preprocessed. There are no edge cases. If you&#x27;d like to see some ridiculously complex fonts get rendered with Slug, check out the 8th page in the demo at sluglibrary.com. Some of those individual glyphs are composed of over 1000 Bézier curves!