On Wed, 2023-12-13 at 22:15 -0800, John Neffenger wrote: > > There are some text animations in JavaFX that you won't see in most > user > interfaces: think text rotations, not stock tickers. It's difficult > to > keep text aligned to the pixel grid when the grid is rotating.
I don't buy this argument, having looked at the implementation. The key point is "keep text aligned to the pixel grid". The thing is: This isn't affected by hinting or the lack of it whatsoever, at least with the way text is implemented in Prism and Freetype, as far as I can tell. In the Prism/Freetype implementation, when the user wants to render the string "Hello World!", for each character in the string, a glyph is requested from Freetype. The contents of the returned glyph bitmap are packed into a persistent texture atlas on the GPU (the "glyph cache"). When actually rendering the string in the UI, the system constructs a set of polygons where each polygon represents one glyph, and each polygon is textured by having its UV coordinates mapped to the corresponding region of the glyph cache for the glyph. What this means is that it's entirely irrelevant whether hinting is used to produce the original glyph bitmap or not: The hinting just controls what pixels come out of Freetype before being written into the glyph cache. The system blindly selects a region of pixels from the glyph cache to be mapped onto polygons; it doesn't even know if those pixels were produced by a text rendering algorithm that used hinting or not. This argument _might_ apply if text was being directly software rendered to the screen, and the entire text was being re-rendered as full strings aligned to a screen-sized pixel grid every time. I could see in that case that an algorithm might produce output that varied on a frame-to-frame basis dependent on hinting. That's not the case here, though. Case in point: I've worked with a lot of OpenGL applications that do text rendering the same way, all of which used hinting, and all of which did heavy rotation and scaling of the resulting text as part of animations. Noone ever complained about jerky or weird text. In fact, most rendering engines these days don't even bother rendering text on a per-glyph basis; they just tell Freetype (or text library of choice) to render a full string into an image, with hinting, and that image is uploaded directly onto the GPU and displayed as a single textured polygon. Additionally, there are also techniques devoted to preserving sharpness and reducing other artifacts in the face of rotations. They're known as "fat pixel" shaders, and are trivial to implement: https://jorenjoestar.github.io/post/pixel_art_filtering/ They're usually discussed in the context of pixel art, but they work very well with text rendering too for the same reasons. -- Mark Raynsford | https://www.io7m.com