Further you may need a bitmap fallback for high scales. It produces better results, but is more complex and less performant than SDFs. Vector rendering seems to be popular lately. It may be worth investigating if its possible to generate an MSDF from a bitmap. For MSDF there is that one project, but its not that actively maintained, so at this point it may be a liability. In terms of dependencies, to create SDF we can get away with just FreeType to create the bitmaps, plus steal some code from vispy to generate the SDF. We’d need tests to visually judge what glyph sizes are needed in both approaches. Whether this is true depends also on the complexity of the glyphs - it has been reported that it does not provide much advantage for e.g. MSDF seems like a very interesting extension that may make it possible to create better results with smaller SDF sizes. SDF rendering already provides pretty solid results and is widely used. Unless I’m mistaken, they use the GUI backend to render text. The SDF glyphs are packed into an atlas texture, and rendered using regular SDF rendering. The code to list and load fonts is platform specific. It can use most fonts installed on the system. The bitmap is then converted to an SDF using either the GPU or Cython. It first gets a glyph bitmap using FreeType (via Rougier’s FreeType wrapper) on Windows and Linux, and Quartz on MacOS. When rendered, the glyph is sampled using a smoothing kernel, giving reasonable results at multiple scales.įurther, visvis includes a mini-SDL to create bold, italic, and math symbols using escaping with backslash. The rendered glyps are on a fixed resolution and put in an atlas texture. Further, it can make use of other fonts installed on the system. Visvis also ships with FreeSans, so there is always a good sans font available. If FreeType is not available, visvis falls back on system that uses pre-rendered fonts. Freetype is available by default on Linux, on Windows it must be installed. Visvis produces glyphs on the fly using FreeType. How do other libs do text rendering? How visvis does text A disadvantage (for us) is that it needs multiple passes, making it harder to fit into our renderer, I think. Also see Slug, which looks pretty neat, but is not open source and covered by a patent.Īlso see this fairly simple approach: It uses a prepass to calculate the winding number for the rough shape, then composes the final shape and applies aa in a fragment shader. each cell is one glyph) then this may be a feasible approach for a dynamic context like ours. If this can be changed to create an atlas (i.e. This approach seems to require some preprocessing to divide the bezier curves into cells. It’s also possible to render the Bezier curves from the glyphs directly on the GPU. It’s not well documented, but is by the author of Harfbuzz … Vector rendering The Glyphy C library converts bezier curves to arcs and then calculates the signed distance to those arcs in the shader, producing better results than normal SDF. The fragment shader is changed only slightly, causing just a minor performance penalty. It produces better results than normal SDF, at a smaller scale. The key contribution is that directional information is encoded too, making is possible to produce sharp corners. MSDFĪround 2015, Viktor Chlumsky published his Master thesis, in which he proposes a method for a Multi-channel Signed Distance Field (MSDF). The current industy standard seems to be anti-aliased euclidian distance transform. There are variations on the way to calculate an SDF. This was a big step in games, but also for generic visualization. This approach makes it possible to create a special kind if bitmap (which encodes distances to the edge instead of a mask), that can then be used to render that glyph at any scale and rotation. In 2007 Chris Green from Valve published an approach that uses scalar distance fields (SDF) to render glyphs. All glyphs in use are put into an atlas: a large image/texture that has all glyphs packed together.Ī downside is that the bitmaps should match the screen pixels, so the bitmaps are font-size specific, and rendering glyphs at an angle is not possible without degrading quality. Historically, fonts are rendered using glyph bitmaps that match the screen resolution. We could leverage the text support of e.g. Methods to render text Leveraging a GUI toolkit
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |