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

wrong text justification at last line of page caused by consecutive ruby elements #985

Closed
MurakamiShinyu opened this issue Sep 9, 2022 · 3 comments · Fixed by #988 or vivliostyle/vivliostyle-cli#329
Assignees
Labels
bug P1 Priority 1: Required for MVP (Minimum Viable Product)
Milestone

Comments

@MurakamiShinyu
Copy link
Member

MurakamiShinyu commented Sep 9, 2022

Test sample: https://gist.github.com/MurakamiShinyu/ea376875cc6943d22cc3b740e9843975

Test with Vivliostyle Viewer (v2.17.2):
https://vivliostyle.github.io/viewer/v2.17.2/#src=https://gist.githubusercontent.com/MurakamiShinyu/ea376875cc6943d22cc3b740e9843975/raw/page-last-line-bug.html

Result screenshot:

Screen Shot 2022-09-11 at 18 33 41

@MurakamiShinyu MurakamiShinyu added bug P1 Priority 1: Required for MVP (Minimum Viable Product) labels Sep 9, 2022
@MurakamiShinyu MurakamiShinyu self-assigned this Sep 9, 2022
@MurakamiShinyu
Copy link
Member Author

MurakamiShinyu commented Sep 11, 2022

この問題が起きる条件は、段落の最後の下端の位置がページエリアの下端の位置にぎりぎり入るか入らないか微妙な位置で、その段落内に連続した ruby 要素(<ruby>銀<rt>ぎん</rt></ruby><ruby>河<rt>が</rt></ruby>)があることなど。

Chromiumで最小文字サイズがあるためルビが大きめになってしまう問題を解決するためにrt要素にzoomプロパティでの縮小をするようにしていることが関係する。

Chromiumで、zoomプロパティで縮小が指定されている要素があると、

const rects = range.getClientRects();

で返される rects 配列のうちその要素に対するrect の bottom が実際の要素のその要素の下端の位置よりも大きな値になる。
その結果、段落のテキスト内での分割位置を決める処理が不具合を起こしている。

getRangeBox()の処理で、ruby要素など分割位置を決める処理で問題が起きる可能性がある要素を除外するようにしているが、ruby要素が2つ連続していると、この除外が働かない。次のところを直すとよさそうである:

} else if (
/^r(uby|[bt]c?)$/.test((node as Element).localName) ||
LayoutHelper.isSpecialInlineDisplay(
this.clientLayout.getElementComputedStyle(node as Element).display,
)
) {
// ruby, inline-block, etc.
seekRange = !haveStart;
if (seekRange) {
range.setStartBefore(node);
haveStart = true;
lastGood = node;
}

@MurakamiShinyu MurakamiShinyu changed the title wrong text justification with text-spacing on last line of page wrong text justification at last line of page when consecutive ruby elements exist Sep 11, 2022
@MurakamiShinyu MurakamiShinyu added this to the v2.17.3 milestone Sep 11, 2022
@MurakamiShinyu MurakamiShinyu changed the title wrong text justification at last line of page when consecutive ruby elements exist wrong text justification at last line of page caused by consecutive ruby elements Sep 12, 2022
MurakamiShinyu added a commit that referenced this issue Sep 12, 2022
@MurakamiShinyu
Copy link
Member Author

MurakamiShinyu added a commit to vivliostyle/vivliostyle-cli that referenced this issue Sep 17, 2022
https://github.com/vivliostyle/vivliostyle.js/releases/tag/v2.18.0

### Features

- **viewer:** add crop marks setting ([1d0834b](vivliostyle/vivliostyle.js@1d0834b)), closes [#993](vivliostyle/vivliostyle.js#993)
- **viewer:** change "User Style" to "Custom Style" and treat it as an author stylesheet by default ([bdb26d4](vivliostyle/vivliostyle.js@bdb26d4)), closes [#991](vivliostyle/vivliostyle.js#991)
- **viewer:** set bookMode=true as default ([5411264](vivliostyle/vivliostyle.js@5411264)), closes [#992](vivliostyle/vivliostyle.js#992)

### Bug Fixes

- error with `<object>` tag ([9e9565f](vivliostyle/vivliostyle.js@9e9565f)), closes [#995](vivliostyle/vivliostyle.js#995)
- errors on the Acid2 Browser Test ([849a604](vivliostyle/vivliostyle.js@849a604))
- failed some of the css-variables tests ([5d0f324](vivliostyle/vivliostyle.js@5d0f324))
- incorrect column-rule positioning in vertical writing mode ([3cc0e01](vivliostyle/vivliostyle.js@3cc0e01)), closes [#978](vivliostyle/vivliostyle.js#978)
- unnecessary page break caused by ruby elements ([21eb17c](vivliostyle/vivliostyle.js@21eb17c)), closes [#987](vivliostyle/vivliostyle.js#987)
- valid CSS rules ignored after parsing error with invalid or unsupported CSS rule ([5e76ed5](vivliostyle/vivliostyle.js@5e76ed5)), closes [#597](vivliostyle/vivliostyle.js#597) [#976](vivliostyle/vivliostyle.js#976)
- **viewer:** problem on author/user stylesheet switch ("Set as user stylesheet" checkbox) ([2799a34](vivliostyle/vivliostyle.js@2799a34))
- **viewer:** tweak Reset Custom Style checkbox behavior ([9c96ccb](vivliostyle/vivliostyle.js@9c96ccb))
- **viewer:** unbound this error "Cannot set properties of undefined" ([2505458](vivliostyle/vivliostyle.js@2505458))
- wrong cascading on shorthand property with CSS variable ([2ee7927](vivliostyle/vivliostyle.js@2ee7927)), closes [#979](vivliostyle/vivliostyle.js#979)
- wrong cascading with CSS !important ([fb1dae2](vivliostyle/vivliostyle.js@fb1dae2)), closes [#986](vivliostyle/vivliostyle.js#986)
- wrong text justification at last line of page caused by consecutive ruby elements ([ad26952](vivliostyle/vivliostyle.js@ad26952)), closes [#985](vivliostyle/vivliostyle.js#985)
MurakamiShinyu added a commit to vivliostyle/vivliostyle-cli that referenced this issue Sep 18, 2022
…ug fixes

- https://github.com/vivliostyle/vivliostyle.js/releases/tag/v2.18.1
- https://github.com/vivliostyle/vivliostyle.js/releases/tag/v2.18.0

### Features

- **viewer:** add crop marks setting ([1d0834b](vivliostyle/vivliostyle.js@1d0834b)), closes [#993](vivliostyle/vivliostyle.js#993)
- **viewer:** change "User Style" to "Custom Style" and treat it as an author stylesheet by default ([bdb26d4](vivliostyle/vivliostyle.js@bdb26d4)), closes [#991](vivliostyle/vivliostyle.js#991)
- **viewer:** set bookMode=true as default ([5411264](vivliostyle/vivliostyle.js@5411264)), closes [#992](vivliostyle/vivliostyle.js#992)

### Bug Fixes

- error with `<object>` tag ([9e9565f](vivliostyle/vivliostyle.js@9e9565f)), closes [#995](vivliostyle/vivliostyle.js#995)
- errors on the Acid2 Browser Test ([849a604](vivliostyle/vivliostyle.js@849a604))
- failed some of the css-variables tests ([5d0f324](vivliostyle/vivliostyle.js@5d0f324))
- incorrect column-rule positioning in vertical writing mode ([3cc0e01](vivliostyle/vivliostyle.js@3cc0e01)), closes [#978](vivliostyle/vivliostyle.js#978)
- unnecessary page break caused by ruby elements ([21eb17c](vivliostyle/vivliostyle.js@21eb17c)), closes [#987](vivliostyle/vivliostyle.js#987)
- valid CSS rules ignored after parsing error with invalid or unsupported CSS rule ([5e76ed5](vivliostyle/vivliostyle.js@5e76ed5)), closes [#597](vivliostyle/vivliostyle.js#597) [#976](vivliostyle/vivliostyle.js#976)
- wrong cascading on shorthand property with CSS variable ([2ee7927](vivliostyle/vivliostyle.js@2ee7927)), closes [#979](vivliostyle/vivliostyle.js#979)
- wrong cascading with CSS !important ([fb1dae2](vivliostyle/vivliostyle.js@fb1dae2)), closes [#986](vivliostyle/vivliostyle.js#986)
- wrong text justification at last line of page caused by consecutive ruby elements ([ad26952](vivliostyle/vivliostyle.js@ad26952)), closes [#985](vivliostyle/vivliostyle.js#985)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug P1 Priority 1: Required for MVP (Minimum Viable Product)
Projects
None yet
1 participant