# Port Upstream PR #978: Improve Font Drawing Performance **Date:** 2026-02-19 **Branch:** `mod/more-upstream-patches-for-1.1.0` **Commit:** `3a06418` ## Task Port upstream PR #978 (perf: Improve font drawing performance) which optimizes glyph rendering by 15-23% on device. ## Changes Made ### Cherry-picked from upstream (commit `07d715e`) - **`lib/GfxRenderer/GfxRenderer.cpp`**: Introduced `TextRotation` enum and `renderCharImpl` template function that consolidates normal and 90-CW-rotated rendering paths. Hoists the `is2Bit` conditional above pixel loops (eliminating per-pixel branch). Uses `if constexpr` for compile-time rotation path selection. Fixes operator precedence bug in `bmpVal` calculation. - **`lib/GfxRenderer/GfxRenderer.h`**: Changed `renderChar` signature (`const int* y` -> `int* y`). Moved `getGlyphBitmap` from private to public (needed by the free-function template). ### Mod-specific extension - Extended `TextRotation` enum with `Rotated90CCW` and refactored `drawTextRotated90CCW` to delegate to the template. This fixed two bugs in the mod's CCW code: 1. Operator precedence bug in `bmpVal`: `3 - (byte >> bit_index) & 0x3` -> `3 - ((byte >> bit_index) & 0x3)` 2. Missing compressed font support: was using raw `bitmap[offset]` instead of `getGlyphBitmap()` ## Recovery of Discarded Changes During plan-mode dry-run cherry-pick reset, `git checkout -- .` inadvertently discarded unstaged working tree changes in 12 files (from PRs #1005, #1010, #1003). These were recovered by: - Cherry-picking upstream commits `cabbfcf` (#1005) and `63b2643` (#1010) with conflict resolution (kept mod's `CrossPointSettings.h` include) - Fetching unmerged PR #1003 branch and manually applying the diff (ImageBlock::isCached, Page placeholder rendering, EpubReaderActivity phased rendering) - Committed as `18be265` ## Build PlatformIO build succeeded. RAM: 31.5%, Flash: 70.4%.