BRT Community

Please login or register.

Login with username, password and session length
Advanced search  

News:

Welcome to the Bridgetek Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ Bridgetek Support

Please refer to our website for detailed information on all our products - Bridgetek - Bridging Technology

Author Topic: Custom Fonts  (Read 8264 times)

raydem

  • Newbie
  • *
  • Posts: 28
    • View Profile
Custom Fonts
« on: October 26, 2022, 09:03:37 AM »

Hello,
I am trying to use various custom fonts saved in RAM. I can draw with the font that I loaded first but not with the following ones. I guess the problem is the address to load the fonts. I use fonts converted and compressed with EAB 2.6.1. I am loading in RAM the raw file(.raw)

Code: [Select]

    #define EVE_RAM_G         0x00000000u

    FillDataLoadImage(0u, EVE_RAM_G, arial20_L2, sizeof(arial20_L2), INFLATE_IMAGE);   // index image, address in RAM, data, data size, format
    FillDataLoadImage(1u,  sizeof(arial20_L2), arial20_L4, sizeof(arial20_L4), INFLATE_IMAGE); // index image, address in RAM, data, data size, format

    Write32BitsInArray(start, CMD_SETFONT2);
    Write32BitsInArray(cont, (uint32)0u); //Font 0
    Write32BitsInArray(cont, EVE_RAM_G); // address
    Write32BitsInArray(cont, (uint32)32u); // first character

    Write32BitsInArray(start, CMD_SETFONT2);
    Write32BitsInArray(cont, (uint32)1u); //Font 1
    Write32BitsInArray(cont, sizeof(arial20_L2)); // address
    Write32BitsInArray(cont, (uint32)32u); // first character
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 745
    • View Profile
Re: Custom Fonts
« Reply #1 on: November 01, 2022, 04:57:07 PM »

Hello,

Thank you for your post.

As you mentioned, the problem may be due to the address the fonts are set to. Please could you tell me the address you set for the font? Would it also be possible to send an example of the converted font output folders for both, and the code used to display them? If preferred you can email these to our support address - support.emea@brtchip.com

For 'arial20_L2' in the code snippet below, is the size mentioned here for compressed or uncompressed(raw)?

Quote
    Write32BitsInArray(start, CMD_SETFONT2);
    Write32BitsInArray(cont, (uint32)1u);         //Font 1
    Write32BitsInArray(cont, sizeof(arial20_L2));   // address
    Write32BitsInArray(cont, (uint32)32u);      // first character

Naturally when you decompress the first font, the size will be bigger than the compressed file, meaning the second font address must be loaded after the end of the decompressed/inflated file of the first one. This may be why only the first font is working.

Best regards BRT Community
Logged

raydem

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: Custom Fonts
« Reply #2 on: November 04, 2022, 12:43:33 PM »

hello,
I use compressed fonts(both .zlib). The EveSetFont and EveCmdText are inside of the  commands List with their needed list commands.

Code: [Select]
   

//These are the parameters for SetFont (DisplayCustomFont_t struct)

    fontData[0].address = 0x00000000u;
    fontData[0].font = 0u;
    fontData[0].firsChar = 32u;
    fontData[0].format = EVE_L2;
    fontData[0].height = 21u;
    fontData[0].width = 26u;
    fontData[0].stride = 7u;

    fontData[1].address = 0x00010000u;
    fontData[1].font = 1u;
    fontData[1].firsChar = 32u;
    fontData[1].format = EVE_L4;
    fontData[1].height = 21u;
    fontData[1].width = 26;
    fontData[1].stride = 13u;

// This is for SetFont, executed twice (for fondData[0] and fontData[1])
Private uint32 EveSetFont(const uint32 start, const DisplayCustomFont_t* const data)
{
    uint32 cont;

    cont = Write32BitsInArray(start, BITMAP_SOURCE(data->address));
    cont = Write32BitsInArray(cont, BITMAP_LAYOUT(data->format, data->stride, data->height));
    cont = Write32BitsInArray(cont, BITMAP_SIZE(EVE_NEAREST, EVE_BORDER, EVE_BORDER, data->width, data->height));

    cont = Write32BitsInArray(cont, CMD_SETFONT2);
    cont = Write32BitsInArray(cont, (uint32)data->font);
    cont = Write32BitsInArray(cont, data->address);
    cont = Write32BitsInArray(cont, (uint32)data->firsChar);
    cont = Write32BitsInArray(cont, END());

   return cont;
}

// This is for display text
Private uint32 EveCmdText(const uint32 start, const GraphicText_t* const data)
{
    const uint8 *textPtr = data->string;
    uint32 cont;
    uint32 textindex = 0uL;
    uint8 StringLength = data->len;
    uint32 commandSize;

    cont = Write32BitsInArray(start, DL_COLOR_RGB | data->color);

    cont = Write32BitsInArray(cont, CMD_TEXT);
    cont = Write32BitsInArray(cont, (((uint32)data->y0 << 16u) | ((uint32)data->x0  & 0xffffu)));
    cont = Write32BitsInArray(cont, (((uint32)data->option  << 16u) | ((uint32)data->font & 0xffffu)));

    commandSize = cont;

    while (textindex < data->len) {
        gpDataBuffer[++cont] = (uint8)textPtr[textindex];
        textindex++;
    }

    if (0x00u != textPtr[data->len - 1u]) {   
        cont++;
        gpDataBuffer[cont] = 0x00u;
        StringLength++;
    }

    StringLength = StringLength & 0x03u; /* 0, 1, 2 or 3 */
    StringLength = 4u-StringLength; /* 4, 3, 2 or 1 */
    StringLength &= 3u; /* 3, 2 or 1 */

    while (StringLength > 0u) {
        gpDataBuffer[++cont] = 0x00u;                     
        StringLength--;
    }

    EveIncCmdOffset(FifoWriteLocation, (uint16)commandSize); // Update fifo write

    return cont;
}

« Last Edit: November 04, 2022, 03:40:22 PM by raydem »
Logged