freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ft-devel] PCF: Issues with lazy copy in `ft_bitmap_glyph_init'


From: armin
Subject: Re: [ft-devel] PCF: Issues with lazy copy in `ft_bitmap_glyph_init'
Date: Sat, 25 Aug 2018 18:34:42 +0100

>> Sure, no worries; you can find a tiny C function + build script 
>> attached.  Please make sure to build FreeType with `clang' and 
>> `-fsanitize=address' for it to work :)
>
> Thanks.  I see two possibilities to fix the bug.
>
> (1) Avoid lazy copying in `FT_Get_Glyph'.

How frequently is `FT_Get_Glyph' used and in which context?

> (2) Update the documentation:
>
>       By default, `FT_Get_Glyph' can be used only once.[*] If you want
>       more copies, use either `FT_Copy_Glyph' or call
>       `FT_GlyphSlot_Own_Bitmap' before calling `FT_Get_Glyph' again.

If I'm not mistaken, `FT_Glyph_Done' is still problematic in that case:

(1) if `FT_Glyph_Done' is NOT called, we (might?) end up with mem leaks, but

(2) IF it is called, the bitmap in the face's glyph slot gets erased
(something
    that is not expected IMO) and the whole loaded glyph cannot be used
anymore.

> What do you prefer?

This question is not targeted towards me (I think) but if the overhead of
properly copying the bitmaps is OK with `FT_Get_Glyph's current use cases
(do we have any statistics on API usage?), I would lobby for that outcome.
Esp. since `FT_Get_Glyph' has the potential of being something really
powerful ... however, the lazy copy makes it unintuitively and complicated
to use (beware: opinion!) ... then again, I currently use the API in
somewhat unconventional ways, other people might have other preferences
there.

>> I think the else (proper copy) condition is bogus.  If bitmap is not 
>> owned, it is not valid and you cannot copy it, which leaves us with 
>> lazy case only.
>
> Yep.  This must be fixed.
>
> [*] This statement is valid only for FT_GLYPH_FORMAT_BITMAP objects.
>     For FT_GLYPH_FORMAT_OUTLINE objects, FreeType always creates a
>     copy.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]