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

Method getAdvance

lib/EpdFont/SdCardFont.cpp:1071–1090  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1069}
1070
1071uint16_t SdCardFont::getAdvance(uint32_t codepoint, uint8_t style) const {
1072 style &= (MAX_STYLES - 1);
1073 if (!advanceTable_[style]) return 0;
1074 const AdvanceEntry* table = advanceTable_[style];
1075 const uint32_t size = advanceTableSize_[style];
1076 // Binary search sorted by codepoint
1077 uint32_t lo = 0, hi = size;
1078 while (lo < hi) {
1079 uint32_t mid = lo + (hi - lo) / 2;
1080 if (table[mid].codepoint < codepoint) {
1081 lo = mid + 1;
1082 } else {
1083 hi = mid;
1084 }
1085 }
1086 if (lo < size && table[lo].codepoint == codepoint) {
1087 return table[lo].advanceX;
1088 }
1089 return 0;
1090}
1091
1092// Given a sorted array of unique codepoints, resolve glyph indices per style,
1093// batch-read advanceX from SD, and merge into the persistent advance table.

Callers 3

getSpaceWidthMethod · 0.80
getSpaceAdvanceMethod · 0.80
getTextAdvanceXMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected