Re: [AD] al_font function names

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Elias Pschernig wrote:
I don't like the names of these 8 function now in the renamed version:


Anyone disagrees with any of it? If it was too much to read, the separate points are in short:

- function name is "draw_text" instead of "textout"

- for substrings use (string, start, end) instead of (string, count)

- no more centre/right versions

- append a single "f" for the formatted version like with al_ustr_new[f]

# al_textout
# al_textout_centre
# al_textout_justify
# al_textout_right
# al_textprintf
# al_textprintf_centre
# al_textprintf_justify
# al_textprintf_right

If I compare to:

void al_draw_bitmap(
    ALLEGRO_BITMAP *bitmap,
    float dx, float dy,
    int flags)

and

void al_draw_line(
    float x1, float y1, float x2, float y2,
    ALLEGRO_COLOR color,
    float thickness)

Maybe we should have:

void al_draw_text(
    ALLEGRO_FONT *font,
    float x, float y,
    int flags,
    char *text,
    int start, int end)

To replace the first tree. The flags parameter would work like for al_draw_bitmap, pass 0 for default behavior and else a combination of flags for horizontal/vertical alignment (both horizontal and vertical alignment are trivial to do though, so not sure we even need flags for it).

About the count parameter, the two reasons for it were non-0-terminated strings and printing of sub-strings. The first one is an invalid argument (many Allegro functions expect strings and they have to be 0 terminated, no reason to special-case al_draw_text). And the use of count for substrings is much easier to achieve if start/end are specified instead of a count, e.g. to print "leg", compare:

al_draw_text(font, x, y, 0, "Allegro", 2, 5)

vs the same with the current count parameter:

ALLEGRO_USTR *str = al_ustr_new("Allegro")
al_draw_text(font, x, y, 0, "Allegro, al_ustr_offset(str, 2), 3)
al_ustr_free(str)

al_draw_justified_text would simply have another x parameter and no flags (or we could leave in flags in case we want more than just alignment flags in the future).

The last four functions probably could be something like "al_draw_formatted_text", but that's even uglier than "al_textprintf", so I was thinking maybe just "al_draw_textf" (compare with al_ustr_newf where just an f is appended for the formatted version as well):

void al_draw_textf(
    ALLEGRO_FONT *font,
    float x, float y,
    int flags,
    char *format, ...)


--
Elias Pschernig <elias@xxxxxxxxxx>




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/