rds1983 / SpriteFontPlus

MonoGame/FNA Library that extends functionality of the SpriteFont.
MIT License
147 stars 33 forks source link

Feature Request: UTF-32 Support #2

Closed rds1983 closed 5 years ago

rds1983 commented 5 years ago

http://community.monogame.net/t/spritefontplus/11271/4?u=rds1983

willmotil commented 5 years ago

looks pretty good i posted up a rough draft of utf32 full c# string 4 byte unicode loading. Unfortunately that only really works with a separate renderer at the moment. However the changes to the loading itself can also be applied to spritefont but it just can't make use of them as it stores 16 bit chars and only one per glyph. I added a junky little buffered render class and used it to test.

The render mockup in it although its just scraped together and thrown in. It shows the basic changes spritebatch . drawstring needs to render unicode characters in the 4 byte smp plane character regions. I do have much better though old now set of rendering classes that really do function like spritebatch but they aren't as fast. Spritebatch has been optimized to death by everyone at this point.

http://community.monogame.net/t/spritefontplus/11271/2

rds1983 commented 5 years ago

You want those changes to be merged into SpriteFontPlus? If yes, can you make a PR?

willmotil commented 5 years ago

Like i made a lot of changes in that project even renaming classes. That spritebuffer isn't really suitable for anything but superficial testing.

It is your project i leave you to decide what to take modify or leave.

One other thing i couldn't seem to get the vertical position to line the letters up to the baseline. Do you know how to do that ?

rds1983 commented 5 years ago

One other thing i couldn't seem to get the vertical position to line the letters up to the baseline. Do you know how to do that ?

No, sorry.

willmotil commented 5 years ago

Ah i fixed it i forgot i rounded the y offset down and that moved the whole letter up.

Rds just wanted to let you know i think this is a great project ill probably start using it. It might even be possible to improve it for hinted text with simple raster line improvements as i have access to the pixel data as it loads.

When i make a more comprehensive spritebuffer ill let you know in case you would like to add it. The idea for the sprite buffer is actually pretty solid but its not refined yet. The idea is that most text doesn't change from frame to frame so instead of recalculating it each frame at all just buffer it up and keep redrawing it until it does. So i would only calculate some part of it that does change from time to time. So ultimately it will basically replace my strings altogether and should be much faster then spritebatch. I already have a no garbage StringBuilder here which can be used to get around all the garbage collections text can create if you use be aware of assigning with it like a string str = "a"+"b" + "c". will generate garbage. I only added that for when its not important like when used in a constructor. https://github.com/willmotil/MonoGameUtilityClasses/blob/master/MgStringBuilder.cs

rds1983 commented 5 years ago

I've added UTF-32 Support to DynamicSpriteFont. This sample demonstrates it in action: https://github.com/rds1983/SpriteFontPlus/tree/master/samples/SpriteFontPlus.Samples.DynamicSpriteFont image