void VbRenderTextAtPos(const char *text, int right_to_left, uint32_t x, uint32_t y, VbFont_t *font) { int i; ImageInfo *image_info = 0; void *buffer; uint32_t buffersize; uint32_t cur_x = x, cur_y = y; if (!text || !font) { VBDEBUG((" VbRenderTextAtPos: invalid args\n")); return; } for (i=0; text[i]; i++) { if (text[i] == '\n') { if (!image_info) image_info = VbFindFontGlyph(font, text[i], &buffer, &buffersize); cur_x = x; cur_y += image_info->height; continue; } image_info = VbFindFontGlyph(font, text[i], &buffer, &buffersize); if (right_to_left) cur_x -= image_info->width; if (VBERROR_SUCCESS != VbExDisplayImage(cur_x, cur_y, buffer, buffersize)) { VBDEBUG((" VbRenderTextAtPos: " "can't display ascii 0x%x\n", text[i])); } if (!right_to_left) cur_x += image_info->width; } }
FontArrayEntryHeader *eptr; uint8_t buf[sizeof(h) + sizeof(eh)]; VbFont_t *fptr; void *bufferptr; uint32_t buffersize; /* Create font data */ h.num_entries = ARRAY_SIZE(eh); Memcpy(buf, &h, sizeof(h)); eptr = (FontArrayEntryHeader *)(buf + sizeof(h)); Memcpy(eptr, eh, sizeof(eh)); fptr = VbInternalizeFontData((FontArrayHeader *)buf); TEST_PTR_EQ(fptr, buf, "Internalize"); TEST_PTR_EQ(VbFindFontGlyph(fptr, 'B', &bufferptr, &buffersize), &eptr[1].info, "Glyph found"); TEST_EQ(buffersize, eptr[1].info.original_size, " size"); TEST_PTR_EQ(VbFindFontGlyph(fptr, 'X', &bufferptr, &buffersize), &eptr[0].info, "Glyph not found"); TEST_EQ(buffersize, eptr[0].info.original_size, " size"); /* Test invalid rendering params */ VbRenderTextAtPos(NULL, 0, 0, 0, fptr); VbRenderTextAtPos("ABC", 0, 0, 0, NULL); VbDoneWithFontForNow(fptr); } int main(void)