Skip to content
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 overriding font-based normal line-height #603

Merged
merged 7 commits into from
Nov 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions crengine/src/lvstsheet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3074,6 +3074,8 @@ static const char * css_cr_only_if_names[]={
"not-inpage-footnote",
"inside-inpage-footnote",
"not-inside-inpage-footnote",
"line-height-normal",
"not-line-height-normal",
NULL
};
enum cr_only_if_t {
Expand Down Expand Up @@ -3111,6 +3113,8 @@ enum cr_only_if_t {
cr_only_if_not_inpage_footnote,
cr_only_if_inside_inpage_footnote,
cr_only_if_not_inside_inpage_footnote,
cr_only_if_line_height_normal,
cr_only_if_not_line_height_normal,
};

static const char * css_cr_apply_func_names[]={
Expand Down Expand Up @@ -5328,6 +5332,27 @@ void LVCssDeclaration::apply( css_style_rec_t * style, const ldomNode * node ) c
return; // don't apply anything more of this declaration to this style
}
}
else if ( only_if == cr_only_if_line_height_normal || only_if == cr_only_if_not_line_height_normal ) {
if ( const ldomNode * parent_node = node->getParentNode(); style->line_height == css_length_t(css_val_inherited, 0) && parent_node ) {
const css_style_ref_t parent_style = node->getParentNode()->getStyle();
if ( !parent_style.isNull() && parent_style->line_height == css_length_t(css_val_unspecified, css_generic_normal) ) {
if ( only_if == cr_only_if_not_line_height_normal )
return; // don't apply anything more of this declaration to this style
}
else {
if ( only_if == cr_only_if_line_height_normal )
return; // don't apply anything more of this declaration to this style
}
}
else if ( style->line_height == css_length_t(css_val_unspecified, css_generic_normal) ) {
if ( only_if == cr_only_if_not_line_height_normal )
return; // don't apply anything more of this declaration to this style
}
else {
if ( only_if == cr_only_if_line_height_normal )
return; // don't apply anything more of this declaration to this style
}
}
}
break;
case cssd_cr_apply_func:
Expand Down
Loading