diff options
author | bptato <nincsnevem662@gmail.com> | 2024-02-22 03:00:48 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-02-22 03:00:48 +0100 |
commit | def15ede4fbd686b0ee9b193f41b2a47190aa43a (patch) | |
tree | f5e19e6dd04e671e7bcfede37202c91355e59833 /src/layout | |
parent | 91d1e18d42a63d355095cf20bbd1767ecd2393fc (diff) | |
download | chawan-def15ede4fbd686b0ee9b193f41b2a47190aa43a.tar.gz |
layout: remove justify
The way `justify' was implemented just made text annoying to read. (The algorithm of distributing spacing evenly does not really work on a cell-based screen because of rounding errors.) CSS 2.1 says: > Conforming user agents may interpret the value 'justify' as 'left' or > 'right', depending on whether the element's default writing direction > is left-to-right or right-to-left, respectively. Since we have no bidi yet, just interpret it as `left'. Maybe in the future we could add an implementation that tries to align line box lengths instead of their contents, but this will probably be difficult to get right.
Diffstat (limited to 'src/layout')
-rw-r--r-- | src/layout/engine.nim | 21 |
1 files changed, 1 insertions, 20 deletions
diff --git a/src/layout/engine.nim b/src/layout/engine.nim index 170e6443..06e95cdc 100644 --- a/src/layout/engine.nim +++ b/src/layout/engine.nim @@ -319,7 +319,7 @@ proc horizontalAlignLine(ictx: var InlineContext, state: InlineState, max(ictx.size.w, ictx.space.w.u) # we don't support directions for now so left = start and right = end case state.computed{"text-align"} - of TEXT_ALIGN_START, TEXT_ALIGN_LEFT, TEXT_ALIGN_CHA_LEFT: + of TEXT_ALIGN_START, TEXT_ALIGN_LEFT, TEXT_ALIGN_CHA_LEFT, TEXT_ALIGN_JUSTIFY: discard of TEXT_ALIGN_END, TEXT_ALIGN_RIGHT, TEXT_ALIGN_CHA_RIGHT: # move everything @@ -334,25 +334,6 @@ proc horizontalAlignLine(ictx: var InlineContext, state: InlineState, for atom in line.atoms.mitems: atom.offset.x += x ictx.size.w = max(atom.offset.x + atom.size.w, ictx.size.w) - of TEXT_ALIGN_JUSTIFY: - if not state.computed.whitespacepre and not last: - var sumwidth: LayoutUnit = 0 - var spaces = 0 - for atom in line.atoms.mitems: - if atom.t == INLINE_SPACING: - discard - else: - inc spaces - sumwidth += atom.size.w - dec spaces - if spaces > 0: - let spacingwidth = (width - sumwidth) div spaces - line.size.w = 0 - for atom in line.atoms.mitems: - atom.offset.x = line.size.w - if atom.t == INLINE_SPACING: - atom.size.w = spacingwidth - line.size.w += atom.size.w # If necessary, update ictx's width. ictx.size.w = max(line.size.w, ictx.size.w) |