BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lvgl
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
lvgl
Commits
b0e26d86
Commit
b0e26d86
authored
Feb 05, 2018
by
Gabor Kiss-Vamosi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new font system WIP
parent
e5676aaf
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
84 additions
and
89 deletions
+84
-89
lv_draw_rbasic.c
lv_draw/lv_draw_rbasic.c
+2
-2
lv_draw_vbasic.c
lv_draw/lv_draw_vbasic.c
+45
-66
lv_area.c
lv_misc/lv_area.c
+1
-1
lv_font.c
lv_misc/lv_font.c
+12
-7
lv_font.h
lv_misc/lv_font.h
+20
-8
dejavu_20.c
lv_misc/lv_fonts/dejavu_20.c
+0
-0
dejavu_20.h
lv_misc/lv_fonts/dejavu_20.h
+2
-3
lv_txt.c
lv_misc/lv_txt.c
+1
-1
lv_txt.h
lv_misc/lv_txt.h
+1
-1
No files found.
lv_draw/lv_draw_rbasic.c
View file @
b0e26d86
...
...
@@ -110,7 +110,7 @@ void lv_rletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
uint8_t
col
,
col_sub
,
row
;
#if LV_FONT_ANTIALIAS == 0
for
(
row
=
0
;
row
<
font_p
->
h
eight_row
;
row
++
)
{
for
(
row
=
0
;
row
<
font_p
->
h
_px
;
row
++
)
{
for
(
col
=
0
,
col_sub
=
7
;
col
<
w
;
col
++
,
col_sub
--
)
{
if
(
*
bitmap_p
&
(
1
<<
col_sub
))
{
lv_rpx
(
pos_p
->
x
+
col
,
pos_p
->
y
+
row
,
mask_p
,
color
,
opa
);
...
...
@@ -131,7 +131,7 @@ void lv_rletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
const
uint8_t
*
map2_p
=
bitmap_p
+
width_byte
;
uint8_t
px_cnt
;
uint8_t
col_byte_cnt
;
for
(
row
=
0
;
row
<
(
font_p
->
h
eight_row
>>
1
);
row
++
)
{
for
(
row
=
0
;
row
<
(
font_p
->
h
_px
>>
1
);
row
++
)
{
col_byte_cnt
=
0
;
col_sub
=
7
;
for
(
col
=
0
;
col
<
(
w
>>
1
);
col
++
)
{
...
...
lv_draw/lv_draw_vbasic.c
View file @
b0e26d86
...
...
@@ -203,11 +203,30 @@ void lv_vfill(const lv_area_t * cords_p, const lv_area_t * mask_p,
void
lv_vletter
(
const
lv_point_t
*
pos_p
,
const
lv_area_t
*
mask_p
,
const
lv_font_t
*
font_p
,
uint32_t
letter
,
lv_color_t
color
,
lv_opa_t
opa
)
{
{
static
uint8_t
bpp1_opa_table
[
2
]
=
{
0
,
255
};
/*Opacity mapping with bpp = 1 (Just for compatibility)*/
static
uint8_t
bpp2_opa_table
[
4
]
=
{
0
,
85
,
170
,
255
};
/*Opacity mapping with bpp = 2*/
static
uint8_t
bpp4_opa_table
[
16
]
=
{
0
,
17
,
34
,
51
,
/*Opacity mapping with bpp = 4*/
68
,
85
,
102
,
119
,
136
,
153
,
170
,
187
,
204
,
221
,
238
,
255
};
if
(
font_p
==
NULL
)
return
;
uint8_t
letter_w
=
lv_font_get_width
(
font_p
,
letter
);
uint8_t
letter_h
=
lv_font_get_height
(
font_p
);
uint8_t
bpp
=
font_p
->
bpp
;
/*Bit per pixel (1,2 or 4)*/
uint8_t
*
bpp_opa_table
;
/*Value per pixel (1, 4 or 16)*/
uint8_t
mask_init
;
uint8_t
mask
;
switch
(
bpp
)
{
case
1
:
bpp_opa_table
=
bpp1_opa_table
;
mask_init
=
0x80
;
break
;
case
2
:
bpp_opa_table
=
bpp2_opa_table
;
mask_init
=
0xC0
;
break
;
case
4
:
bpp_opa_table
=
bpp4_opa_table
;
mask_init
=
0xF0
;
break
;
default:
return
;
/*Invalid bpp. Can't render the letter*/
}
const
uint8_t
*
map_p
=
lv_font_get_bitmap
(
font_p
,
letter
);
...
...
@@ -223,15 +242,17 @@ void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
lv_coord_t
col
,
row
;
uint8_t
col_bit
;
uint8_t
col_byte_cnt
;
uint8_t
width_byte
=
letter_w
>>
3
;
/*Width in bytes (e.g. w = 11 -> 2 bytes wide)*/
if
(
letter_w
&
0x7
)
width_byte
++
;
uint8_t
width_byte_scr
=
letter_w
>>
3
;
/*Width in bytes (on the screen finally) (e.g. w = 11 -> 2 bytes wide)*/
if
(
letter_w
&
0x7
)
width_byte_scr
++
;
uint8_t
width_byte_bpp
=
(
letter_w
*
bpp
)
>>
3
;
/*Width in bytes in the font (e.g. w = 11 -> 2 bytes wide)*/
if
((
letter_w
*
bpp
)
&
0x7
)
width_byte_bpp
++
;
/* Calculate the col/row start/end on the map
* If font anti al
aias
sing is enabled use the reduced letter sizes*/
* If font anti al
ia
sing is enabled use the reduced letter sizes*/
lv_coord_t
col_start
=
pos_p
->
x
>
mask_p
->
x1
?
0
:
mask_p
->
x1
-
pos_p
->
x
;
lv_coord_t
col_end
=
pos_p
->
x
+
(
letter_w
>>
LV_FONT_ANTIALIAS
)
<
mask_p
->
x2
?
(
letter_w
>>
LV_FONT_ANTIALIAS
)
:
mask_p
->
x2
-
pos_p
->
x
+
1
;
lv_coord_t
col_end
=
pos_p
->
x
+
letter_w
<
mask_p
->
x2
?
letter_w
:
mask_p
->
x2
-
pos_p
->
x
+
1
;
lv_coord_t
row_start
=
pos_p
->
y
>
mask_p
->
y1
?
0
:
mask_p
->
y1
-
pos_p
->
y
;
lv_coord_t
row_end
=
pos_p
->
y
+
(
letter_h
>>
LV_FONT_ANTIALIAS
)
<
mask_p
->
y2
?
(
letter_h
>>
LV_FONT_ANTIALIAS
)
:
mask_p
->
y2
-
pos_p
->
y
+
1
;
lv_coord_t
row_end
=
pos_p
->
y
+
letter_h
<
mask_p
->
y2
?
letter_h
:
mask_p
->
y2
-
pos_p
->
y
+
1
;
/*Set a pointer on VDB to the first pixel of the letter*/
vdb_buf_tmp
+=
((
pos_p
->
y
-
vdb_p
->
area
.
y1
)
*
vdb_width
)
...
...
@@ -241,78 +262,36 @@ void lv_vletter(const lv_point_t * pos_p, const lv_area_t * mask_p,
vdb_buf_tmp
+=
(
row_start
*
vdb_width
)
+
col_start
;
/*Move on the map too*/
map_p
+=
((
row_start
<<
LV_FONT_ANTIALIAS
)
*
width_byte
)
+
((
col_start
<<
LV_FONT_ANTIALIAS
)
>>
3
);
#if LV_FONT_ANTIALIAS != 0
lv_opa_t
opa_tmp
=
opa
;
if
(
opa_tmp
!=
LV_OPA_COVER
)
opa_tmp
=
opa_tmp
>>
2
;
/*Opacity per pixel (used when sum the pixels)*/
const
uint8_t
*
map1_p
=
map_p
;
const
uint8_t
*
map2_p
=
map_p
+
width_byte
;
uint8_t
px_cnt
;
for
(
row
=
row_start
;
row
<
row_end
;
row
++
)
{
col_byte_cnt
=
0
;
col_bit
=
7
-
((
col_start
<<
LV_FONT_ANTIALIAS
)
%
8
);
for
(
col
=
col_start
;
col
<
col_end
;
col
++
)
{
map_p
+=
(
row_start
*
width_byte_bpp
)
+
((
col_start
*
bpp
)
>>
3
);
px_cnt
=
0
;
if
((
*
map1_p
&
(
1
<<
col_bit
))
!=
0
)
px_cnt
++
;
if
((
*
map2_p
&
(
1
<<
col_bit
))
!=
0
)
px_cnt
++
;
if
(
col_bit
!=
0
)
col_bit
--
;
else
{
col_bit
=
7
;
col_byte_cnt
++
;
map1_p
++
;
map2_p
++
;
}
if
((
*
map1_p
&
(
1
<<
col_bit
))
!=
0
)
px_cnt
++
;
if
((
*
map2_p
&
(
1
<<
col_bit
))
!=
0
)
px_cnt
++
;
if
(
col_bit
!=
0
)
col_bit
--
;
else
{
col_bit
=
7
;
col_byte_cnt
++
;
map1_p
++
;
map2_p
++
;
}
if
(
px_cnt
!=
0
)
{
if
(
opa
==
LV_OPA_COVER
)
*
vdb_buf_tmp
=
lv_color_mix
(
color
,
*
vdb_buf_tmp
,
63
*
px_cnt
);
else
*
vdb_buf_tmp
=
lv_color_mix
(
color
,
*
vdb_buf_tmp
,
opa_tmp
*
px_cnt
);
}
vdb_buf_tmp
++
;
}
map1_p
+=
width_byte
;
map2_p
+=
width_byte
;
map1_p
+=
width_byte
-
col_byte_cnt
;
map2_p
+=
width_byte
-
col_byte_cnt
;
vdb_buf_tmp
+=
vdb_width
-
((
col_end
)
-
(
col_start
));
/*Next row in VDB*/
}
#else
uint8_t
letter_px
;
for
(
row
=
row_start
;
row
<
row_end
;
row
++
)
{
col_byte_cnt
=
0
;
col_bit
=
7
-
(
col_start
%
8
);
col_bit
=
(
col_start
*
bpp
)
%
8
;
mask
=
mask_init
>>
col_bit
;
for
(
col
=
col_start
;
col
<
col_end
;
col
++
)
{
if
((
*
map_p
&
(
1
<<
col_bit
))
!=
0
)
{
if
(
opa
==
LV_OPA_COVER
)
*
vdb_buf_tmp
=
color
;
else
*
vdb_buf_tmp
=
lv_color_mix
(
color
,
*
vdb_buf_tmp
,
opa
);
letter_px
=
(
*
map_p
&
mask
)
>>
(
8
-
col_bit
-
bpp
);
if
(
letter_px
!=
0
)
{
*
vdb_buf_tmp
=
lv_color_mix
(
color
,
*
vdb_buf_tmp
,
bpp_opa_table
[
letter_px
]);
}
vdb_buf_tmp
++
;
vdb_buf_tmp
++
;
if
(
col_bit
!=
0
)
col_bit
--
;
else
{
col_bit
=
7
;
col_byte_cnt
++
;
map_p
++
;
if
(
col_bit
<
8
-
bpp
)
{
col_bit
+=
bpp
;
mask
=
mask
>>
bpp
;
}
else
{
col_bit
=
0
;
col_byte_cnt
++
;
mask
=
mask_init
;
map_p
++
;
}
}
map_p
+=
width_byte
-
col_byte_cnt
;
map_p
+=
(
width_byte_bpp
)
-
col_byte_cnt
;
vdb_buf_tmp
+=
vdb_width
-
(
col_end
-
col_start
);
/*Next row in VDB*/
}
#endif
}
/**
...
...
lv_misc/lv_area.c
View file @
b0e26d86
...
...
@@ -175,7 +175,7 @@ bool lv_area_is_on(const lv_area_t * a1_p, const lv_area_t * a2_p)
if
(
lv_area_is_point_on
(
a1_p
,
&
p
))
return
true
;
/*a2 right-top corner is on a1*/
p
.
x
=
a2_p
->
x
1
;
p
.
x
=
a2_p
->
x
2
;
p
.
y
=
a2_p
->
y1
;
if
(
lv_area_is_point_on
(
a1_p
,
&
p
))
return
true
;
...
...
lv_misc/lv_font.c
View file @
b0e26d86
...
...
@@ -18,6 +18,11 @@
/**********************
* TYPEDEFS
**********************/
typedef
struct
{
uint32_t
glyph_index
;
uint32_t
unicode
;
uint8_t
w_px
;
}
asd_glyph_dsc_t
;
/**********************
* STATIC PROTOTYPES
...
...
@@ -109,7 +114,7 @@ void lv_font_init(void)
/*DEJAVU 20*/
#if USE_LV_FONT_DEJAVU_20 != 0
lv_font_add
(
&
lv_font_dejavu
_20
,
NULL
);
lv_font_add
(
&
arial
_20
,
NULL
);
#endif
#if USE_LV_FONT_DEJAVU_20_SUP != 0
...
...
@@ -446,9 +451,9 @@ const uint8_t * lv_font_get_bitmap(const lv_font_t * font_p, uint32_t letter)
{
const
lv_font_t
*
font_i
=
font_p
;
while
(
font_i
!=
NULL
)
{
if
(
letter
>=
font_i
->
first_ascii
&&
letter
<=
font_i
->
last_ascii
)
{
uint32_t
index
=
(
letter
-
font_i
->
first_ascii
);
return
&
font_i
->
bitmap
[
font_i
->
map
[
index
]
];
if
(
letter
>=
font_i
->
unicode_first
&&
letter
<=
font_i
->
unicode_last
)
{
uint32_t
index
=
(
letter
-
font_i
->
unicode_first
);
return
&
font_i
->
glyph_bitmap
[
font_i
->
glyph_dsc
[
index
].
glyph_index
];
}
font_i
=
font_i
->
next_page
;
...
...
@@ -467,9 +472,9 @@ uint8_t lv_font_get_width(const lv_font_t * font_p, uint32_t letter)
{
const
lv_font_t
*
font_i
=
font_p
;
while
(
font_i
!=
NULL
)
{
if
(
letter
>=
font_i
->
first_ascii
&&
letter
<=
font_i
->
last_ascii
)
{
uint32_t
index
=
(
letter
-
font_i
->
first_ascii
);
return
font_i
->
width
[
index
]
;
if
(
letter
>=
font_i
->
unicode_first
&&
letter
<=
font_i
->
unicode_last
)
{
uint32_t
index
=
(
letter
-
font_i
->
unicode_first
);
return
font_i
->
glyph_dsc
[
index
].
w_px
;
}
font_i
=
font_i
->
next_page
;
}
...
...
lv_misc/lv_font.h
View file @
b0e26d86
...
...
@@ -29,15 +29,27 @@ extern "C" {
* TYPEDEFS
**********************/
typedef
struct
{
uint32_t
w_px
:
8
;
uint32_t
glyph_index
:
24
;
}
lv_font_glyph_dsc_t
;
typedef
struct
{
uint32_t
unicode
:
21
;
uint32_t
glyph_dsc_index
:
11
;
}
lv_font_unicode_map_t
;
typedef
struct
_lv_font_struct
{
uint32_t
first_ascii
;
uint32_t
last_ascii
;
uint8_t
height_row
;
const
uint8_t
*
bitmap
;
const
uint32_t
*
map
;
const
uint8_t
*
width
;
uint32_t
unicode_first
;
uint32_t
unicode_last
;
uint8_t
h_px
;
const
uint8_t
*
glyph_bitmap
;
const
lv_font_glyph_dsc_t
*
glyph_dsc
;
struct
_lv_font_struct
*
next_page
;
/*Pointer to a font extension*/
uint32_t
bpp
:
3
;
/*Bit per pixel: 1, 2 or 4*/
}
lv_font_t
;
/**********************
...
...
@@ -71,7 +83,7 @@ const uint8_t * lv_font_get_bitmap(const lv_font_t * font_p, uint32_t letter);
*/
static
inline
uint8_t
lv_font_get_height
(
const
lv_font_t
*
font_p
)
{
return
font_p
->
h
eight_row
;
return
font_p
->
h
_px
;
}
/**
...
...
@@ -81,7 +93,7 @@ static inline uint8_t lv_font_get_height(const lv_font_t * font_p)
*/
static
inline
uint8_t
lv_font_get_height_scale
(
const
lv_font_t
*
font_p
)
{
return
(
font_p
->
h
eight_row
>>
LV_FONT_ANTIALIAS
)
>>
LV_ANTIALIAS
;
return
(
font_p
->
h
_px
>>
LV_FONT_ANTIALIAS
)
>>
LV_ANTIALIAS
;
}
...
...
lv_misc/lv_fonts/dejavu_20.c
View file @
b0e26d86
This source diff could not be displayed because it is too large. You can
view the blob
instead.
lv_misc/lv_fonts/dejavu_20.h
View file @
b0e26d86
...
...
@@ -9,7 +9,7 @@
#include <stdint.h>
#include "../lv_font.h"
extern
lv_font_t
lv_font_dejavu
_20
;
extern
lv_font_t
arial
_20
;
#endif
/*USE_LV_FONT_DEJAVU_20*/
#endif
/*DEJAVU_20_H*/
\ No newline at end of file
#endif
/*DEJAVU_20_H*/
lv_misc/lv_txt.c
View file @
b0e26d86
...
...
@@ -315,7 +315,7 @@ uint8_t lv_txt_utf8_size(uint8_t c)
* @param letter_uni an Unicode letter
* @return UTF-8 coded character in Little Endian to be compatible with C chars (e.g. 'Á', 'Ű')
*/
uint32_t
txt_unicode_to_utf8
(
uint32_t
letter_uni
)
uint32_t
lv_
txt_unicode_to_utf8
(
uint32_t
letter_uni
)
{
if
(
letter_uni
<
128
)
return
letter_uni
;
uint8_t
bytes
[
4
];
...
...
lv_misc/lv_txt.h
View file @
b0e26d86
...
...
@@ -121,7 +121,7 @@ uint8_t lv_txt_utf8_size(uint8_t c);
* @param letter_uni an Unicode letter
* @return UTF-8 coded character in Little Endian to be compatible with C chars (e.g. 'Á', 'Ű')
*/
uint32_t
txt_unicode_to_utf8
(
uint32_t
letter_uni
);
uint32_t
lv_
txt_unicode_to_utf8
(
uint32_t
letter_uni
);
/**
* Decode an UTF-8 character from a string.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment