PersonalVotingMachine/basic-setup/components/u8g2/sys/sdl/text_kerning3/main.c
2020-12-22 14:30:09 +02:00

107 lines
2.2 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "u8g2.h"
#include <stdio.h>
u8g2_t u8g2;
const uint16_t my_kerning_table[] =
{
/* first char, second char, gap reduction value */
0x646, 0x627, 4, /* ن and ا */
0x627, 0x647, 5, /* ا and ه */
0x647, 0x62C, 6, /* ه and ج */
0x645, 0x627, 3, /* م and ا */
0x627, 0x644, 4, /* ا and ل */
0x644, 0x633, 2, /* ل and س */
/* this line terminates the table */
0xffff, 0xffff, 0xffff
};
int main(void)
{
int x, y;
int k;
int i;
u8g2_SetupBuffer_SDL_128x64_4(&u8g2, &u8g2_cb_r0);
u8x8_InitDisplay(u8g2_GetU8x8(&u8g2));
u8x8_SetPowerSave(u8g2_GetU8x8(&u8g2), 0);
//u8g2_SetFont(&u8g2, u8g2_font_helvB18_tr);
x = 50;
y = 30;
for(;;)
{
#ifdef U8G2_WITH_HVLINE_COUNT
u8g2.hv_cnt = 0UL;
#endif /* U8G2_WITH_HVLINE_COUNT */
/*
u8g2_ClearBuffer(&u8g2);
u8g2_SetFontDirection(&u8g2, 0);
u8g2_DrawStr(&u8g2, x, y, "ABC");
u8g2_SetFontDirection(&u8g2, 1);
u8g2_DrawStr(&u8g2, x, y, "abc");
u8g2_SetFontDirection(&u8g2, 2);
u8g2_DrawStr(&u8g2, x, y, "abc");
u8g2_SetFontDirection(&u8g2, 3);
u8g2_DrawStr(&u8g2, x, y, "abc");
u8g2_SendBuffer(&u8g2);
*/
//u8g2_SetFont(&u8g2, u8g2_font_cu12_t_arabic);
u8g2_SetFont(&u8g2, u8g2_font_unifont_t_arabic);
u8g2_FirstPage(&u8g2);
i = 0;
do
{
u8g2_SetFontDirection(&u8g2, 0);
u8g2_DrawExtUTF8(&u8g2, x, y, 1, NULL, "سلام جهان");
u8g2_DrawExtUTF8(&u8g2, x, y+20, 1, my_kerning_table, "سلام جهان");
i++;
} while( u8g2_NextPage(&u8g2) );
#ifdef U8G2_WITH_HVLINE_COUNT
printf("hv cnt: %ld\n", u8g2.hv_cnt);
#endif /* U8G2_WITH_HVLINE_COUNT */
do
{
k = u8g_sdl_get_key();
} while( k < 0 );
if ( k == 273 ) y -= 7;
if ( k == 274 ) y += 7;
if ( k == 276 ) x -= 7;
if ( k == 275 ) x += 7;
if ( k == 'e' ) y -= 1;
if ( k == 'x' ) y += 1;
if ( k == 's' ) x -= 1;
if ( k == 'd' ) x += 1;
if ( k == 'q' ) break;
}
//u8x8_Set8x8Font(u8g2_GetU8x8(&u8g2), bdf_font);
//u8x8_Draw8x8String(u8g2_GetU8x8(&u8g2), 0, 0, "Hello World!");
return 0;
}