Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
TFT_eSPI
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
TFT_eSPI
Commits
7d3f4f21
Commit
7d3f4f21
authored
Apr 29, 2022
by
Bodmer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #1802
parent
673de31f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
86 additions
and
19 deletions
+86
-19
Extensions/Sprite.cpp
Extensions/Sprite.cpp
+86
-19
No files found.
Extensions/Sprite.cpp
View file @
7d3f4f21
...
@@ -2393,15 +2393,27 @@ void TFT_eSprite::drawGlyph(uint16_t code)
...
@@ -2393,15 +2393,27 @@ void TFT_eSprite::drawGlyph(uint16_t code)
uint16_t
fg
=
textcolor
;
uint16_t
fg
=
textcolor
;
uint16_t
bg
=
textbgcolor
;
uint16_t
bg
=
textbgcolor
;
// Check if cursor has moved
if
(
last_cursor_x
!=
cursor_x
)
{
bg_cursor_x
=
cursor_x
;
last_cursor_x
=
cursor_x
;
}
if
(
code
<
0x21
)
if
(
code
<
0x21
)
{
{
if
(
code
==
0x20
)
{
if
(
code
==
0x20
)
{
if
(
_fillbg
)
fillRect
(
bg_cursor_x
,
cursor_y
,
(
cursor_x
+
gFont
.
spaceWidth
)
-
bg_cursor_x
,
gFont
.
yAdvance
,
bg
);
cursor_x
+=
gFont
.
spaceWidth
;
cursor_x
+=
gFont
.
spaceWidth
;
bg_cursor_x
=
cursor_x
;
last_cursor_x
=
cursor_x
;
return
;
return
;
}
}
if
(
code
==
'\n'
)
{
if
(
code
==
'\n'
)
{
cursor_x
=
0
;
cursor_x
=
0
;
bg_cursor_x
=
0
;
last_cursor_x
=
0
;
cursor_y
+=
gFont
.
yAdvance
;
cursor_y
+=
gFont
.
yAdvance
;
if
(
textwrapY
&&
(
cursor_y
>=
height
()))
cursor_y
=
0
;
if
(
textwrapY
&&
(
cursor_y
>=
height
()))
cursor_y
=
0
;
return
;
return
;
...
@@ -2421,6 +2433,8 @@ void TFT_eSprite::drawGlyph(uint16_t code)
...
@@ -2421,6 +2433,8 @@ void TFT_eSprite::drawGlyph(uint16_t code)
createSprite
(
gWidth
[
gNum
],
gFont
.
yAdvance
);
createSprite
(
gWidth
[
gNum
],
gFont
.
yAdvance
);
if
(
fg
!=
bg
)
fillSprite
(
bg
);
if
(
fg
!=
bg
)
fillSprite
(
bg
);
cursor_x
=
-
gdX
[
gNum
];
cursor_x
=
-
gdX
[
gNum
];
bg_cursor_x
=
cursor_x
;
last_cursor_x
=
cursor_x
;
cursor_y
=
0
;
cursor_y
=
0
;
}
}
else
else
...
@@ -2428,10 +2442,11 @@ void TFT_eSprite::drawGlyph(uint16_t code)
...
@@ -2428,10 +2442,11 @@ void TFT_eSprite::drawGlyph(uint16_t code)
if
(
textwrapX
&&
((
cursor_x
+
gWidth
[
gNum
]
+
gdX
[
gNum
])
>
width
()))
{
if
(
textwrapX
&&
((
cursor_x
+
gWidth
[
gNum
]
+
gdX
[
gNum
])
>
width
()))
{
cursor_y
+=
gFont
.
yAdvance
;
cursor_y
+=
gFont
.
yAdvance
;
cursor_x
=
0
;
cursor_x
=
0
;
bg_cursor_x
=
0
;
last_cursor_x
=
0
;
}
}
if
(
textwrapY
&&
((
cursor_y
+
gFont
.
yAdvance
)
>
height
()))
cursor_y
=
0
;
if
(
textwrapY
&&
((
cursor_y
+
gFont
.
yAdvance
)
>
height
()))
cursor_y
=
0
;
if
(
cursor_x
==
0
)
cursor_x
-=
gdX
[
gNum
];
if
(
cursor_x
==
0
)
cursor_x
-=
gdX
[
gNum
];
}
}
...
@@ -2445,11 +2460,45 @@ void TFT_eSprite::drawGlyph(uint16_t code)
...
@@ -2445,11 +2460,45 @@ void TFT_eSprite::drawGlyph(uint16_t code)
}
}
#endif
#endif
int16_t
xs
=
0
;
int16_t
cy
=
cursor_y
+
gFont
.
maxAscent
-
gdY
[
gNum
];
uint16_t
dl
=
0
;
int16_t
cx
=
cursor_x
+
gdX
[
gNum
];
// if (cx > width() && bg_cursor_x > width()) return;
// if (cursor_y > height()) return;
int16_t
fxs
=
cx
;
uint32_t
fl
=
0
;
int16_t
bxs
=
cx
;
uint32_t
bl
=
0
;
int16_t
bx
=
0
;
uint8_t
pixel
=
0
;
uint8_t
pixel
=
0
;
int32_t
cgy
=
cursor_y
+
gFont
.
maxAscent
-
gdY
[
gNum
];
int32_t
cgx
=
cursor_x
+
gdX
[
gNum
];
int16_t
fillwidth
=
0
;
uint16_t
fillheight
=
0
;
// Fill area above glyph
if
(
_fillbg
)
{
fillwidth
=
(
cursor_x
+
gxAdvance
[
gNum
])
-
bg_cursor_x
;
if
(
fillwidth
>
0
)
{
fillheight
=
gFont
.
maxAscent
-
gdY
[
gNum
];
if
(
fillheight
>
0
)
{
fillRect
(
bg_cursor_x
,
cursor_y
,
fillwidth
,
fillheight
,
textbgcolor
);
}
}
else
{
// Could be negative
fillwidth
=
0
;
}
// Fill any area to left of glyph
if
(
bg_cursor_x
<
cx
)
fillRect
(
bg_cursor_x
,
cy
,
cx
-
bg_cursor_x
,
gHeight
[
gNum
],
textbgcolor
);
// Set x position in glyph area where background starts
if
(
bg_cursor_x
>
cx
)
bx
=
bg_cursor_x
-
cx
;
// Fill any area to right of glyph
if
(
cx
+
gWidth
[
gNum
]
<
cursor_x
+
gxAdvance
[
gNum
])
{
fillRect
(
cx
+
gWidth
[
gNum
],
cy
,
(
cursor_x
+
gxAdvance
[
gNum
])
-
(
cx
+
gWidth
[
gNum
]),
gHeight
[
gNum
],
textbgcolor
);
}
}
for
(
int32_t
y
=
0
;
y
<
gHeight
[
gNum
];
y
++
)
for
(
int32_t
y
=
0
;
y
<
gHeight
[
gNum
];
y
++
)
{
{
...
@@ -2458,49 +2507,65 @@ void TFT_eSprite::drawGlyph(uint16_t code)
...
@@ -2458,49 +2507,65 @@ void TFT_eSprite::drawGlyph(uint16_t code)
fontFile
.
read
(
pbuffer
,
gWidth
[
gNum
]);
fontFile
.
read
(
pbuffer
,
gWidth
[
gNum
]);
}
}
#endif
#endif
for
(
int32_t
x
=
0
;
x
<
gWidth
[
gNum
];
x
++
)
for
(
int32_t
x
=
0
;
x
<
gWidth
[
gNum
];
x
++
)
{
{
#ifdef FONT_FS_AVAILABLE
#ifdef FONT_FS_AVAILABLE
if
(
fs_font
)
{
if
(
fs_font
)
pixel
=
pbuffer
[
x
];
pixel
=
pbuffer
[
x
];
}
else
else
#endif
#endif
pixel
=
pgm_read_byte
(
gPtr
+
gBitmap
[
gNum
]
+
x
+
gWidth
[
gNum
]
*
y
);
pixel
=
pgm_read_byte
(
gPtr
+
gBitmap
[
gNum
]
+
x
+
gWidth
[
gNum
]
*
y
);
if
(
pixel
)
if
(
pixel
)
{
{
if
(
bl
)
{
drawFastHLine
(
bxs
,
y
+
cy
,
bl
,
bg
);
bl
=
0
;
}
if
(
pixel
!=
0xFF
)
if
(
pixel
!=
0xFF
)
{
{
if
(
dl
)
{
drawFastHLine
(
xs
,
y
+
cgy
,
dl
,
fg
);
dl
=
0
;
}
if
(
fl
)
{
if
(
_bpp
!=
1
)
{
if
(
fl
==
1
)
drawPixel
(
fxs
,
y
+
cy
,
fg
);
if
(
fg
==
bg
)
drawPixel
(
x
+
cgx
,
y
+
cgy
,
alphaBlend
(
pixel
,
fg
,
readPixel
(
x
+
cgx
,
y
+
cgy
))
);
else
drawFastHLine
(
fxs
,
y
+
cy
,
fl
,
fg
);
else
drawPixel
(
x
+
cgx
,
y
+
cgy
,
alphaBlend
(
pixel
,
fg
,
bg
))
;
fl
=
0
;
}
}
else
if
(
pixel
>
127
)
drawPixel
(
x
+
cgx
,
y
+
cgy
,
fg
);
if
(
getColor
)
bg
=
getColor
(
x
+
cx
,
y
+
cy
);
drawPixel
(
x
+
cx
,
y
+
cy
,
alphaBlend
(
pixel
,
fg
,
bg
));
}
}
else
else
{
{
if
(
dl
==
0
)
xs
=
x
+
cg
x
;
if
(
fl
==
0
)
fxs
=
x
+
c
x
;
d
l
++
;
f
l
++
;
}
}
}
}
else
else
{
{
if
(
dl
)
{
drawFastHLine
(
xs
,
y
+
cgy
,
dl
,
fg
);
dl
=
0
;
}
if
(
fl
)
{
drawFastHLine
(
fxs
,
y
+
cy
,
fl
,
fg
);
fl
=
0
;
}
if
(
_fillbg
)
{
if
(
x
>=
bx
)
{
if
(
bl
==
0
)
bxs
=
x
+
cx
;
bl
++
;
}
}
}
}
}
if
(
dl
)
{
drawFastHLine
(
xs
,
y
+
cgy
,
dl
,
fg
);
dl
=
0
;
}
}
if
(
fl
)
{
drawFastHLine
(
fxs
,
y
+
cy
,
fl
,
fg
);
fl
=
0
;
}
if
(
bl
)
{
drawFastHLine
(
bxs
,
y
+
cy
,
bl
,
bg
);
bl
=
0
;
}
}
// Fill area below glyph
if
(
fillwidth
>
0
)
{
fillheight
=
(
cursor_y
+
gFont
.
yAdvance
)
-
(
cy
+
gHeight
[
gNum
]);
if
(
fillheight
>
0
)
{
fillRect
(
bg_cursor_x
,
cy
+
gHeight
[
gNum
],
fillwidth
,
fillheight
,
textbgcolor
);
}
}
}
if
(
pbuffer
)
free
(
pbuffer
);
if
(
pbuffer
)
free
(
pbuffer
);
cursor_x
+=
gxAdvance
[
gNum
];
if
(
newSprite
)
if
(
newSprite
)
{
{
pushSprite
(
c
g
x
,
cursor_y
);
pushSprite
(
cx
,
cursor_y
);
deleteSprite
();
deleteSprite
();
}
}
cursor_x
+=
gxAdvance
[
gNum
];
}
}
else
else
{
{
...
@@ -2508,6 +2573,8 @@ void TFT_eSprite::drawGlyph(uint16_t code)
...
@@ -2508,6 +2573,8 @@ void TFT_eSprite::drawGlyph(uint16_t code)
drawRect
(
cursor_x
,
cursor_y
+
gFont
.
maxAscent
-
gFont
.
ascent
,
gFont
.
spaceWidth
,
gFont
.
ascent
,
fg
);
drawRect
(
cursor_x
,
cursor_y
+
gFont
.
maxAscent
-
gFont
.
ascent
,
gFont
.
spaceWidth
,
gFont
.
ascent
,
fg
);
cursor_x
+=
gFont
.
spaceWidth
+
1
;
cursor_x
+=
gFont
.
spaceWidth
+
1
;
}
}
bg_cursor_x
=
cursor_x
;
last_cursor_x
=
cursor_x
;
}
}
...
...
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