AriZuu / ttf2ugui

Simple utility to convert TTF fonts into uGUI bitmap fonts.
111 stars 53 forks source link

show support utf8 encoded character #8

Closed joyhope closed 2 years ago

joyhope commented 2 years ago

the dump support Unicode characters, but the show is unable to support them. I added utf8 decoder so let the show also works.

thank you provide this tool.

AriZuu commented 2 years ago

Thanks for your effort and enhancements. Looks like most of your work is actually development to uGUI itself, with only minor changes in ttf2ugui.c. The ugui.c and ugui.h are included here as-is from uGUI project and it would be preferable to handle those changes there. The project used to live at http://embeddedlightning.com/ugui/ and https://github.com/achimdoebler/UGUI.

I'm not willing to provide an enhanced ugui here so please try to submit your changes to original project. After that I'm more than willing to accept proposed changes to my code in ttf2ugui.c.

deividAlfa commented 2 years ago

Please check my ugui & ttf2ugui forks for utf-8 support and other enhancements. (No need to reinvent the wheel)

AriZuu commented 2 years ago

Your fork looks COOL :-) Why here in PR is

UG_PutChar( UG_U16 chr, UG_S16 x, UG_S16 y, UG_COLOR fc, UG_COLOR bc );

and in your fork UG_PutChar( UG_CHAR chr, UG_S16 x, UG_S16 y, UG_COLOR fc, UG_COLOR bc );

Would be nice if the necessary files were completely same, ie. drop in from your fork to here.

I'll try to get my one of projects to compile with your version.

joyhope commented 2 years ago

I make merge. Whether it meets your requirement?

I found it is a useful tool to understand freetype.

AriZuu commented 2 years ago

What I was trying to understand why to create a special ugui.c for ttf2ugui instead of using ugui.c directly from your fork ? Would that be too big change ?

deividAlfa commented 2 years ago

You can't merge my forks, the original UGUI doesn't support UTF8 or Unicode, neither the new font structure allowing the whole unicode charset, font stripping, ranges... that's why I made my own forks, they're NOT compatible and won't be due the enhancements.

The main reason for the font structure change was because the original UGUI only supports sequential charsets, if you want '0' and 'Z', you must include all chars between them, wasting a lot of space. ASCII could waste up to 256 chars, but Unicode would require a crazy amount of storage to include "0-9"+any exotic char, thus I modified that. Ex. I can make a font with only "0-9" + "A-F" + '©'.

UGUI fork code is very different in many ways, had some issues while trying to make it work with ttf2ugui, so I ended modifying the original uGUI source, just modifying the essentials for Unicode/utf-8 support and the new font structure. To make it simple, the ttf2ugui fork always works in Unicode, as you know Unicode it's a 16-bit value, whether it's later being encoded/decoded as UTF8 doesn't matter, the final code will always be 16-bit, ASCII will work just fine.

I later kept working on UGUI, I'm not sure whether it will work now, but as it worked just fine and I was pretty tired, not having any bugs or issues, I left it there. It only has to make fonts, not displaying a gui... I know it's a little dirty!

AriZuu commented 2 years ago

Ok, sounds reasonable. I'll merge this now. Maybe later refactor ugui files into subdirectory with readme explaining what is going on.

Thanks again.

deividAlfa commented 2 years ago

I Just updated my comment, I don't know what you read, check it out!

AriZuu commented 2 years ago

Ok. Just merged PR #9 which moves uGUI files to subdirectory and adds a readme there.