We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 1088 - Broken cache of glyphs [patch]
Summary: Broken cache of glyphs [patch]
Status: RESOLVED FIXED
Alias: None
Product: SDL_ttf
Classification: Unclassified
Component: misc (show other bugs)
Version: 2.0.10
Hardware: All All
: P2 major
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-11 22:38 UTC by Peter Kosyh
Modified: 2011-03-01 01:09 UTC (History)
0 users

See Also:


Attachments
Patch (1.21 KB, patch)
2011-01-11 22:40 UTC, Peter Kosyh
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Kosyh 2011-01-11 22:38:59 UTC
It's like that cache of glyphs works only with symbols with codes <= 255. Se the code in SDL_ttf.c:

static FT_Error Find_Glyph( TTF_Font* font, Uint16 ch, int want )
{
	int retval = 0;

	if( ch < 256 ) { /* here it is. very strange approach! */
		font->current = &font->cache[ch];
	} else {

It is too bad, because leads to very high cpu load on slow machines. Here is a tiny patch, that makes cache more clever and speed up non english languages rendering about 50 times in my project (build wince, s60, android).

The idea is trivial:
static FT_Error Find_Glyph( TTF_Font* font, Uint16 ch, int want )
{
	int retval = 0;
	int hsize = sizeof( font->cache ) / sizeof( font->cache[0] );

	int h = ch % hsize;
	font->current = &font->cache[h];

	if (font->current->cached != ch)
		Flush_Glyph( font->current );


I hope (it is too hard to support own version of SDL_ttf), you will include this patch, or i can write more clever cache logic (built on list/hash).
Comment 1 Peter Kosyh 2011-01-11 22:40:00 UTC
Created attachment 552 [details]
Patch

Forgotten patch attached. :)
Comment 2 Sam Lantinga 2011-02-28 15:00:04 UTC
I'm looking at the possibility of bundling SDL_ttf with the commercial
license option for SDL 1.3.

Do you give me permission to release your contributions to SDL_ttf
under both the LGPL and a closed-source commercial license?

Thanks!
Comment 3 Peter Kosyh 2011-03-01 00:19:13 UTC
(In reply to comment #2)
> I'm looking at the possibility of bundling SDL_ttf with the commercial
> license option for SDL 1.3.
> 
> Do you give me permission to release your contributions to SDL_ttf
> under both the LGPL and a closed-source commercial license?
> 
> Thanks!


Yes, you can use this patch as you want.
Comment 4 Sam Lantinga 2011-03-01 01:09:20 UTC
Thanks, your patch has been added!
http://hg.libsdl.org/SDL_ttf/rev/a6e04cc57348