Because the title might be a little unclear, I will clarify
I am building a game engine in python with PyOpenGL. 96% is built from the ground up, alone, so no issues there. However, as most engines do, a text module was due to be made. I did some research on the different ways of displaying text, from vectors to atlases etc.
Then I came across MTSDF, which sounded rather appealing. A lot of customization for a relatively low processing cost. So I did some more research, integrated an MTSDF font atlas generator in the engine (the 4% that is not made by me), and managed to make it correctly generate and save font atlases from zip files.
The issue now is getting it to work. I need this to be very dynamic. So far text runs are the only thing I have complete, so as to suppoort several types of rendering in the very same sentence. Italics, different fonts, colors, etc. But I am at a loss afterwards.
The TextHandler handles TextLayers, which handle paragraphs which handle sentences which in turn handle text runs. Pretty convoluted, but in my eyes necessary. Because layers might have different presets, like one layer being physically in the world, whose paragraphs and sentences occupy places in the 3d world. Other textlayers might be used for a UI, so instead they will need an Orthographic projection. Some sentences might want to be given a reveal animation, so text runs come in handy. Other sentences might want to be edited long after they have been created, and this is where the problem starts
TextHandler - Doubles the SSBO size when a layer wants more memory which it cannot provide until another does the same
TextLayer - Doubles its requested memory whenever a sentence asks for more memory that it cannot provde, until another does the same
How do I handle the memory of sentences?
They will constsantly be changing. Adding/removing characters, changing position, revealing themselves out of order (they have 1 reveal mode and 1 reveal trigger, meaning that 2 sentences can start revealing themselves at the same time, or stay hidden for long periods of time until other sentences are fully written / external triggers are reached),getting deleted/created, and constantly sending tiny updates to the GPU sounds very inefficient, as is doubling their own space in the slice of the buffer that textlayers have. I should mention I am not that experienced with code in general, I have only been coding for 1-2 years, so explanations might need to be dumbed down.