GNOME Bugzilla – Bug 340134
pango_layout_set_text_static
Last modified: 2017-08-31 23:06:23 UTC
Implement it. It should not copy text, unless absolutely necessary (text not valid, not nul-terminated.) We may change Pango to not require nul-termination, so we don't have to copy text in _static if length >= 0. The only remaining problem would be that then pango_layout_get_text will not necessarily return a nul-terminated string. But that's Ok if the input text wasn't nul-terminated. We may then want to add a pango_layout_get_text_len().
I think it is troubling that users must know the text is static or dynamic when they call pango_layout_set_text( ) or pango_layout_set_text_static( ).
No LingNing. This is not confusing. Users can still use pango_layout_set_text() as they were doing. The _static() version on the other hand is used if the text passed in will be available and not change during the life cycle of the layout, and so doesn't need to be duplicated.
Created attachment 66812 [details] [review] my patch I wrote a patch for this bug. But I think this patch need to modify. I think that "free(old_text)" will be modified and the struct of PangoLayout will be added a member about "guint static_text".
Created attachment 66888 [details] [review] modified patch I modified my patch for adding a member of PangoLayout and the codes about this member. And my thought in this patch is that we need copy text in pango_layout_set_text_static( ) if length > 0. I think that it has some problems if we don't copy text in pango_layout_set_text_static( ) when length > 0. And will it have some trouble if users call pango_layout_get_text( ).