Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode 16 bits runtime support #5

Open
marcos10soares opened this issue Feb 6, 2020 · 1 comment
Open

Unicode 16 bits runtime support #5

marcos10soares opened this issue Feb 6, 2020 · 1 comment

Comments

@marcos10soares
Copy link

marcos10soares commented Feb 6, 2020

At the time I didn't find a way to create text containing 16bits characters in runtime, so I modified the "libaria_string.c" file with the following function in order to support it.

Here it is just in case you might want to add it to the library:

laString laString_CreateFromCharBuffer16(const uint16_t* chr, uint16_t size, GFXU_FontAsset* fnt)
{
    laString str = { 0, 0, 0, 0, LA_STRING_NULLIDX };
    uint32_t i;
    
    if(laContext_GetActive() == NULL || chr == NULL)
    {
        laString_Initialize(&str);
        return str;
    }

    if(size != 0)
    {
        laString_Allocate(&str, size);

        if(str.capacity == 0)
            return str;

        for(i = 0; i < size; i++)
        {
            str.data[i] = (GFXU_CHAR)(chr[i]);
        }

        str.data[i] = '\0';
    }
 
    str.font = fnt;
    str.table_index = LA_STRING_NULLIDX;
    
    return str;
}
@microchip-gfx
Copy link
Contributor

This is a good submission. Thank you for posting.

As an FYI the newer Legato graphics library in Harmony uses 16 bit character strings by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants