Unvanquished icon indicating copy to clipboard operation
Unvanquished copied to clipboard

vendoring font cleanup

Open ghost opened this issue 3 years ago • 5 comments

I think @illwieckz will be quite interested with this.

The game currently loads 8 .ttf files at start:

  • fonts/Roboto-Bold.ttf
  • fonts/Roboto-BoldItalic.ttf
  • fonts/Roboto-Italic.ttf
  • fonts/Roboto-Regular.ttf
  • fonts/fontawesome-webfont.ttf
  • fonts/DejaVuSansCondensed.ttf
  • fonts/MaterialIcons-Regular.ttf

I have serious doubts that all those fonts are actually used, so we can probably lazy-load some of the stuff there, for a start.

2nd, there's actually 13 files in that fonts/ folder, here they are with their sizes in bytes:

  • 643852 DejaVuSansCondensed.ttf
  • 141564 fontawesome-webfont.ttf
  • 107780 MaterialIcons-Regular.ttf
  • 134556 Roboto-BoldItalic.ttf
  • 127744 Roboto-Bold.ttf
  • 135504 RobotoCondensed-BoldItalic.ttf
  • 127340 RobotoCondensed-Bold.ttf
  • 133908 RobotoCondensed-Italic.ttf
  • 125332 RobotoCondensed-Regular.ttf
  • 132440 Roboto-Italic.ttf
  • 126072 Roboto-Regular.ttf
  • 269 roboto.ttf
  • 16336380 unifont.ttf

The RobotoCondensed files are never referenced anywhere AFAICT.

The roboto.ttf files contains this text:

I AM A DUMMY FILE

I'm working around a font/filesystem bug where an old Roboto Thin (found in the alpha 0.25 package) overrides the normal Roboto font. I do this by camping on it's filename (roboto.ttf) so it cannot load.

Veyrdite, 2014-07-31

(This is a bad hack)

Lastly, the bigger file (unifont.ttf) is 16 megs big, only loaded by engine, possibly for console. This is unifont, a huge font with as much as possible glyphs. While this might be ok (I'm not that sure tbh), I see some issues here:

  • it means daemon can not draw text in console if the .dpk have a problem. In my opinion, this file should be installed by the Updated along daemon itself, so that daemon would be more self-contained. This would also prevent this file to be decompressed at each map loading, and it represents ~50% of the decompressed archive;
  • it might be outdated. Unifont website says there's 4 truetype files: 2 are 12Megs big (japan/non-japan), others are much smaller (they complete the 2 1sts I guess). This should be investigated imo.
  • if the code can handle OpenType (.otf) files, we may want to switch, as those are 2 times smaller than .ttf files

ghost avatar Jul 13 '22 07:07 ghost

it means daemon can not draw text in console if the .dpk have a problem. In my opinion, this file should be installed by the Updated along daemon itself, so that daemon would be more self-contained.

The idea is to one day embed a dpk in the engine itself binary. There are other files that are actually needed by the engine but distributed by the game (meaning the engine is not standalone):

https://github.com/DaemonEngine/Daemon/tree/master/pkg/daemon_src.dpkdir

The files from there are copied from unvanquished_src.dpkdir, I did this folder in Dæmon's source tree so third-party games investigating a dæmon port can directly use -pakpath pkg to not need the unvanquished dpk. The hope is that one day that dpkdir is embedded in the binary the way we do with GLSL files.

illwieckz avatar Jul 13 '22 23:07 illwieckz

See:

  • https://github.com/DaemonEngine/Daemon/issues/71

illwieckz avatar Jul 13 '22 23:07 illwieckz

Unifont is specifically to ensure that any glyph can be displayed. Unvanquished supports any font format supported by freetype.

DolceTriade avatar Jul 13 '22 23:07 DolceTriade

I'm not sure we are going to do anything here.

DolceTriade avatar May 06 '24 18:05 DolceTriade

At least we can delete I AM A DUMMY FILE.

slipher avatar May 07 '24 04:05 slipher