AriZuu / ttf2ugui

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

Enhancements #6

Closed deividAlfa closed 3 years ago

deividAlfa commented 3 years ago

Add minchar and maxchar options to the help, use utf-8 for output chars, enhance the formatting details. I know uGUI doesn't support UTF-8 yet, but the ability will be there.

Example help:

./ttf2ugui.exe
ttf2ugui {--show text|--dump} --font=fontfile [--dpi=displaydpi] --size=fontsize [--bpp=bitsperpixel] [--minchar=charnumber] [--maxchar=charnumber]
If --dpi is not given, font size is assumed to be pixels.
Bits per pixel must be 1 or 8. Default is 1.
Char numbers use unicode or ascii encoding in decimal representation (ex. 'a' = 97 ), default is 32-126.

Example output, ASCII range:

static __UG_FONT_DATA unsigned char fontBits_arial_6X6[59][6] = {
                                    // Hex     Dec   Char (UTF-8)
  {0x00,0x06,0x06,0x06,0x09,0x00 }, // 0x41    65    'A'
  {0x00,0x07,0x05,0x0B,0x07,0x00 }, // 0x42    66    'B'
  {0x00,0x0F,0x01,0x01,0x0E,0x00 }, // 0x43    67    'C'

Example output, UNICODE range:

static __UG_FONT_DATA unsigned char fontBits_arial_6X6[64][6] = {
                                    // Hex     Dec   Char (UTF-8)
  {0x00,0x04,0x1F,0x15,0x0D,0x06 }, // 0x444   1092  'ф'
  {0x00,0x00,0x03,0x02,0x05,0x00 }, // 0x445   1093  'х'
  {0x00,0x00,0x05,0x05,0x05,0x02 }, // 0x446   1094  'ц'
AriZuu commented 3 years ago

Merged, thanks a lot for contributing !