drawutfline
This commit is contained in:
parent
a5f30a5f10
commit
0c31f9b41f
|
@ -946,14 +946,14 @@ static u8g2_uint_t u8g2_string_width(u8g2_t *u8g2, const char *str) U8G2_NOINLIN
|
|||
static u8g2_uint_t u8g2_string_width(u8g2_t *u8g2, const char *str)
|
||||
{
|
||||
uint16_t e;
|
||||
u8g2_uint_t w, dx, pw;
|
||||
u8g2_uint_t w, dx;
|
||||
|
||||
u8g2->font_decode.glyph_width = 0;
|
||||
u8x8_utf8_init(u8g2_GetU8x8(u8g2));
|
||||
|
||||
/* reset the total width to zero, this will be expanded during calculation */
|
||||
w = 0;
|
||||
dx = 0;
|
||||
pw = 0;
|
||||
|
||||
for(;;)
|
||||
{
|
||||
|
@ -965,13 +965,12 @@ static u8g2_uint_t u8g2_string_width(u8g2_t *u8g2, const char *str)
|
|||
{
|
||||
dx = u8g2_GetGlyphWidth(u8g2, e); /* delta x value of the glyph */
|
||||
w += dx;
|
||||
pw = u8g2->font_decode.glyph_width; /* the real pixel width of the glyph */
|
||||
}
|
||||
}
|
||||
|
||||
/* adjust the last glyph */
|
||||
w -= dx;
|
||||
w += pw;
|
||||
w += u8g2->font_decode.glyph_width; /* the real pixel width of the glyph, sideeffect of GetGlyphWidth */
|
||||
|
||||
return w;
|
||||
}
|
||||
|
|
|
@ -75,21 +75,34 @@ void u8g2_DrawUTF8Line(u8g2_t *u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t w
|
|||
}
|
||||
|
||||
/* caluclate frame */
|
||||
fx = x-1; /* -1 adjustment so that the frame is outside */
|
||||
fy = y - u8g2_GetAscent(u8g2) - 1;
|
||||
fw = w+2; /* +2 to make the frame outside */
|
||||
fh = u8g2_GetAscent(u8g2) - u8g2_GetDescent(u8g2) + 2;
|
||||
u8g2_DrawFrame(u8g2, fx, fy, fw, fh );
|
||||
fx = x;
|
||||
fy = y - u8g2_GetAscent(u8g2) ;
|
||||
fw = w;
|
||||
fh = u8g2_GetAscent(u8g2) - u8g2_GetDescent(u8g2) ;
|
||||
|
||||
|
||||
/*
|
||||
u8g2_SetDrawColor(u8g2, 1);
|
||||
if ( is_invert )
|
||||
{
|
||||
u8g2_SetDrawColor(u8g2, 1);
|
||||
u8g2_DrawBox(u8g2, fx, fy, fw, fh);
|
||||
}
|
||||
|
||||
while( border_size > 0 )
|
||||
{
|
||||
fx--;
|
||||
fy--;
|
||||
fw +=2;
|
||||
fh +=2;
|
||||
u8g2_DrawFrame(u8g2, fx, fy, fw, fh );
|
||||
border_size--;
|
||||
}
|
||||
|
||||
if ( is_invert )
|
||||
{
|
||||
u8g2_SetDrawColor(u8g2, 0);
|
||||
}
|
||||
*/
|
||||
|
||||
u8g2_DrawUTF8(u8g2, x+d, y, s);
|
||||
u8g2_SetDrawColor(u8g2, 1);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ Major Changes (Code rework required)
|
|||
- getFontLineSpacing() and setFontLineSpacingFactor() are not supported any more.
|
||||
- setFontRefHeightText(), setFontRefHeightExtendedText() and setFontRefHeightAll() are
|
||||
not supported as of now. Maybe this will be added in the future.
|
||||
- getStrPixelWidth() is not supported any more, use getStrWidth() instead
|
||||
- getStrPixelWidth() is replaced by getStrWidth() instead
|
||||
- setHardwareBackup() not yet supported. Might be implemented later
|
||||
- Cursor functions are not available. This includes:
|
||||
setCursorFont(), setCursorStyle(), setCursorPos(), setCursorColor(),
|
||||
|
|
|
@ -21,7 +21,7 @@ int main(void)
|
|||
u8g2_FirstPage(&u8g2);
|
||||
do
|
||||
{
|
||||
u8g2_DrawUTF8Line(&u8g2, 5, 15, 10, "Agile", 1,0);
|
||||
u8g2_DrawUTF8Line(&u8g2, 5, 15, 10, "Agile", 2,1);
|
||||
} while( u8g2_NextPage(&u8g2) );
|
||||
|
||||
utf8_show();
|
||||
|
|
Loading…
Reference in New Issue