Skip to content

Improve anti aliased text rendering#25

Open
alexfaria wants to merge 4 commits intobitbank2:mainfrom
alexfaria:main
Open

Improve anti aliased text rendering#25
alexfaria wants to merge 4 commits intobitbank2:mainfrom
alexfaria:main

Conversation

@alexfaria
Copy link

Hi @bitbank2 - this library is amazing and I am loving your work

I am using your library to control a LILYGO T5 E-Paper S3 Pro and I'm displaying some anti aliased text

I've encountered some small visual bugs and I'm also hoping to add dark mode support

Hopefully this PR helps to explain what the problem is and possible fixes

  • Inverted the grayscale color mapping when the background is black (bbepWriteStringCustom, src/bb_ep_gfx.inl).
  • Added a check to only draw pixels that are not the background color, which prevents drawing transparent pixels and avoids overlapping pixels from previous characters (important for italic fonts) (bbepWriteStringCustom, src/bb_ep_gfx.inl).
  • Cleared the line buffer before decoding each line to prevent artifacts from previous data (bbepWriteStringCustom, src/bb_ep_gfx.inl).
  • Applied a mask to the last byte of the line buffer when the width is not a multiple of 8, improving edge rendering accuracy (bbepWriteStringCustom, src/bb_ep_gfx.inl).

Before - note the vertical edges and the clipped italic text
image

Before - white text on black background
image

After - fixed vertical edges and clipped text
image

After - inverted grays if background is black
image

Only call pfnSetPixelFast when the computed font color differs from the background (iBG). This prevents drawing transparent/background pixels, avoiding overlap artifacts (e.g., with italic fonts) and reducing unnecessary pixel writes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant