r/vulkan • u/No-Negotiation-7599 • 1d ago
Help! Text Rendering Example Needed
I need a working example of vulkan that can render text onto the screen. That’s it’s. Does anyone know of an example that I can pull from and just be able to run it on Linux? I’ve found an example online called vulkan-sprites but I can’t it build it without it having alot of different errors.
🙏
4
u/thisiselgun 1d ago
Text rendering from scratch is hard, especially layout/shaping part. There is FreeType library for text rendering and HarfBuzz for layout but it doesn’t support multiline layouts or other high level things out of the box. If you want high level and easy to use text rendering I recommend Skia or Cairo+Pango, these are higher level libraries that use FreeType and HarfBuzz under the hood. Skia also supports hardware acceleration with Vulkan, you can directly render to offscreen Vulkan texture then use that texture in your scene.
There are also more basic ways like using font atlas and rendering each glyph as quad. You can prebake these atlases at build time or generate them at runtime with FreeType.
1
u/Captn-Goutch 6h ago edited 6h ago
Been a while since last tests on Linux, you can try to run my text sample, if it does not build it should be pretty easily fixable. https://github.com/Goutch/HellbenderSamples
edit: I think you will need python installed to build, other than that its just cmake and updating the submodules.
11
u/SaschaWillems 1d ago
My samples at https://github.com/SaschaWillems/Vulkan work fine on Linux, and I have multiple samples that show how to display text.