MCPcopy Create free account
hub / github.com/OpenEPaperLink/OpenEPaperLink / drawString

Function drawString

ESP32_AP-Flasher/src/contentmanager.cpp:695–761  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

693}
694
695void drawString(TFT_eSprite &spr, String content, int16_t posx, int16_t posy, String font, byte align, uint16_t color, uint16_t size, uint16_t bgcolor) {
696 // drawString(spr,"test",100,10,"bahnschrift30",TC_DATUM,TFT_RED);
697
698 // backwards compitibility
699 replaceVariables(content);
700 if (font.startsWith("fonts/calibrib")) {
701 String numericValueStr = font.substring(14);
702 int calibriSize = numericValueStr.toInt();
703 if (calibriSize != 30 && calibriSize != 16) {
704 font = "Signika-SB.ttf";
705 size = calibriSize;
706 }
707 }
708 if (font == "glasstown_nbp_tf") {
709 font = "tahoma9.vlw";
710 posy -= 8;
711 }
712 if (font == "7x14_tf") {
713 font = "REFSAN12.vlw";
714 posy -= 10;
715 }
716 if (font == "t0_14b_tf") {
717 font = "calibrib16.vlw";
718 posy -= 11;
719 }
720
721 switch (processFontPath(font)) {
722 case 2: {
723 // truetype
724 time_t t = millis();
725 truetypeClass truetype = truetypeClass();
726 void *framebuffer = spr.getPointer();
727 truetype.setFramebuffer(spr.width(), spr.height(), spr.getColorDepth(), static_cast<uint8_t *>(framebuffer));
728 File fontFile = contentFS->open(font, "r");
729 if (!truetype.setTtfFile(fontFile)) {
730 Serial.println("read ttf failed");
731 return;
732 }
733
734 truetype.setCharacterSize(size);
735 truetype.setCharacterSpacing(0);
736 if (align == TC_DATUM) {
737 posx -= truetype.getStringWidth(content) / 2;
738 }
739 if (align == TR_DATUM) {
740 posx -= truetype.getStringWidth(content);
741 }
742 truetype.setTextBoundary(posx, spr.width(), spr.height());
743 if (spr.getColorDepth() == 8) {
744 truetype.setTextColor(spr.color16to8(color), spr.color16to8(color));
745 } else {
746 truetype.setTextColor(color, color);
747 }
748 truetype.textDraw(posx, posy, content);
749 truetype.end();
750 } break;
751 case 3: {
752 // vlw bitmap font

Callers 12

drawDateFunction · 0.85
drawNumberFunction · 0.85
drawWeatherContentFunction · 0.85
drawForecastFunction · 0.85
stampTimeFunction · 0.85
getRssFeedFunction · 0.85
getCalFeedFunction · 0.85
getDayAheadFeedFunction · 0.85
drawQRFunction · 0.85
drawBuienradarFunction · 0.85
drawTimestampFunction · 0.85
drawElementFunction · 0.85

Calls 15

replaceVariablesFunction · 0.85
processFontPathFunction · 0.85
truetypeClassClass · 0.85
setFramebufferMethod · 0.80
widthMethod · 0.80
heightMethod · 0.80
openMethod · 0.80
setTtfFileMethod · 0.80
printlnMethod · 0.80
setCharacterSizeMethod · 0.80
setCharacterSpacingMethod · 0.80
getStringWidthMethod · 0.80

Tested by

no test coverage detected