Open mosra opened 8 years ago
New tech just keeps appearing: https://github.com/Chlumsky/msdfgen
Color emoji in OTF fonts: https://github.com/googlei18n/color-emoji, https://github.com/googlei18n/noto-emoji Yay!
Safe-to-break API appearing in HarfBuzz: https://github.com/behdad/harfbuzz/issues/224
Also for inspiration to get more creative with text rendering: https://www.youtube.com/watch?v=q3ROZmdu65o (found from there https://news.ycombinator.com/item?id=10824989 )
Also another one https://github.com/behdad/glyphy - Vector based SDF
Another article on rendering using vectors instead of bitmaps https://medium.com/@evanwallace/easy-scalable-text-rendering-on-the-gpu-c3f4d782c5ac#.gdsqful7b
@ytain wow, that vector rendering is really neat! Knew about Glyphy but forgot to add it. Updated the list, thank you!
stb_truetype
font plugin merged: https://github.com/mosra/magnum-plugins/pull/12
More emoji fonts: http://emojione.com/, https://github.com/Ranks/emojione/tree/master/assets/fonts
@mosra I've been using stb_truetype, but will we ever get an AnyFontImporter or something?
@Alicemargatroid there's currently not much use of AnyFont
-like plugin, because the engine supports mainly just the TTF format.
I think you might want to use the TrueTypeFont
plugin alias -- it maps to StbTrueTypeFont
, FreeTypeFont
or HarfBuzzFont
based on which one of them is available, so then you don't need to bother about particular plugin implementation in you app.
Qt has a nice new tool for generating distance fields, appending them to the original TTF/OTF file: https://blog.qt.io/blog/2018/10/10/introducing-distance-field-generator/ Support for such files (and ability to generate compatible files directly with magnum-fontconverter
) could be very beneficial.
Progress:
The text rendering library didn't age well and while trying to use it for the upcoming UI library (mosra/magnum-extras#2, not there yet) I got really angry at the shameful state of it. My previous job revolved around text a lot and, while this library was the prototype that I built upon, the actual real-world text rendering needed a lot more flexibility than what's provided here. Putting this braindump here before it fades away completely.
If somebody wants to tackle one of these things, I will be glad to help you and suggest a direction.
Things that are shitty and need to be fixed ASAP
0 1 2 0 2 3 4 5 6 4 6 7 ...
over and over again.GL
suffix to make room for Vulkan, WebGPU, etc. implementationsstd::vector
every time we need some array with size known in advance -- 568a4205a66da527547e4afd15274bfcd905ae5f, ab8dc070c4f20405b4535dbcbf84de03306870b1, 2692ff216c91fb774a8bcbe96c02419066b06d0c...Things that need to be improved/fixed before going further
initialize()
function is broken by design: initializing HarfBuzz plugin after FreeType will callFreeTypeFont::initialize()
second time, finalizing HarfBuzz plugin will callFreeTypeFont::finalize()
even though FreeType plugin is still used and thus breaks it. -- mosra/magnum-plugins@217832f73837512dd6a97c2edcd19c452ca6df83TextureTools::distanceField()
, ensure that it doesn't have artifacts on older platforms, ensure that it works even on GLES and WebGL -- done in 209cdbcd050b7cdc76f58638cc99230a1d301351, 2e4beb361c3a23692722454cc2dfb28ffe980ff1 and 8ba2cac0eef024774cae2bac9cf213eaea5de2bbText::GlyphCache
andText::DistanceFieldGlyphCache
-- 82691fcd50219a379adc81a7a6f9607fba6c7489Making the renderer usable with real-world text and font features
Having automatic font fallback would make the engine better than 90% of competitors.
TextureTools::Atlas
functionality -- 66bf0b264dd90887f2d3cbbc6e2c719692dd4fd1Image::slice()
that operate withPixelStorage
parameters so we're able to upload image subdataTextureTools::distanceField()
-- ada0645f3476301fe3a0da4602e999dec31392bd, abf8a759f26c305dbf0babf754dd2467b58add67, a2554cb65612522c6ab9b674f8f02a01931c46f7Switching fonts based on special Unicode control characters (or, if there are none, using the private plane for it)wouldn't be able to use the shaping context that way, has to be a separate streamTexture2DArray
for the glyph cache instead ofTexture2D
so we can fit also big alphabets inside. And somehow make it optional or backwards compatible with GLES2 / WebGL 1 that doesn't have them.GL
suffix, to make room for Vulkan, WebGPU etc. implementations -- 42342cd3a533632ae9b1d5fb7cde7e8343bfe32aAbility to use cubemaps? Could help on ES2 platforms, it's not an array but it's 6x times as large as a 2D texturenobody cares about ES2 nowadays anymoreaddVariant(size)
/removeVariant(id)
and then using that variant ID increateShaper()
?findFont()
(and third toaddFont()
)vec4(dot())
of the pixel value is usedImproved text rendering capabilities
Unicode-aware text shaping
Make HarfBuzz the go-to solution on all platforms instead of trying to emulate it poorly using other libraries. Works on Linux, should "just work" on OSX, I was able to compile it for Windows using CMake. What about Android? iOS? Emscripten?No. Instead broaden the API to make it possible to fully control HarfBuzz from it while still making it possible to use stb_truetype or plain bitmap fonts where advanced shaping isn't neededAbility to autodetect these in the shaper (http://unicode.org/reports/tr24/ -- I read through it and implemented it, but most of it faded away already. HarfBuzz somehow exposes this in the API so one could maybe take it as a starting point.)Just let HarfBuzz do that on its own.Improved text editing capabilities
For the UI.
Plugins
stb_truetype
to make the usage easier on platforms that don't "just have" FreeType (mosra/magnum-plugins#12)MagnumFont
FreeTypeFont
StbTrueTypeFont
StbTrueTypeFont
to make it less blurry and differing in sizeAnyFont
so one can just not care about which plugin is getting usedOpenTypeFont
alias -- mosra/magnum-plugins@2c36ec45d77e97c16d31a391cf05ae6e0f453615Tools
magnum-fontconverter --info
, like is already done for images and scenesHarfBuzzFontConverter
that implements whathb-subset
does)Shaders and rendering
Having the glyph cache completely on the GPU, passing just a list of glyph IDs and positions and leaving the rest on the shaderhugenon-negligible impact with large textMaking the renderer usable with BIDI
Specs: http://unicode.org/reports/tr9/
Direction autodetection based on script (easy)HarfBuzz does this implicitly as of 0782cdf5e0b2f588bdbde6aa139e9fcb556c5bdaAbstractLayouter
interface and expose it via pluginsAbstractLayouter
?