This commit is contained in:
olikraus 2016-08-20 14:04:33 +02:00
parent bf4198b23f
commit 8241447854
7 changed files with 190 additions and 3 deletions

View File

@ -31,7 +31,10 @@ https://github.com/olikraus/u8g2 ChangeLog
* Fixed SSD1306 I2C procedures (mirror pixel in last tile column, issue 44)
* Experimental support für mini12864 (pull request)
* Use beginTransaction for SPI. This requires Arduino 1.6.0
2016-08-18 v2.3.x olikraus@gmail.com
2016-08-18 v2.3.2 olikraus@gmail.com
* MINI12874; Fixed HW Flip Mode (pull request 49)
* Fixed ST7920 HW SPI with very fast uC, issue 50
* Improved HW SPI for SH1106 and SSD1306 displays
* Fixed issue with missing fonts
2016-xx-xx v2.4.x olikraus@gmail.com

View File

@ -602,6 +602,7 @@ void u8g2_DrawTriangle(u8g2_t *u8g2, int16_t x0, int16_t y0, int16_t x1, int16_t
/* u8g2_kerning.c */
//uint8_t u8g2_GetNullKerning(u8g2_t *u8g2, uint16_t e1, uint16_t e2);
uint8_t u8g2_GetKerning(u8g2_t *u8g2, u8g2_kerning_t *kerning, uint16_t e1, uint16_t e2);
uint8_t u8g2_GetKerningByTable(u8g2_t *u8g2, const uint16_t *kt, uint16_t e1, uint16_t e2);
/*==========================================*/
@ -624,6 +625,7 @@ void u8g2_SetFontDirection(u8g2_t *u8g2, uint8_t dir);
u8g2_uint_t u8g2_DrawStr(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, const char *str);
u8g2_uint_t u8g2_DrawUTF8(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, const char *str);
u8g2_uint_t u8g2_DrawExtendedUTF8(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, uint8_t to_left, u8g2_kerning_t *kerning, const char *str);
u8g2_uint_t u8g2_DrawExtUTF8(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, uint8_t to_left, const uint16_t *kerning_table, const char *str);
#define u8g2_GetMaxCharHeight(u8g2) ((u8g2)->font_info.max_char_height)
#define u8g2_GetMaxCharWidth(u8g2) ((u8g2)->font_info.max_char_width)

View File

@ -825,6 +825,52 @@ u8g2_uint_t u8g2_DrawExtendedUTF8(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, ui
return sum;
}
u8g2_uint_t u8g2_DrawExtUTF8(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, uint8_t to_left, const uint16_t *kerning_table, const char *str)
{
u8g2->u8x8.next_cb = u8x8_utf8_next;
uint16_t e_prev = 0x0ffff;
uint16_t e;
u8g2_uint_t delta, sum, k;
u8x8_utf8_init(u8g2_GetU8x8(u8g2));
sum = 0;
for(;;)
{
e = u8g2->u8x8.next_cb(u8g2_GetU8x8(u8g2), (uint8_t)*str);
if ( e == 0x0ffff )
break;
str++;
if ( e != 0x0fffe )
{
delta = u8g2_GetGlyphWidth(u8g2, e);
if ( to_left )
{
k = u8g2_GetKerningByTable(u8g2, kerning_table, e, e_prev);
delta -= k;
x -= delta;
}
else
{
k = u8g2_GetKerningByTable(u8g2, kerning_table, e_prev, e);
delta -= k;
}
e_prev = e;
u8g2_DrawGlyph(u8g2, x, y, e);
if ( to_left )
{
}
else
{
x += delta;
x -= k;
}
sum += delta;
}
}
return sum;
}

View File

@ -75,3 +75,20 @@ uint8_t u8g2_GetKerning(u8g2_t *u8g2, u8g2_kerning_t *kerning, uint16_t e1, uint
return kerning->kerning_values[i2];
}
uint8_t u8g2_GetKerningByTable(u8g2_t *u8g2, const uint16_t *kt, uint16_t e1, uint16_t e2)
{
uint16_t i;
i = 0;
if ( kt == NULL )
return 0;
for(;;)
{
if ( kt[i] == 0x0ffff )
break;
if ( kt[i] == e1 && kt[i+1] == e2 )
return kt[i+2];
i+=3;
}
return 0;
}

View File

@ -0,0 +1,12 @@
CFLAGS = -g -Wall -I../../../csrc/. `sdl-config --cflags`
SRC = $(shell ls ../../../csrc/*.c) $(shell ls ../common/*.c ) main.c
OBJ = $(SRC:.c=.o)
helloworld: $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJ) `sdl-config --libs` -o u8g2_sdl
clean:
-rm $(OBJ) u8g2_sdl

View File

@ -0,0 +1,107 @@
#include "u8g2.h"
#include <stdio.h>
u8g2_t u8g2;
u8g2_DrawExtUTF8(&u8g2, x, y, 1, NULL, "سلام جهان");
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;
}

View File

@ -1,2 +1,2 @@
# without 'v' prefix
echo -n "2.3.1"
echo -n "2.3.2"