???
This commit is contained in:
@@ -41,7 +41,8 @@ public:
|
||||
/** get the pixel-width of the given char */
|
||||
uint8_t getCharWidht(char c) const {
|
||||
if (c == 32) {return 3;} // whitespace
|
||||
return offsets[c-off+1] - offsets[c-off];
|
||||
const int i = c-off;
|
||||
return offsets[i+1] - offsets[i];
|
||||
}
|
||||
|
||||
uint8_t getHeight() const {
|
||||
@@ -57,8 +58,8 @@ public:
|
||||
return sum;
|
||||
}
|
||||
|
||||
/** draw the given char at the given position */
|
||||
template <typename Scalar, typename Destination> void draw(const char* c, Scalar dx, Scalar dy, Destination& dst) {
|
||||
/** draw the given string at the given position */
|
||||
template <typename Scalar, typename Destination> void draw(const char* c, Scalar dx, Scalar dy, Destination& dst) const {
|
||||
while(*c) {
|
||||
draw(*c, dx, dy, dst);
|
||||
dx += getCharWidht(*c);// + 1;
|
||||
@@ -67,11 +68,10 @@ public:
|
||||
}
|
||||
|
||||
/** draw the given char at the given position */
|
||||
template <typename Scalar, typename Destination> void draw(unsigned char c, Scalar dx, Scalar dy, Destination& dst) {
|
||||
template <typename Scalar, typename Destination> void draw(unsigned char c, Scalar dx, Scalar dy, Destination& dst) const {
|
||||
|
||||
if (c == 32) {return;} // skip whitespace
|
||||
|
||||
|
||||
const uint16_t x1 = offsets[c-off];
|
||||
const uint16_t x2 = offsets[c-off+1];
|
||||
const uint16_t y1 = 0;
|
||||
@@ -80,8 +80,8 @@ public:
|
||||
for (uint16_t y = y1; y < y2; ++y) {
|
||||
for (uint16_t x = x1; x < x2; ++x) {
|
||||
const uint16_t idx = (x/8) + (y*this->w/8);
|
||||
const uint8_t pixel = data[idx] & (1<<(x&7));
|
||||
if (pixel) {
|
||||
const uint8_t pxInFont = data[idx] & (1<<(x&7)); // pixel from font glyph
|
||||
if (pxInFont) {
|
||||
dst.setPixel(dx+x-x1, dy+y);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user