-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect font rendering in a specific book #516
Comments
The styling there is certainly bizarre, but could it be handled in a way that doesn't make text disappear? Or is this the quirk of WebKit rendering and shouldn't be worked around in the engine? And what about the font, compare it to the first picture, it's a combination of thick and thin strokes, but the engine draws it in nearly uniform lines. |
Dunno, would need investigating. This is how some (older) version of Calibre renders it: The bottom part is me having added: <div style='font-family:"Romanesque";'>O T P</div>
<div style='font-family:"Romanesque"; font-size:500%'>O T P</div>
<div style='font-family:"Romanesque"; font-size:500%; font-weight: bold'>O T P</div> And this is how koreader/crengine renders that other part:
That may be because on this, we may do better than webengines - and here, better happens to make it worse :) @font-face{
font-family:"Romanesque";
src:url(../fonts/Romanesque_Normal.ttf);
font-weight:bold;
font-style:normal;
} so, this defines a font named "Romanesque", and says that when requesting it for an element with Add |
I think strictly speaking you may be supposed to see a variety of things drawn over each other with line-height 0, so without looking closer I suspect seeing nothing could be wrong. That doesn't mean that which happens in Foliate is right of course; I'd expect something closer to what your old Calibre screenshot shows really. |
Thank you for the extensive and clear explanations, feel free to close the issue as I tend to agree with your approach. |
Investigated a bit why it would not be displayed - and its drawing is actually skipped. Under some conditions of line-height and the negative top/bottom margins, the inner content (so, actually, a paragraph with the letter "O") may be positionned fully outside this little 1px-height box - and this is a condition for its drawing to be skipped. If it would just intercept with this little box, it would be drawn - and that is why when tweaking line-height and margins, we may get it to be displayed. If I tweak the check for drawing outside content: @@ -9609,7 +9610,9 @@ void DrawDocument( LVDrawBuf & drawbuf, ldomNode * enode, int x0, int y0, int dx
int height = fmt.getHeight();
int top_overflow = fmt.getTopOverflow();
int bottom_overflow = fmt.getBottomOverflow();
- if ( (doc_y + height + bottom_overflow <= 0 || doc_y - top_overflow >= 0 + dy) ) {
+ printf("%d + %d + %d = %d || %d\n", doc_y, height, bottom_overflow, doc_y + height + bottom_overflow, doc_y - top_overflow - dy);
+ if ( enode->getParentNode() && enode->getParentNode()->isFloatingBox() ) { printf("goingon\n");} else
+ if ( (doc_y + height + bottom_overflow < 0 || doc_y - top_overflow >= 0 + dy) ) {
// We don't have to draw this node.
// Except TR which may have cells with rowspan>1, and even though
// this TR is out of range, it must draw a rowspan>1 cell, so it we get the above picture, which is not even nice, as the float is only 1px, so it's overflowing content override the text. Negative margins probably, which is something we are quite limited at handling, mostly because it's not worth the pain getting into it :) I'm happy enough we can draw corectly "dense" floats :) I'm not sure the above fix would be the right thing in other cases, so I won't touch anything. |
@poire-z Yes, something in that general direction is the rendering I expected to see with line-height: 0 in this scenario. |
In the linked book an embedded font is being used to implement drop caps. In the web and book render modes they aren't visible at all, while in the flat and legacy modes they are visible but the font rendering seems incorrect.
As the book looks like it has been authored with Apple tools I checked it in Foliate which also uses the WebKit engine for rendering. So here is what I assume a reference look of the document in Foliate:
Web mode:
Flat mode:
The file:
The Ruby in the Smoke.zip
I've tried to extract the font and embed it in a minimal test document created in calibre's ebook-editor and it looked right in KOReader, so probably the font itself isn't the problem, but some combination of the document layout and engine quirks is to blame?
The text was updated successfully, but these errors were encountered: