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

Method getSpaceWidth

lib/GfxRenderer/GfxRenderer.cpp:1552–1568  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1550}
1551
1552int GfxRenderer::getSpaceWidth(const int fontId, const EpdFontFamily::Style style) const {
1553 // Advance table fast-path for SD card fonts during layout
1554 auto sdIt = sdCardFonts_.find(fontId);
1555 if (sdIt != sdCardFonts_.end() && sdIt->second->hasAdvanceTable()) {
1556 const uint8_t resolvedStyle = resolveSdCardStyle(*sdIt->second, style);
1557 return fp4::toPixel(sdIt->second->getAdvance(' ', resolvedStyle));
1558 }
1559
1560 const auto fontIt = fontMap.find(fontId);
1561 if (fontIt == fontMap.end()) {
1562 LOG_ERR("GFX", "Font %d not found", fontId);
1563 return 0;
1564 }
1565
1566 const EpdGlyph* spaceGlyph = fontIt->second.getGlyph(' ', style);
1567 return spaceGlyph ? fp4::toPixel(spaceGlyph->advanceX) : 0; // snap 12.4 fixed-point to nearest pixel
1568}
1569
1570int GfxRenderer::getSpaceAdvance(const int fontId, const uint32_t leftCp, const uint32_t rightCp,
1571 const EpdFontFamily::Style style) const {

Callers 2

measureWordWidthFunction · 0.80

Calls 6

resolveSdCardStyleFunction · 0.85
toPixelFunction · 0.85
endMethod · 0.80
hasAdvanceTableMethod · 0.80
getAdvanceMethod · 0.80
getGlyphMethod · 0.45

Tested by

no test coverage detected