1. Anders Ruud
  2. love

Pull requests

#20 Merged
Repository
love-imagefont-improvements
Branch
default
Repository
love
Branch
default

UTF-8 image fonts and full 32 bit UTF-8 font support

Author
  1. Alex Szpakowski
Reviewers
Description

This pull request fixes a few font-related things:

  • ImageFonts can now handle UTF-8 strings passed to both love.graphics.newImageFont and love.graphics.print.

  • ImageFonts are no longer restricted to 256 usable glyphs.

  • Both image and truetype fonts can now handle all 4 bytes of unicode characters. Previously the code used unsigned short instead of unsigned int, which restricted usable UTF-8 characters to only 2 bytes.

  • ImageFonts no longer modify their source ImageData. Previously the ImageFont code would set the color of pixels in the source ImageData to transparent if the color matched the spacer color. The color modification is now applied to generated GlyphData instead.

This pull request resolves issue #373. The API and implementation changes required to resolve the other parts of issue #190 would probably need some discussion, so that'll have to wait for a different pull request.

A test .love demonstrating some of the changes is linked below. The glyph 'a' on the screen and in the ImageFont is represented by the character '𠜎' (4 byte UTF-8) in the Lua code. It might crash LÖVE sometimes in 0.8.0.

https://dl.dropbox.com/u/4214717/imagefonttest.love

Comments (0)