feat(epub): overhaul border system to support individual sides and radii (#44)

- Refactored `BlockStyle` to replace unified border/radius fields with explicit properties for all four sides and corners.
- Overhauled `CssParser` to correctly handle CSS border shorthands (`border-bottom`, `border-width`, etc.) and multi-value `border-radius`.
- Implemented `drawCssBorders` custom modifier to render side-specific borders, styles (dashed/dotted), and background clipping.
- Updated `Paginator` measurement logic to calculate block height and splitting points based on individual side widths.
This commit is contained in:
Aryan 2026-03-08 10:31:07 +05:30 committed by GitHub
parent 68c4611187
commit dff236fa7f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 434 additions and 206 deletions

View file

@ -221,11 +221,20 @@ class ContentStyler(
} else {
original.backgroundColor
}
val newBorder = original.border?.let {
val newBorderColor = CssParser.adaptColorForTheme(it.color, isDarkTheme, isBackground = false)
it.copy(color = newBorderColor)
fun themeBorder(b: BorderStyle?): BorderStyle? {
if (b == null) return null
val newColor = CssParser.adaptColorForTheme(b.color, isDarkTheme, isBackground = false)
return b.copy(color = newColor)
}
original.copy(backgroundColor = newBgColor, border = newBorder)
original.copy(
backgroundColor = newBgColor,
borderTop = themeBorder(original.borderTop),
borderRight = themeBorder(original.borderRight),
borderBottom = themeBorder(original.borderBottom),
borderLeft = themeBorder(original.borderLeft)
)
}
return style.copy(spanStyle = newSpanStyle, blockStyle = newBlockStyle)