Better HN
topnewbestaskshowjobs
Log inSign up

raphlinus

14,081 karma · joined Mar 7, 2014 (12y ago) · 1,887 submissions

I do research on fundamental UI technology and 2D graphics, with a focus on Rust and fonts. @raph@mastodon.online
Submissions

comment 5y ago · link · parent

I think I miscommunicated a bit. I'm not suggesting you should be routinely breaking these rules with cubic Béziers. Rather, I'm saying that if you had a better underlying curve family, you wouldn't need these rules, as you'd get good results even with a freer approach to designing curves. That's basically the hypothesis we're testing.

comment 5y ago · link · parent

The mathematical treatment of the underlying 4-parameter curve family is coming soonish; this blog focuses on the UX, which I think is also a very interesting and challenging problem.

comment 5y ago · link · parent

These kinds of rules are common, but it also means you're only using a fraction of the expressive power of the Béziers. Why not draw actual S-curves? That way you're guaranteed an actual inflection point where curvature goes smoothly through zero, as opposed to two arcs joined. Why not explore control over tension by using curve handles greater than 1/3 (so curvature on endpoints is less) or less than 1/3, cranking up the tension in a way inspired by physical materials? Why not have the computer do the work of ensuring the joins are G2 continuous by construction, instead of having to eyeball it?

994.

The Hyperbezier Pen Tool(cmyr.net ↗)

120 points · by raphlinus · 5y ago · 22 comments

comment 5y ago · link · parent

I'm very curious about this too. I'm going to seriously consider this color space, as well as cubic splines, as native gradient types in piet-gpu, because I think it's likely we can see higher quality at modest GPU shader cost.

comment 5y ago · link · parent

Dithering is usually best done in a linear space; the mixing of light is modeled as a physical rather than a perceptual process. This is especially true when the pixels are small and one can imagine a low-pass filter removing the high spatial frequencies. When dithering to huge, chunky pixels that can be individually perceived, different considerations might apply.

comment 5y ago · link · parent

Chromatic adaptation is definitely one of the trickier questions in color management. Here's my take on it.

For the most part, when looking at a monitor, chromatic adaptation is pretty good. In other words, RGB #FFFFFF looks white, not light blue, and #808080 looks gray, not bluish-gray. It does start falling apart when you mix different lighting, for example holding a white piece of paper to the screen under normal room light.

I think the main reason D65 is chosen for the sRGB white point is that it is fairly accurate, in other words it's pretty close to the actual white point of the monitor I'm looking at now (Dell P2415Q).

I have yet to find a source on chromatic adaptation that I consider a really excellent tutorial. Certainly the Wikipedia page is cursory and abstract, which is a shame.

comment 5y ago · link · parent

If you want to match the font of the IBM PC technical documentation, it's ITC Garamond, not Times. Very characteristic of the era, Apple also adopted it (in it condensed variant).

comment 5y ago · link · parent

Do Windows on ARM devices tend to have hardware support for x86-style Total Store Order (as does M1), or is it all done through software tricks? If the latter, it's hard to see how it can be both performant and reliable.

comment 5y ago · link · parent

I just want to confirm the quality of this source, as someone who is not actually a biologist but who has been following the scene carefully since the beginning. Dr Hodcroft is in the top tier of science communicators. This "new strain" story is basically tailor made for misinformation and poor information, as it has such a strong hook.

The tl;dr as I understand it is that there may be something there, but it is too early to tell for sure.

comment 5y ago · link · parent

That's true for traditional object oriented GUI, but there are other ways to do it. Druid uses almost no interior mutability, and Arc is used sparingly, as immutable data structures are very handy for incremental computation. The Crochet prototype is even more imgui-like from the perspective of the application, and relies on Arc (and Clone bounds) even less.

I think doing this right will require some imagination, not just playing greatest hits from previous decades, only in a new language.

comment 5y ago · link · parent

Of course. And once the basics are in place (again, they're getting there but not yet), why wouldn't that ecosystem develop of it?

comment 5y ago · link · parent

I agree that support for VoiceOver (and other assistive technology) and full support for keyboard shortcuts is essential for a production GUI toolkit. We certainly don't do those yet, but I do think we can get there.

Rust makes it easier to bind platform capabilities at a low level than most other languages. As an example, we do cut'n'paste cross-platform, supporting complex media types, not just plain text, so we can round-trip a vector glyph from Runebender to other font editors. I think that's a taste of being able to take on these more ambitious challenges.

Also, "native" UI toolkits are a lot less actually native than they used to be. On Windows, the old HWND-per-control and GDI drawing model (long considered the standard for "native" Windows UI) is long obsolete, and there are actually a whole bunch of toolkits that people use, with UWP the most actively supported. Apple has a stronger story, but even there you have AppKit + SwiftUI, and technically Catalyst is officially supported, though nobody would argue it's actually a good experience.

And the fact is, a lot of people are using Electron, because it actually solves the business problem of delivering good-enough UI. I think we have a good shot at competing against that niche, and also that building it on Rust is a more solid foundation than any other language ecosystem.

comment 5y ago · link · parent

I'm not sure what you mean by posting just this link. But I'll repeat what I've been saying for a while. The Rust ecosystem is making significant advances toward building what I believe will be a world class GUI toolkit, but we do not yet have a mature, usable solution, and getting there will take time. There are no shortcuts either, though it is possible to get something working by lashing together existing pieces.

I obviously consider Druid to to be one of the most promising approaches, but even that aside there are other projects that could become a solid GUI toolkit, including Iced. I also encourage people to look at Makepad, as it does a lot of innovative things and emphasizes priorities such as small binary size and fast compile time.

comment 5y ago · link · parent

Thanks! Did you know that it's now a 2-axis variable font, with large ranges on both width and weight? Check it out on Google Fonts.

And also thanks for the kind words about my writing. I consider education to be a pretty big part of my personal mission, and take care to write clearly, explicitly trying to minimize controversy and misunderstanding (if you optimize for clicks or number of comments, it often takes you in a different direction). And sometimes my blog posts take a long time to gestate. "The compositor is evil" was 18 months from concept to publication, 11 of which were in my private repo. It's nice to hear that people appreciate the effort.

comment 5y ago · link · parent

Thanks! I had a great conversation with Mario Carneiro a couple weeks ago (I hope he doesn't mind me mentioning that), but sadly, I think I'm going to have to lay some of my research interests down, at least for now, to have more focus for my other ambitious research interests.

I'll not speak to OSS generally, as I'm sure other people have more insight than I do, but specifically within the Rust ecosystem, I can confidently predict corresponding numbers increasing significantly.

comment 5y ago · link · parent

I can't wholeheartedly recommend anything right now. There should be a standard text layout library with pluggable back-ends, but there isn't. If you go to the #text stream on xi.zulipchat.com, there's a lot of discussion under the "Skribo: lifting the curse" topic and a couple others.

It's definitely possible to build something yourself using Allsorts and other pieces, but making it all work well is a highly nontrivial task. Part of the problem is that there are a bunch of projects out there, each with their own subset of requirements, rather than one good one.

I'd like to mentor work to make this situation better, but it's too much for me to take on single-handedly.

I'm also hoping that WebGPU catches on, and we'll be able to run piet-gpu on it (through wasm). That would, I think, be compelling for a lot of interesting use cases.

comment 5y ago · link · parent

No worries, it's all good.

I wrote about this a bit in a sibling comment, but making piet-gpu real is a major goal and probably the main reason I got the gig. It's speculative in some ways because it's trying to do things in a new way, but if it works out as well as I hope, it's pretty easy to see why it's worth doing.

comment 5y ago · link · parent

Watch this space!

comment 5y ago · link · parent

So this is work in the pipeline, and there's a bunch more polishing that's needed, but I will definitely be writing more about it soon, and I hope that will answer your questions.

But I'll give a brief teaser here anyway. The new spline is a hybrid between Spiro and cubic Béziers, with (I hope) the best features of both. Spiro is good for smooth curves but not so good when you need to crank up the tension. Béziers, by contrast, can do tension just fine, but aren't very smooth (one technical manifestation is that curvature maxima tend to happen near the segment endpoints, but rarely on them, especially for S-shaped curves).

Something that's particularly difficult for Béziers is a smooth transition from a straight line segment into a curve, which is important for U-shaped letters. Unless you take special care, the curvature jumps right up to some nonzero value at the join point. But with the new spline, it's continuous by default, unless you explicitly drag the control handles to make it not so.

It's difficult for people to learn to draw well with cubic Béziers, but obviously people climb that learning curve (so to speak) and get great results. Even so, I wonder if there's a bit of Stockholm syndrome, of being attached to that way of working just because of the amount of pain that's gone into the process of learning it.

comment 5y ago · link · parent

Thanks for the kind words. It will not be, as work on Druid is very much in scope for my new role. And I'm especially excited about Piet, as I think I've basically figured out how to get next-gen performance out of GPU rendering, and think a good 2D rendering engine is an essential piece of infrastructure needed for Rust GUI.

comment 5y ago · link · parent

I really didn't expect this to be posted here, it's just a job change, and not even that big of one, as my work on Druid and Runebender was getting financial support from Google Fonts already. I sometimes wonder if I posted my shopping list whether it would make the HN front page. (Ooh, I see Impossible burgers, let's have a discussion about that)

But as long as we're here, feel free to AMA, and I'll do my best to answer.

comment 5y ago · link · parent

I think these will emerge organically in time, but I think to really exercise the power of piet-gpu in particular, we'll want to see apps that display or visualize huge amounts of data. I'd love to see scientific visualizations.

comment 5y ago · link · parent

I've put some thought into this question, and there's some flexibility - it's possible to take the basic ideas and put more work into compatibility to work on even more hardware, but that's a cost/tradeoff curve, and affects overall system complexity and especially the difficulty of extending the imaging model.

My current target is a GPU that can do compute shaders, and also has descriptor indexing. That includes DX12, Metal 2.0, and most desktop Vulkan. It leaves out DX11 and OpenGL. Mobile is complicated; I don't expect it to work on most legacy Android devices.

The need for descriptor indexing can be worked around, which I think in practice brings Android with Vulkan back in the fold, and it's possible DX11.

It's more a function of API and driver than actual hardware, except for very old and low-spec stuff. I suspect that Raspberry Pi up to 3 is off the table without massive work, but that Vulkan drivers on the 4 will catch up. (I have a Raspberri Pi 4 and intend to use it as a compatibility target, along with a Pine64)

I hope that clarifies the situation. GPU compute was not mainstream at all (aside from CUDA, which has been around a while) and until quite recently, targeting it would seriously limit an app. I do think that's changing, even on inexpensive hardware.

comment 5y ago · link · parent

As I posted to a similar request, this is an arcane field, and different things are meant by 2D - in games, it's largely painting sprites from sprite sheets, I think of it as involving vector graphics, and there are other contexts.

I think a good blog post that motivates some of the main differences between 2D and 3D in the GPU context is this one: https://blog.mecheye.net/2019/05/why-is-2d-graphics-is-harde...

comment 5y ago · link · parent

Unfortunately, both 2D graphics and the programming of Vulkan compute shaders are very arcane topics, and the intersection of the two basically maxes out.

For GPU programming, I have a list of resources here: https://raphlinus.github.io/gpu/2020/02/12/gpu-resources.htm..., and also a talk here: https://www.janestreet.com/tech-talks/a-taste-of-gpu-compute...

Re 2D graphics, a long term ambition of mine is to write a book on the topic (and I have a repo started with a rough, bullet point outline), largely because I don't know of any source that brings the concepts together. I don't think I'll be able to spend significant time on it, though, as I have my hands pretty full. I am hoping to do more explaining and public communication as part of my piet-gpu work.

A good snapshot of GPU font rendering work from 3 years ago is: https://aras-p.info/blog/2017/02/15/Font-Rendering-is-Gettin... . The linked papers are quite good and have informed my thinking, though of course I hope to advance the state of the art even further.

comment 5y ago · link · parent

This is a good question, and I'm well aware of the broad scope of my projects, especially spanning low to high level.

A few things might help put this in context. First, Druid well predated Runebender, though Runebender is now the "hero app" (before, it was xi-editor, now on the back burner).

Second, I have a lot of experience doing high performance 2D and font rendering, from libart to working on the PDF 1.4 blend modes in Ghostscript to font-rs. I've also been curious about GPU for a while, not least because that was what was actually painting the text on Android, and I worked on the Android UI team for almost 5 years. So now that GPU compute is becoming mainstream, I see an almost unique opportunity to apply my skills there.

Third, I'm not doing all this by myself. I'm deliberately trying to cultivate open source community involvement and, really, building a team, though it has diffuse borders. Now is also a good time to acknowledge my long-time collaboration with Colin Rofls, who does a huge amount of the day to day work on both Runebender and Druid.

Lastly, I published this in advance of a career move, which is becoming a research software engineer on the Google Fonts team. I believe this is a perfect position for me to continue pushing this research agenda forward, and I'm hoping will bring more resources and focus.

There is no chance of me getting bored doing this. Burnout is something I'm watching carefully, as I have experienced it (it was the end of my time on Android), but one thing I discovered in my 2.5 years away from being a full-timer at Google is that graphics research is what I love the most, and would probably be doing even if it wasn't also a good career move.

comment 5y ago · link · parent

It's a link from the word "bogus."

I'm going to expand on this a bit, possibly against my better judgment. I believe Paul Graham has a point here, and it's a good one. In intellectual pursuits, there's a spectrum from dealing purely with nature and facts, to dealing with human perceptions. To pick what I hope is a reasonably neutral example, doing the science to get containment of a fusion reaction is on one end of the spectrum. Planning and engineering a project to do it is in the middle. And making the case that carbon-based energy production poses an existential threat to humanity and that we should be investing hundreds of billions into fusion energy is on the other. All these inform each other, and I (personally) don't make a value judgment on which is most virtuous or most important.

The salient thing is that Paul Graham did not choose a somewhat neutral example. Rather, he chose one that is perhaps at the very center of the culture wars, and has done so using a highly emotionally loaded word. Because he is someone who knows how to use words, I can fairly confidently conclude that he is effectively declaring his position on the issue.

comment 5y ago · link · parent

Congrats on the promo! It didn't quite retain me either, but I was a lowly staff software engineer. I am returning to Google though (back to the Google Fonts team), and it's entirely possible we'll get a chance to work together again.

comment 6y ago · link · parent

This is a pretty deep topic. The best resource I've found is: https://fgiesen.wordpress.com/2011/07/09/a-trip-through-the-...

I'll also do my best to answer your questions, though I won't be able to do them justice in this space.

A pretty good model for GPUs is remote procedure calls. When you want to do something like draw some triangles, you call a function in the GL API on the client side, and what the driver actually does under the hood is serialize the parameters of that call into some binary sequence, then at some point that "command buffer" is uploaded to the GPU, and a combination of hardware and software on the GPU side decodes it and uses it to set up the hardware pipeline that actually draws a triangle.

There's a lot more to it than that, obviously. A very big deal is that if you did an actual RPC for every triangle draw, it would be hopelessly inefficient. So a large part of what OpenGL drivers do is use heuristics for batching up a bunch of calls into one actual request. In OpenGL, the details of that batching, and the way the command buffer is encoded, are completely hidden from the application.

Shaders are basically small pieces of code that get run on the GPU hardware as part of the rendering pipeline. A vertex shader is a program that gets run every vertex in a mesh, and a fragment shader is another program that gets run for every fragment (pixel) that gets rasterized. There are other shaders that are run for other tasks, but those are the two biggies. In the early days of OpenGL, lighting calculations and so on were done by "fixed function" hardware, but these days it's programmable.

In classic OpenGL, you call a function to compile a shader from a string containing GLSL source code, and the driver compiles it to machine language for the GPU hardware. You can use Radeon Shader Analyzer (available online at http://shader-playground.timjones.io/) to see what that assembly language looks like.

Even just to understand OpenGL better, it might make sense to learn about Vulkan. A good (though somewhat daunting) resource is "API without Secrets: Introduction to Vulkan": https://software.intel.com/content/www/us/en/develop/article... . In Vulkan, the batching and other aspects of resource management are much more explicit and under control of the application, though other details are still abstracted by the driver. For example, there is no one standard binary format for encoding command lists. Also, instead of the driver compiling shaders all the way from source, the application is responsible for compiling the shader into an intermediate language (SPIR-V), then the driver compiles that to the actual GPU machine language.

There are some other low level GPU resources here: https://raphlinus.github.io/gpu/2020/02/12/gpu-resources.htm...

Best of luck, I find GPUs to be a fascinating journey!

1
333435
63