#include "MainWindow.h" #include "ui_MainWindow.h" #include #include #include #include #include #include MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {// ui(new Ui::MainWindow) { //ui->setupUi(this); setMinimumSize(1500,300); //QFont fnt("/apps/esp/test/04B_03__.TTF"); fnt.setPixelSize(7); } MainWindow::~MainWindow() { //delete ui; } void MainWindow::paintEvent(QPaintEvent* e) { QString fontPath="/apps/ESP8266lib/tools/PixelFontGen/fonts/"; //FontBuilder::Result res = fb.build("/apps/esp/test/04B_03__.TTF"); //FontBuilder fb(10); fb.addChars("/apps/esp/PixelFont/PixelOperator.ttf", 16, 9, 32, 126); //FontBuilder fb(8); fb.addChars("/apps/esp/PixelFont/04B_03__.TTF", 8, 6, 32, 126); // OK //FontBuilder fb(8); fb.addChars("/apps/esp/PixelFont/Minecraft.ttf", 7.5, 6, 32, 126); // ugly //FontBuilder fb(10); fb.addChars("/apps/esp/PixelFont/EnterCommand.ttf", 15, 8, 32, 126); //FontBuilder fb(10); fb.addChars("/apps/esp/PixelFont/PIXELADE.TTF", 13, 8, 32, 126); //FontBuilder fb(10); fb.addChars("/apps/esp/PixelFont/C&C Red Alert [LAN].ttf", 110, 8, 32, 126); // ugly //FontBuilder fb(11); fb.addChars("/apps/esp/PixelFont/LeviWindows.ttf", 21, 9, 32, 126); //FontBuilder fb(9); fb.addChars("/apps/esp/PixelFont/SadMachine.ttf", 16, 8, 32, 126); //FontBuilder fb(7); fb.addChars("/apps/esp/PixelFont/bitdust1.ttf", 8, 6, 32, 126); // NICE //FontBuilder fb(10); fb.addChars("/apps/esp/PixelFont/pixeljosh6.ttf", 8, 7, 32, 126); //FontBuilder fb(9); fb.addChars("/apps/esp/PixelFont/BitPotionExt.ttf", 16, 7, 32, 126); //FontBuilder fb(10); fb.addChars("/apps/esp/PixelFont/PIXEARG_.TTF", 8, 8, 32, 126); //FontBuilder fb(10); fb.addChars(fontPath+"/Volter__28Goldfish_29.ttf", 9, 8, 32, 126); //FontBuilder fb(10); fb.addChars(fontPath+"/ti-83-plus-large.ttf", 8, 8, 32, 126); //FontBuilder fb(10); fb.addChars(fontPath+"/EXEPixelPerfect.ttf", 16, 8, 32, 126); //FontBuilder fb(10); fb.addChars(fontPath+"/new-gen.ttf", 9, 8, 32, 126); //FontBuilder fb(10); fb.addChars(fontPath+"/Comicoro.ttf", 16, 8, 32, 126, [](char c, QRect& r) { if(c=='1'){r.setX(-2); r.setWidth(5);} if(c=='-'){r.setX(-1); r.setWidth(5);} }); //FontBuilder fb(9); fb.addChars(fontPath+"/Nineteen Ninety Six.otf", 9, 7, 32, 126); //FontBuilder fb(15); fb.addChars(fontPath+"/Mario64.ttf", 12, 12, 32, 126); //FontBuilder fb(7); fb.addChars(fontPath+"/RNTG Larger.ttf", 7, 7, 32, 126, [](char c, QRect& r) {if(c=='1'){r.setX(0); r.setWidth(5);}}); //FontBuilder fb(8); fb.addChars(fontPath+"/Bonni-Africa.ttf", 8, 7, 32, 126); //FontBuilder fb(8); fb.addCharsMonoFromImage("/apps/esp/PixelFont/res/fnt1.png", 3, 32, 126); // test for icons FontBuilder fb(9); // for (int i = 0; i < 10; ++i) { fb.addDummy(); //fb.addIcon("/apps/esp/PixelFont/res/icon/wifi.svg", 12, 0); fb.addIcon("/apps/esp32/BoatRemote/icon/remote.svg", 11, 9, 0); fb.addIcon("/apps/esp32/BoatRemote/icon/boat.svg", 12, 9, 0); fb.addDummy(); // } const FontBuilder::Result& res = fb.get(); //res.dump("f1"); res.dump("fIcon"); struct F { QPainter&p; F(QPainter& p ) : p(p) {;} void setPixel(int x, int y) { p.drawPoint(QPointF(x,y)); } void fillRect(int x, int y, int w, int h) { p.fillRect(x,y,w,h, Qt::blue); } }; QPainter p(this); p.setPen(Qt::black); p.translate(10,10); F dst(p); // uint8_t data[] = {171,40,153,86,0,208,190,163,183,55,131,200,57,59,223,239,121,206,196,180,179,243,103,198,204,31,22,4,1,4,66,52,2,0,0,128,0,0,0,124,138,0,251,29,133,41,1,40,69,180,8,204,92,23,198,204,100,18,41,172,236,205,204,12,101,214,76,38,44,232,103,55,249,33,191,179,243,250,51,107,243,85,69,1,161,134,88,217,115,36,53,171,59,50,39,160,245,188,228,223,47,156,212,206,204,52,101,85,115,69,4,144,153,236,103,182,214,204,204,141,50,171,146,146,64,1,240,89,36,9,1,34,13,124,76,73,92,23,212,207,100,146,169,172,196,204,203,67,101,213,196,132,4,144,153,28,101,246,214,204,204,176,178,148,82,84,32,2,161,78,90,6,136,193,252,163,51,49,147,136,184,60,223,227,121,203,199,180,176,60,153,168,180,15,199,227,103,55,121,54,215,180,243,28,93,84,253,125,224,3,}; // uint16_t offsets[] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,4,9,13,18,23,24,26,28,31,34,36,39,40,45,49,51,55,59,63,67,71,75,79,83,84,85,88,91,94,98,103,107,111,114,118,121,124,128,132,135,139,143,146,151,155,159,163,167,171,175,178,182,186,191,195,199,202,204,209,211,214,218,220,224,228,231,235,239,242,246,250,251,253,257,258,263,267,271,275,279,282,286,289,293,297,302,305,309,313,316,317,320,324,330,}; FontWrap fnt(res.w, res.h, res.data.data(), res.offsets.data()); Draw d(dst); const char* txt = "!! ## AABBCCDD aabbccdd"; p.save(); p.scale(6,6); p.drawImage(0, 0, res.img); p.restore(); for (int i = 1; i <= 2; ++i) { p.save(); p.scale(i,i); fnt.draw("--!\"#$%&'()*+,-./--", 20, 100, dst); fnt.draw("--0123456789--", 20, 110, dst); fnt.draw("--abcdefghijklmnopqrstuvwxyz--", 20, 120, dst); fnt.draw("--ABCDEFGHIJKLMNOPQRSTUVWXYZ--", 20, 130, dst); p.restore(); } // d.drawRect(10,10, 30, 20); // uint8_t data = {255,255,255,255}; // uint16_t offsets = {0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; p.end(); }