Xteink-X4-crosspoint-reader/lib
Jake Kenneally 2cf799f45b
feat: Add CSS parsing and CSS support in EPUBs (#411)
## Summary

* **What is the goal of this PR?**

- Adds basic CSS parsing to EPUBs and determine the CSS rules when
rendering to the screen so that text is styled correctly. Currently
supports bold, underline, italics, margin, padding, and text alignment

## Additional Context

- My main reason for wanting this is that the book I'm currently
reading, Carl's Doomsday Scenario (2nd in the Dungeon Crawler Carl
series), relies _a lot_ on styled text for telling parts of the story.
When text is bolded, it's supposed to be a message that's rendered
"on-screen" in the story. When characters are "chatting" with each
other, the text is bolded and their names are underlined. Plus, normal
emphasis is provided with italicizing words here and there. So, this
greatly improves my experience reading this book on the Xteink, and I
figured it was useful enough for others too.
- For transparency: I'm a software engineer, but I'm mostly frontend and
TypeScript/JavaScript. It's been _years_ since I did any C/C++, so I
would not be surprised if I'm doing something dumb along the way in this
code. Please don't hesitate to ask for changes if something looks off. I
heavily relied on Claude Code for help, and I had a lot of inspiration
from how [microreader](https://github.com/CidVonHighwind/microreader)
achieves their CSS parsing and styling. I did give this as good of a
code review as I could and went through everything, and _it works on my
machine_ 😄

### Before

![IMG_6271](https://github.com/user-attachments/assets/dba7554d-efb6-4d13-88bc-8b83cd1fc615)

![IMG_6272](https://github.com/user-attachments/assets/61ba2de0-87c9-4f39-956f-013da4fe20a4)

### After

![IMG_6268](https://github.com/user-attachments/assets/ebe11796-cca9-4a46-b9c7-0709c7932818)

![IMG_6269](https://github.com/user-attachments/assets/e89c33dc-ff47-4bb7-855e-863fe44b3202)

---

### AI Usage

Did you use AI tools to help write this code? **YES**, Claude Code
2026-02-05 21:28:10 +11:00
..
EpdFont feat: Add CSS parsing and CSS support in EPUBs (#411) 2026-02-05 21:28:10 +11:00
Epub feat: Add CSS parsing and CSS support in EPUBs (#411) 2026-02-05 21:28:10 +11:00
expat Add expat and swap out EPUB HTML parser (#2) 2025-12-06 20:57:24 +11:00
FsHelpers Add exFAT support (#150) 2025-12-30 16:09:30 +11:00
GfxRenderer feat: Add CSS parsing and CSS support in EPUBs (#411) 2026-02-05 21:28:10 +11:00
hal fix: don't wake up after USB connect (#644) 2026-02-01 22:19:33 +11:00
JpegToBmpConverter fix: #348 fit cover artifacts 2 (#465) 2026-01-27 20:21:15 +11:00
KOReaderSync fix: Fix KOReader document md5 calculation for binary matching progress sync (#529) 2026-01-27 22:14:07 +11:00
miniz Stream inflated EPUB HTMLs down to disk instead of inflating in memory (#4) 2025-12-08 00:39:17 +11:00
OpdsParser fix: OPDS browser OOM (#403) 2026-01-22 01:43:51 +11:00
picojpeg Add JPG image support (#23) 2025-12-21 17:15:17 +11:00
Serialization Add exFAT support (#150) 2025-12-30 16:09:30 +11:00
Txt Add TXT file reader support (#240) 2026-01-14 21:36:40 +11:00
Utf8 fix: truncating chapter titles using UTF-8 safe function (#599) 2026-02-01 22:23:48 +11:00
Xtc feat: Extract author from XTC/XTCH files (#563) 2026-01-27 22:56:51 +11:00
ZipFile perf: optimize large EPUB indexing from O(n^2) to O(n) (#458) 2026-01-28 01:29:15 +11:00
README Public release 2025-12-03 22:06:45 +11:00

This directory is intended for project specific (private) libraries.
PlatformIO will compile them to static libraries and link into the executable file.

The source code of each library should be placed in a separate directory
("lib/your_library_name/[Code]").

For example, see the structure of the following example libraries `Foo` and `Bar`:

|--lib
|  |
|  |--Bar
|  |  |--docs
|  |  |--examples
|  |  |--src
|  |     |- Bar.c
|  |     |- Bar.h
|  |  |- library.json (optional. for custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html
|  |
|  |--Foo
|  |  |- Foo.c
|  |  |- Foo.h
|  |
|  |- README --> THIS FILE
|
|- platformio.ini
|--src
   |- main.c

Example contents of `src/main.c` using Foo and Bar:
```
#include <Foo.h>
#include <Bar.h>

int main (void)
{
  ...
}

```

The PlatformIO Library Dependency Finder will find automatically dependent
libraries by scanning project source files.

More information about PlatformIO Library Dependency Finder
- https://docs.platformio.org/page/librarymanager/ldf.html