-
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
Allow calculating a nicer normal line-height #603
base: master
Are you sure you want to change the base?
Conversation
ab4cf26
to
d68e84e
Compare
crengine/src/lvrend.cpp
Outdated
if (gRenderNormalLineHeight > 0) { | ||
int rem = enode->getDocument()->getDefaultFont()->getSize(); | ||
// Scale slightly to font size. Line height is partially a fixed offset and | ||
// partially relative to font size, so scale half of the offset. | ||
// Larger font sizes need less line height | ||
line_h = em + (gRenderNormalLineHeight - rem) * (em + rem) / (2 * em); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was wondering if all this and your comment could end up in a static inline int getFancyLineHeight(node, font_size)
.
But it's just one line of maths.
Anyway, keep the documentative comment here only (in renderFinalBlock), and for the 2 others (rather anecdotical : list item and <empty-line>
, just mention // See renderFinalBlock()
to avoid triplicating the comment.
crengine/include/lvdocviewprops.h
Outdated
@@ -90,6 +90,7 @@ | |||
// use 0 for old crengine behaviour (no support for absolute units and 1css px = 1 screen px) | |||
#define PROP_RENDER_DPI "crengine.render.dpi" | |||
#define PROP_RENDER_SCALE_FONT_WITH_DPI "crengine.render.scale.font.with.dpi" | |||
#define PROP_RENDER_NORMAL_LINE_HEIGHT "crengine.render.normal.line.height" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know these settings name are all rather odd and some reads as sentnce rather than as a tree :)
May be "crengine.render.line.height.normal" (so it reads like the CSS name:value, rather than a sentence) ?
crengine/src/lvrend.cpp
Outdated
int em = font->getSize(); | ||
if (gRenderNormalLineHeight > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int em...
can be put inside the if ... { }
.
d68e84e
to
de21aad
Compare
} | ||
} | ||
if (pstyle->cr_normal_line_height.type == css_val_inherited) { | ||
pstyle->cr_normal_line_height = parent_style->cr_normal_line_height; // inherit as-is | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just asking in case you did wonder and your brain worked better than mine:
No need to do as in the previous if (pstyle->line_height.type == css_val_inherited) {
just above, in case one uses line-height: normal; -cr-normal-line-height: 120% or 1.2em
on the parent and line-height: inherit; -cr-normal-line-height: inherit
on the child? (or some other kind of combination like that... my brain hurts trying to think about that :/)
int em = font->getSize(); | ||
if ( style->cr_normal_line_height.type == css_val_unspecified && | ||
style->cr_normal_line_height.value == css_generic_normal ) { | ||
line_h = font->getHeight(); // line-height: normal | ||
} | ||
else { | ||
line_h = lengthToPx(enode, style->cr_normal_line_height, em, em, true); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can shove the int em = font->getSize();
in the else {}
branch.
For koreader#, see description there
This change is