Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
esp8266-oled-ssd1306
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
c3pb
esp8266-oled-ssd1306
Commits
c8fbe1bb
Commit
c8fbe1bb
authored
7 years ago
by
Xavier Grosjean
Browse files
Options
Downloads
Patches
Plain Diff
Fixed up-bound shifting issue when parsing a font, reported by @lorol
parent
8e1cd26f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
resources/glyphEditor.html
+16
-18
16 additions, 18 deletions
resources/glyphEditor.html
with
16 additions
and
18 deletions
resources/glyphEditor.html
+
16
−
18
View file @
c8fbe1bb
...
...
@@ -104,16 +104,16 @@ SOFTWARE.
<td
width=
"75%"
rowspan=
"5"
>
<textarea
id=
"inputText"
placeholder=
"Or paste a char array font definition here"
>
const char My_Font[] PROGMEM = {
0x
a
, // Width: 10
0x
d
, // Height: 13
0x1, // First char: 1
0x2, // Number of chars: 2
// Jump
t
able:
0x0, 0x0, 0x1
4
, 0x
a,
0x0, 0x14, 0x
14, 0xa,
0x
0A
, // Width: 10
0x
0D
, // Height: 13
0x
0
1, // First char: 1
0x
0
2, // Number of chars: 2
// Jump
T
able:
0x0
0
, 0x0
0
, 0x1
3
, 0x
0A, // 1
0x0
0, 0x13
, 0x14, 0x
0A, // 2
// Font Data:
0x
8
0,0x
1f,0x80,
0x10,0x
80,0x1f,0x80,
0x10,0x
80,0x1f,0x80,
0x10,0x
80,0x1f,0x80,
0x10,0x
80,0x1f,0x0,0x6,
0x0
,0x60,
0x0,0x
5c,
0x
8
0,0x
43,0x60,0x40,0x98,0x57,0x98,0x57,0x60,0x40,
0x
8
0,0x
43,
0x0,0x
5c,0x0,0x60,
0x
F
0,
0x
03,
0x10,
0x
02, 0xF0, 0x03,
0x10,
0x
02, 0xF0, 0x03,
0x10,
0x
02, 0xF0, 0x03,
0x10,
0x
02, 0xF0, 0x03, 0xC0, // 1
0x0
0, 0x0C,
0x
8
0,
0x
0B,
0x
7
0,
0x
08, 0x0C, 0x08, 0xF3, 0x0A, 0xF3, 0x0A, 0x0C, 0x08,
0x
7
0,
0x
08,
0x
8
0,
0x
0B, 0x00, 0x0C, // 2
};
</textarea></td>
</tr>
...
...
@@ -155,8 +155,7 @@ const char My_Font[] PROGMEM = {
constructor
()
{
this
.
height
=
parseInt
(
document
.
getElementById
(
'
height
'
).
value
);
this
.
width
=
parseInt
(
document
.
getElementById
(
'
width
'
).
value
);
let
firstCharCode
=
parseInt
(
document
.
getElementById
(
'
code
'
).
value
);
this
.
currentCharCode
=
firstCharCode
;
this
.
currentCharCode
=
parseInt
(
document
.
getElementById
(
'
code
'
).
value
);
this
.
fontContainer
=
document
.
getElementById
(
'
chars
'
);
this
.
bytesForHeight
=
(
1
+
((
this
.
height
-
1
)
>>
3
));
// number of bytes needed for this font height
document
.
body
.
className
=
"
started
"
;
...
...
@@ -184,7 +183,7 @@ const char My_Font[] PROGMEM = {
// If data is provided, decode it to pixel initialization friendly structure
let
pixelInit
=
[];
if
(
charData
&&
charData
.
length
)
{
// charData byte count needs to be a multiple of bytesForHeight. End bytes with value 0 may have been
s
tri
pp
ed
// charData byte count needs to be a multiple of bytesForHeight. End bytes with value 0 may have been tri
mm
ed
let
missingBytes
=
charData
.
length
%
this
.
bytesForHeight
;
for
(
let
b
=
0
;
b
<
missingBytes
;
b
++
)
{
charData
.
push
(
0
);
...
...
@@ -204,8 +203,8 @@ const char My_Font[] PROGMEM = {
mask
=
mask
>>
1
;
}
}
pixelRow
.
splice
(
this
.
height
+
1
);
//
Font.output('data', pixelRow);
pixelRow
.
splice
(
0
,
pixelRow
.
length
-
this
.
height
);
//Font.output('data', pixelRow);
pixelInit
.
push
(
pixelRow
.
reverse
());
}
}
...
...
@@ -290,17 +289,16 @@ const char My_Font[] PROGMEM = {
let
pixelState
=
rows
[
r
].
children
[
col
].
className
;
bits
+=
(
pixelState
===
'
on
'
?
'
1
'
:
'
0
'
);
}
// Need to complete missing bits to have a sizeof byte multiple number of bits
for
(
let
b
=
0
;
b
<
bits2add
;
b
++
)
{
bits
+
=
'
0
'
;
bits
=
'
0
'
+
bits
;
}
// Font.output('data', ` // ${bits}`); // Debugging help: rotated bitmap
// read bytes from the end
for
(
let
b
=
bits
.
length
-
1
;
b
>=
7
;
b
-=
8
)
{
//Font.output('data', ` // ${bits.substr
ing
(b-7,
b
)}`); // Debugging help: rotated bitmap
let
byte
=
parseInt
(
bits
.
substr
ing
(
b
-
8
,
b
),
2
);
//Font.output('data', ` // ${bits.substr(b-7,
8
)}`); // Debugging help: rotated bitmap
let
byte
=
parseInt
(
bits
.
substr
(
b
-
7
,
8
),
2
);
if
(
byte
!=
0
)
{
notZero
=
true
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment