How do you change the current font in ...freetype_int32 and/or font_cache_manager?

View: New views
3 Messages — Rating Filter:   Alert me  

How do you change the current font in ...freetype_int32 and/or font_cache_manager?

by Vinnie-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Dear Group:

I've got agg working lovely in my application. I'm using it to draw my entire user interface, including plenty of text in different fonts.

Problem is, I'm creating a separate instance of agg::font_engine_freetype_int32 and agg::font_cache_manager for each face and size combination. This can't be right...can it? When I step into the source code I see something about num_faces and max_faces and an array where it keeps multiple fonts cached, along with a signature that gets updated whenever an attribute that would invalidate the glyph cache is modified.

So apparently there is a bunch of code to let the font manager and cache manager remember multiple fonts, but where is the function to select which is the "current" font for drawing?

Thanks!


------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

Re: How do you change the current font in ...freetype_int32 and/or font_cache_manager?

by Lorne Laliberte :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> So apparently there is a bunch of code to let the font manager and cache manager remember multiple fonts, but where is the function to select which is the "current" font for drawing?

create_font() takes care of that.

Lorne Laliberte
Senior Software Developer, Indigo Rose Software

------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general

Re: How do you change the current font in ...freetype_int32 and/or font_cache_manager?

by Stephan Assmus :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

On 2009-04-11 at 11:44:10 [+0200], Vinnie <thevinn@...> wrote:

> I've got agg working lovely in my application. I'm using it to draw my
> entire user interface, including plenty of text in different fonts.
>
> Problem is, I'm creating a separate instance of
> agg::font_engine_freetype_int32 and agg::font_cache_manager for each face
> and size combination. This can't be right...can it? When I step into the
> source code I see something about num_faces and max_faces and an array
> where it keeps multiple fonts cached, along with a signature that gets
> updated whenever an attribute that would invalidate the glyph cache is
> modified.
>
> So apparently there is a bunch of code to let the font manager and cache
> manager remember multiple fonts, but where is the function to select
> which is the "current" font for drawing?

Lorne already replied what method to use.

I just want to add that if your application is multi-threaded, you have to
be careful with a global font/glyph cache! You cannot use the same
FT_Library handle from different threads. You have to add your own locking
around that. Ideally, you would read-lock when checking if glyphs are
already in the cache, and switch to write locking when you see it's not the
case for all glyphs in your string. Careful about the race condition when
switching lock types...

The font/glyph cache in the Haiku operating system is originally based on
the AGG code. If you want to have a look:

<http://dev.haiku-os.org/browser/haiku/trunk/src/servers/app>

Interesting are FontCache, FontCacheEntry and GlyphLayoutEngine, which does
the proper locking.

Best regards,
-Stephan

------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Vector-agg-general mailing list
Vector-agg-general@...
https://lists.sourceforge.net/lists/listinfo/vector-agg-general