koreader / crengine

This is the KOReader CREngine fork. It cross-pollinates with the official CoolReader repository at https://github.com/buggins/coolreader, in case you were looking for that one.
72 stars 45 forks source link

Avoid some re-renderings, hanging punctuation tweaks #461

Closed poire-z closed 2 years ago

poire-z commented 2 years ago

setStatusFontSize/Face(): avoid spurious re-rendering

Update the font instance as soon its size or face is updated. Should help fixing https://github.com/koreader/koreader/pull/7312#issuecomment-986180114, see followup comments there. Also call updateLayout() on main font size change, as in 2-pages mode, the middle margin needs to be recomputed. See https://github.com/koreader/koreader/pull/8501#issuecomment-986271199. Otherwise, these would be noticed later and cause spurious and uneeded re-renderings.

Hanging punctuation: include it in native highlighting

The part of punctuation hanging in the right margin wasn't included in the "native" text selection highlighting because the range segments were cropped to frmline-width. So, remember by how much we overflow it, and extend the crop region (lineRect) to include it.

This is just a minor aesthetic issue - fortunately, it costs nothing as sizeof(formatted_line_t) does not change with this added field (still 32 bytes on x64, 24 bytes on arm32). When doing mutliple text selection with long press + pan, the box was rugged on the left side (following the hanging punctuation), but was flat on the right side (with parts of hanging punctuation glyphs not part of the text selection). When releasing, and having KOReader draw the boxes, we get the rugged box on both sides. This little change was just bugging me :)

Hanging punctuation: tweak hanging ratios again

Hanging ratio was a bit too heavy for guillemets. Make it lower, and dependant on the side (instead of the presence of a space alongside). Discussed at https://github.com/koreader/crengine/pull/355#issuecomment-986280651 and follow ups. Waiting for additional suggestions from @zwim before merging.


This change is Reviewable

zwim commented 2 years ago

No more comments from my side.

poire-z commented 2 years ago

Updated last commit with RTL paragraph info and use line_end_hanging instead of right_hanging for the asymmetry, https://github.com/koreader/crengine/pull/355#issuecomment-987707930.

poire-z commented 2 years ago

I don't think it's really noticable, but let's keep it as an example of what can be done.