Font.renderGlyphs crashes (windows, neko)
I know that this is because of the body of renderGlyphs being commented out, I'd just like to know what the state of this is? Do we have to use renderGlyph instead?
I tried to update the renderGlyphs function myself (with the whole ByteArray -> Bytes thing), but with no luck.
fwiw, this is still an issue (on all platforms I'm pretty sure). Also, one of the examples that ships with lime does not work because of this. I would either recommend fixing the renderGlyphs function so that the original text rendering example works, or modify the example to render text in a supported way.
I tried using renderGlyph on each individual glyph and storing the results manually in the Map, but it outputs weird text.
There were a lot of improvements we were making to TextLayout, focused on OpenFL as the rendering layer. Font.renderGlyphs is working again, and the "TextRendering" Lime sample has been updated with minor fixes as well as Cairo renderer support as well :grin:
One followup question on this. Is there a supported way to render the glyphs to a single Image (i.e. a font atlas of some sort)? It would be useful on the OpenGL end to not have to switch textures each time a different character is rendered.
The only thing I could come up with off the top of my head was using the Image.copyPixels to merge all of the separate images into a single Image, keeping track of glyph positions/sizes in some kind of atlas.
Currently, Font.renderGlyphs can be used with a text string, it will render all the glyphs it finds in the string.
Long-term, it would be nice if this API allowed for ways to add extra glyphs to an existing texture. Happy to help if someone is interested in drafting an API or working on that
For ASCII, you could use Font.renderGlyphs ("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#$%&'()*+,-./:;<=>?@[\\]^_{|}~ ", fontSize)`, but it might be nice (also) to have an API for glyph ranges as well
Ah nice! That should work just fine for now.
So, followup on this. It looks like the example doesn't work for the html5 target (lime test html5). It complains with:
128WebGL: INVALID_OPERATION: vertexAttribPointer: no ARRAY_BUFFER is bound and offset is non-zero
128WebGL: INVALID_OPERATION: drawElements: no buffer is bound to enabled attribute
TextRendering.js:1358 Uncaught (in promise) TypeError: Cannot read property 'bitsPerPixel' of null
at TextRender.init (TextRendering.js:1358)
at Main.onPreloadComplete (TextRendering.js:1189)
at Array.f (TextRendering.js:26723)
at lime_app__$Event_$Void_$Void.dispatch (TextRendering.js:8119)
at lime_app_Preloader.start (TextRendering.js:7172)
at lime_app_Preloader.updateProgress (TextRendering.js:7256)
at lime_app_Preloader.loadedAssetLibrary (TextRendering.js:7165)
at TextRendering.js:7134
at lime_app_Promise.complete (TextRendering.js:7277)
at lime_utils_AssetLibrary.__assetLoaded (TextRendering.js:25026)
TextRendering.js:1408 WebGL: too many errors, no more errors will be reported to the console for this context.
In my own personal project, I specifically am running into problems with the TextLayout's positions array being empty, even when the TextLayout was created with a string on the html5 target. This can be verified in the TextRendering example as well by sticking a trace(textLayout.positions); right after one of the new TextLayout()'s. It shows up as an empty array for me on html5.
Is there something I might be missing? Otherwise, it seems like there might still be some work to be done here.
(On a side note, it appears that TextLayout doesn't do anything with newlines in terms of setting the y offset of glyphs, but this is a separate issue.)
The TextLayout API is only for native targets, at the moment, but I'm hoping we can migrate some of this logic over:
https://github.com/openfl/openfl/issues/1693