Skip to content

Commit

Permalink
Merge pull request #22 from lovyan03/unstable
Browse files Browse the repository at this point in the history
0.1.13
  • Loading branch information
lovyan03 authored Jun 25, 2020
2 parents 105ae24 + 6618b8c commit fd4e8e1
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 27 deletions.
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"type": "git",
"url": "https://github.com/lovyan03/LovyanGFX"
},
"version": "0.1.12",
"version": "0.1.13",
"framework": "arduino",
"platforms": "espressif32, atmelsam",
"build": {
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=LovyanGFX
version=0.1.12
version=0.1.13
author=lovyan03
maintainer=Lovyan <[email protected]>
sentence=LCD Graphics driver for ESP32 and SAMD51
Expand Down
6 changes: 6 additions & 0 deletions src/Fonts/lgfx_fonts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,10 @@ namespace fonts {
}
using namespace fonts;

#ifndef _GFXFONT_H_
#define _GFXFONT_H_
typedef lgfx::GFXfont GFXfont;
typedef lgfx::GFXglyph GFXglyph;
#endif

#endif
36 changes: 19 additions & 17 deletions src/lgfx/lgfx_font_support.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ namespace lgfx
}

std::int32_t textWidth(const char *string) {
if (!string) return 0;
if (!string || !string[0]) return 0;

auto sx = _text_style.size_x;

Expand Down Expand Up @@ -860,7 +860,7 @@ namespace lgfx
std::int32_t cwidth = textWidth(string); // Find the pixel width of the string in the font
std::int32_t cheight = _font_metrics.height * _text_style.size_y;

{
if (string && string[0]) {
auto tmp = string;
do {
std::uint16_t uniCode = *tmp;
Expand Down Expand Up @@ -911,16 +911,18 @@ namespace lgfx
y -= int(_font_metrics.y_offset * _text_style.size_y);

_filled_x = 0;
do {
std::uint16_t uniCode = *string;
if (_text_style.utf8) {
do {
uniCode = decodeUTF8(*string);
} while (uniCode < 0x20 && *++string);
if (uniCode < 0x20) break;
}
sumX += (fpDrawChar)(this, x + sumX, y, uniCode, &_text_style, _font);
} while (*(++string));
if (string && string[0]) {
do {
std::uint16_t uniCode = *string;
if (_text_style.utf8) {
do {
uniCode = decodeUTF8(*string);
} while (uniCode < 0x20 && *++string);
if (uniCode < 0x20) break;
}
sumX += (fpDrawChar)(this, x + sumX, y, uniCode, &_text_style, _font);
} while (*(++string));
}
this->endWrite();

return sumX;
Expand Down Expand Up @@ -1054,10 +1056,10 @@ namespace lgfx
std::int32_t clip_bottom = me->_clip_b;

float sx = style->size_x;
float sy = style->size_y;
std::int32_t sh = fontHeight * style->size_y;

if ((x <= clip_right) && (clip_left < (x + fontWidth * sx ))
&& (y <= clip_bottom) && (clip_top < (y + fontHeight * sy ))) {
&& (y <= clip_bottom) && (clip_top < (y + sh ))) {
// if (!fillbg || sy != 1 || x < clip_left || y < clip_top || y + fontHeight > clip_bottom || x + fontWidth * sx > clip_right) {
me->startWrite();
if (fillbg) {
Expand All @@ -1066,17 +1068,17 @@ namespace lgfx
std::int32_t x0 = (fontWidth - margin) * sx;
std::int32_t x1 = (fontWidth ) * sx;
if (x0 < x1) {
me->writeFillRect(x + x0, y, x1 - x0, fontHeight * sy);
me->writeFillRect(x + x0, y, x1 - x0, sh);
}
}
}
std::int_fast8_t i = 0;
std::int32_t i = 0;
std::int32_t y1 = 0;
std::int32_t y0 = - 1;
do {
bool fill = y0 != y1;
y0 = y1;
y1 = ++i * sy;
y1 = ++i * sh / fontHeight;
std::uint8_t line = font_addr[0];
bool flg = line & 0x80;
std::int_fast8_t j = 1;
Expand Down
16 changes: 8 additions & 8 deletions src/lgfx/lgfx_img_support.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace lgfx
drawBmpFile(&file, path, x, y);
}

inline bool drawJpgFile(fs::FS &fs, const char *path, std::int32_t x=0, std::int32_t y=0, std::int32_t maxWidth=0, std::int32_t maxHeight=0, std::int32_t offX=0, std::int32_t offY=0, jpeg_div_t scale=JPEG_DIV_NONE) {
inline bool drawJpgFile(fs::FS &fs, const char *path, std::int32_t x=0, std::int32_t y=0, std::int32_t maxWidth=0, std::int32_t maxHeight=0, std::int32_t offX=0, std::int32_t offY=0, jpeg_div::jpeg_div_t scale=jpeg_div::jpeg_div_t::JPEG_DIV_NONE) {
FileWrapper file(fs);
return drawJpgFile(&file, path, x, y, maxWidth, maxHeight, offX, offY, scale);
}
Expand All @@ -58,7 +58,7 @@ namespace lgfx
draw_bmp(&data, x, y);
}

inline bool drawJpg(Stream *dataSource, std::int32_t x=0, std::int32_t y=0, std::int32_t maxWidth=0, std::int32_t maxHeight=0, std::int32_t offX=0, std::int32_t offY=0, jpeg_div_t scale=JPEG_DIV_NONE) {
inline bool drawJpg(Stream *dataSource, std::int32_t x=0, std::int32_t y=0, std::int32_t maxWidth=0, std::int32_t maxHeight=0, std::int32_t offX=0, std::int32_t offY=0, jpeg_div::jpeg_div_t scale=jpeg_div::jpeg_div_t::JPEG_DIV_NONE) {
StreamWrapper data;
data.set(dataSource);
return draw_jpg(&data, x, y, maxWidth, maxHeight, offX, offY, scale);
Expand All @@ -78,7 +78,7 @@ namespace lgfx
FileWrapper file;
drawBmpFile(&file, path, x, y);
}
inline bool drawJpgFile(const char *path, std::int32_t x=0, std::int32_t y=0, std::int32_t maxWidth=0, std::int32_t maxHeight=0, std::int32_t offX=0, std::int32_t offY=0, jpeg_div_t scale=JPEG_DIV_NONE) {
inline bool drawJpgFile(const char *path, std::int32_t x=0, std::int32_t y=0, std::int32_t maxWidth=0, std::int32_t maxHeight=0, std::int32_t offX=0, std::int32_t offY=0, jpeg_div::jpeg_div_t scale=jpeg_div::jpeg_div_t::JPEG_DIV_NONE) {
FileWrapper file;
return drawJpgFile(&file, path, x, y, maxWidth, maxHeight, offX, offY, scale);
}
Expand All @@ -95,7 +95,7 @@ namespace lgfx
data.set(bmp_data, bmp_len);
draw_bmp(&data, x, y);
}
bool drawJpg(const std::uint8_t *jpg_data, std::uint32_t jpg_len, std::int32_t x=0, std::int32_t y=0, std::int32_t maxWidth=0, std::int32_t maxHeight=0, std::int32_t offX=0, std::int32_t offY=0, jpeg_div_t scale=JPEG_DIV_NONE) {
bool drawJpg(const std::uint8_t *jpg_data, std::uint32_t jpg_len, std::int32_t x=0, std::int32_t y=0, std::int32_t maxWidth=0, std::int32_t maxHeight=0, std::int32_t offX=0, std::int32_t offY=0, jpeg_div::jpeg_div_t scale=jpeg_div::jpeg_div_t::JPEG_DIV_NONE) {
PointerWrapper data;
data.set(jpg_data, jpg_len);
return draw_jpg(&data, x, y, maxWidth, maxHeight, offX, offY, scale);
Expand All @@ -110,7 +110,7 @@ namespace lgfx
inline void drawBmp(DataWrapper *data, std::int32_t x=0, std::int32_t y=0) {
draw_bmp(data, x, y);
}
inline bool drawJpg(DataWrapper *data, std::int32_t x=0, std::int32_t y=0, std::int32_t maxWidth=0, std::int32_t maxHeight=0, std::int32_t offX=0, std::int32_t offY=0, jpeg_div_t scale=JPEG_DIV_NONE) {
inline bool drawJpg(DataWrapper *data, std::int32_t x=0, std::int32_t y=0, std::int32_t maxWidth=0, std::int32_t maxHeight=0, std::int32_t offX=0, std::int32_t offY=0, jpeg_div::jpeg_div_t scale=jpeg_div::jpeg_div_t::JPEG_DIV_NONE) {
return draw_jpg(data, x, y, maxWidth, maxHeight, offX, offY, scale);
}
inline void drawPng(DataWrapper *data, std::int32_t x = 0, std::int32_t y = 0, std::int32_t maxWidth = 0, std::int32_t maxHeight = 0, std::int32_t offX = 0, std::int32_t offY = 0, double scale = 1.0) {
Expand Down Expand Up @@ -247,7 +247,7 @@ namespace lgfx
file->postRead();
}

bool drawJpgFile(FileWrapper* file, const char *path, std::int32_t x, std::int32_t y, std::int32_t maxWidth, std::int32_t maxHeight, std::int32_t offX, std::int32_t offY, jpeg_div_t scale) {
bool drawJpgFile(FileWrapper* file, const char *path, std::int32_t x, std::int32_t y, std::int32_t maxWidth, std::int32_t maxHeight, std::int32_t offX, std::int32_t offY, jpeg_div::jpeg_div_t scale) {
bool res = false;
this->prepareTmpTransaction(file);
file->preRead();
Expand Down Expand Up @@ -356,15 +356,15 @@ namespace lgfx

#if !defined (__LGFX_TJPGDEC_H__)

bool draw_jpg(DataWrapper* data, std::int32_t x, std::int32_t y, std::int32_t maxWidth, std::int32_t maxHeight, std::int32_t offX, std::int32_t offY, jpeg_div_t scale)
bool draw_jpg(DataWrapper* data, std::int32_t x, std::int32_t y, std::int32_t maxWidth, std::int32_t maxHeight, std::int32_t offX, std::int32_t offY, jpeg_div::jpeg_div_t scale)
{
//ESP_LOGI("LGFX","drawJpg need include utility/tjpgd.h");
return false;
}

#else

bool draw_jpg(DataWrapper* data, std::int32_t x, std::int32_t y, std::int32_t maxWidth, std::int32_t maxHeight, std::int32_t offX, std::int32_t offY, jpeg_div_t scale)
bool draw_jpg(DataWrapper* data, std::int32_t x, std::int32_t y, std::int32_t maxWidth, std::int32_t maxHeight, std::int32_t offX, std::int32_t offY, jpeg_div::jpeg_div_t scale)
{
draw_jpg_info_t jpeg;
pixelcopy_t pc(nullptr, this->getColorDepth(), bgr888_t::depth, this->hasPalette());
Expand Down

0 comments on commit fd4e8e1

Please sign in to comment.