Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Font Improvements #30

Open
embedded-creations opened this issue Sep 18, 2015 · 7 comments

Comments

Projects
None yet
4 participants
@embedded-creations
Copy link
Contributor

commented Sep 18, 2015

The fonts in SmartMatrix could use some improvements. I'm collecting a list of updates to make, please let me know if you have anything to add.

  • Only compile in fonts that are used by the Sketch. Also allow user to add their own font without modifying the library.
    • Have sketch refer to font by a pointer to the font object instead of an enum.
  • Consider switching from using bitmaps to more space efficient BDF, like PJRC's graphics library does
  • Support >8-pixel wide fonts
  • change bdf2c lookup table to use unsigned char instead of unsigned short
  • See Issue #47
@ecurtz

This comment has been minimized.

Copy link

commented Sep 18, 2015

int getBitmapFontLocation(unsigned char letter, const bitmap_font *font) searches through an array mapping font entries -> character codes. If this was changed to an array of character codes -> font entries then it's simply an array lookup, and the array can be unit8 rather than the current uint16. If the font contains more than 255 characters an offset and second array could be used, but that seems unlikely. The array would need to be as large as the highest char code, but that's not an issue for any of the current fonts, and it could have an initial skip for < 32 and other tricks if space was an issue.

@embedded-creations

This comment has been minimized.

Copy link
Contributor Author

commented Sep 18, 2015

@ecurtz Makes sense. I briefly looked at the font code and I think if we limit the fonts to a max character code of 255 (which they should be now), the array size can be changed to uint8_t, no major code changes needed. There's a couple fonts like Font_apple6x10.c that have >255, but I think that's just because I was manually trimming down the table in the early days and forgot to delete codes >255. Your method may have other efficiency improvements I haven't considered yet.

Before I spend any time improving the fonts I want to evaluate and try the code in the PJRC library as if there are substantial advantages I may end up replacing a lot of my code with Paul's code.

I have a number of other improvements that are ahead of Fonts, so I probably won't start working on this for a good while.

@yoonghm

This comment has been minimized.

Copy link

commented Feb 4, 2016

I worked on Unicode before by converting my own Chinese fonts. Depending the languages (Chinese, Japanese, Korean, etc). I did not complete that portion as I was having problem to locate the font bitmap quickly as the array is big. The existing code search the code linearly, which is fine for 255 characters but not for 65535 characters.

I suggest this

  • Use compile-time define to restrict the availability of fonts (uint8, uint16, uint32).
  • The compile-time define also define the appropriate alias data type that is used in various font accessing function.
@embedded-creations

This comment has been minimized.

Copy link
Contributor Author

commented Feb 8, 2016

@yoonghm Thanks for the suggestions!

@grene78

This comment has been minimized.

Copy link

commented Aug 17, 2016

Support for fonts > 8px wide is a huge one for me. Have you done any work on that, have any suggestions? I'd hate to pour time into that one if you're switching to BDF anytime soon.

@embedded-creations

This comment has been minimized.

Copy link
Contributor Author

commented Aug 20, 2016

@grene78 I haven't done any work on this yet.

@embedded-creations

This comment has been minimized.

Copy link
Contributor Author

commented Mar 30, 2017

Some work on >8px fonts posted on the SmartMatrix Community: http://community.pixelmatix.com/t/improving-fonts/205

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.