MCPcopy Create free account
hub / github.com/crosspoint-reader/crosspoint-reader / handleFontList

Method handleFontList

src/network/CrossPointWebServer.cpp:1718–1757  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1716}
1717
1718void CrossPointWebServer::handleFontList() const {
1719 // Pick up any uploads/deletes that happened since the last reader load.
1720 const_cast<SdCardFontSystem&>(sdFontSystem).refreshIfDirty();
1721 const auto& families = sdFontSystem.registry().getFamilies();
1722
1723 JsonDocument doc;
1724 JsonArray arr = doc["families"].to<JsonArray>();
1725 doc["maxFamilies"] = SdCardFontRegistry::MAX_SD_FAMILIES;
1726
1727 for (const auto& family : families) {
1728 JsonObject fObj = arr.add<JsonObject>();
1729 fObj["name"] = family.name;
1730
1731 JsonArray sizes = fObj["sizes"].to<JsonArray>();
1732 for (uint8_t s : family.availableSizes()) {
1733 sizes.add(s);
1734 }
1735
1736 JsonArray files = fObj["files"].to<JsonArray>();
1737 for (const auto& file : family.files) {
1738 JsonObject fileObj = files.add<JsonObject>();
1739 // Extract filename from full path
1740 const char* name = strrchr(file.path.c_str(), '/');
1741 fileObj["name"] = name ? name + 1 : file.path.c_str();
1742
1743 // Stat the file for size
1744 HalFile f;
1745 if (Storage.openFileForRead("WEB", file.path.c_str(), f)) {
1746 fileObj["size"] = static_cast<unsigned long>(f.size());
1747 f.close();
1748 } else {
1749 fileObj["size"] = 0;
1750 }
1751 }
1752 }
1753
1754 String json;
1755 serializeJson(doc, json);
1756 server->send(200, "application/json", json);
1757}
1758
1759void CrossPointWebServer::handleFontUploadData() {
1760 HTTPUpload& upload = server->upload();

Callers

nothing calls this directly

Calls 5

refreshIfDirtyMethod · 0.80
availableSizesMethod · 0.80
openFileForReadMethod · 0.80
sizeMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected