messageFeed branch: message body with CJK characters is truncated in height #59

Closed
opened 2021-11-15 15:12:25 +00:00 by shunf4 · 8 comments
Contributor

image

I'm afraid bodyMetrics.boundingRect() doesn't do well in measuring the space of texts, if they contain CJK characters.

The texts:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus at mollis eros. Fusce tempor nunc sed massa porta, a bibendum enim blandit. Vivamus tincidunt, purus eu vulputate pharetra, nulla purus malesuada est, faucibus finibus ligula orci quis nisl. Mauris cursus nisi non erat molestie feugiat tincidunt quis ligula. Duis nec sodales lacus, et accumsan urna. Sed malesuada at arcu eget elementum. Maecenas volutpat porta elit, vel vehicula nibh. Vestibulum vestibulum nisi eget mauris tristique, id vestibulum ex facilisis. Nullam dapibus euismod purus. Donec luctus orci erat, vel pulvinar leo ornare sed. Vestibulum sit amet pretium ipsum, gravida vulputate quam. Cras id nunc vel est tincidunt laoreet. Proin sodales tempor nulla, nec ultrices sem. Suspendisse iaculis orci sem, sed scelerisque velit placerat sit amet.

In vehicula varius mauris in elementum. Ut ligula enim, vulputate vitae nunc sed, porta ullamcorper dui. Nullam ullamcorper varius tristique. Cras ornare aliquam velit, quis suscipit enim lobortis non. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Suspendisse potenti. Cras pretium venenatis enim, faucibus accumsan ex maximus ac. Duis quis imperdiet mauris. Donec pellentesque metus a arcu tempor, a tristique tortor finibus. Aenean vitae felis eu libero tempus vestibulum. Cras in molestie urna. Proin volutpat egestas tellus quis laoreet.
野尾都名擢魔遊メソイ、るぬうみなんそぬ巣区都れムキアチイミチヨネヘヨ遊そ。んあまめハッレイ、しこゆせかむつなる名絵舳保しめね二素他離離巣樹るて列絵露魔等ねふゃす、う知遊こめ屋課エイエヨミ課日留、よゆツョヤヒ無鵜きけひ。らきへも都野ちえ、な津瀬るカニモネマへら差屋のかあ素魔鵜根ま瀬個にそおるもまみふ。保よかすよさろりためたてほ御露無都やゅむ無根よくえソヌソモ譜個えすた。

まえちえのも派目保魔名。そむえ。れふる雲留列さらめ名擢魔いと、ひつ知無等ゃふせさほょ、とく差派譜舳つあほ瀬夜、派保目遊差せっゅ列瀬阿ちうもく御夜瀬。よふよ遊差ふあ。

お素知おも根留目目津津遊ぬゅるゅ列列魔無ゆつもちョナヒヤ「ヌへいょせ氏阿課譜」差二。目毛ゅ舳離くくなほもひめにんヘシフラマつつろゆい御もえてっめは氏ふ以毛個雲瀬夜鵜素夜保そ、日せほつむゆ離根えりやせるかはれのやゅめょるっ課二いりおま魔阿野つゅめ魔以雲雲、とうあ、夜ょ派留まほい差魔御、保瀬知野根留。区遊離けひた。区レソソ。
表両約村悪境福測社鑑図元関前項経均賀。際検的断台漠始高写織前拠発係聞。業前切長野婚芸帯宅車図間月所。鹿趣功心育海頭週紀件力青告稿府届波。表責工棋剖条財図社目種夜上。続属応以罰培転員歳事壁拝開堀止者。記距力現綱催応西本政険年的旅。陸速鑑節三権票係犯後問停。感活細格組沢詰度民回力鑑況。労機恨紙粗浜訃供大目戦抜給事想。

使増岡個定載北安体属践希学。所好転転策陸間激況謙洋布読報。囲勢民意惑思選載億引傷務駒。北民社界負恐自羽形産階体削募。毎億部立進話索表伝財像込事写。情先衝任軽倫能倉暴区上名。進経現経老均振堅東広事初近枝時昇掲埼。味分前応直変禁岩善物住予市化済納円。購発産土生拠児療攻華六窃体止応起原隆侍亮。新暮新入迫発親録出自航森問線選。
![image](/attachments/6d530dd6-7761-4ac4-8d47-3c389f2ad8b3) I'm afraid `bodyMetrics.boundingRect()` doesn't do well in measuring the space of texts, if they contain CJK characters. The texts: ``` Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus at mollis eros. Fusce tempor nunc sed massa porta, a bibendum enim blandit. Vivamus tincidunt, purus eu vulputate pharetra, nulla purus malesuada est, faucibus finibus ligula orci quis nisl. Mauris cursus nisi non erat molestie feugiat tincidunt quis ligula. Duis nec sodales lacus, et accumsan urna. Sed malesuada at arcu eget elementum. Maecenas volutpat porta elit, vel vehicula nibh. Vestibulum vestibulum nisi eget mauris tristique, id vestibulum ex facilisis. Nullam dapibus euismod purus. Donec luctus orci erat, vel pulvinar leo ornare sed. Vestibulum sit amet pretium ipsum, gravida vulputate quam. Cras id nunc vel est tincidunt laoreet. Proin sodales tempor nulla, nec ultrices sem. Suspendisse iaculis orci sem, sed scelerisque velit placerat sit amet. In vehicula varius mauris in elementum. Ut ligula enim, vulputate vitae nunc sed, porta ullamcorper dui. Nullam ullamcorper varius tristique. Cras ornare aliquam velit, quis suscipit enim lobortis non. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Suspendisse potenti. Cras pretium venenatis enim, faucibus accumsan ex maximus ac. Duis quis imperdiet mauris. Donec pellentesque metus a arcu tempor, a tristique tortor finibus. Aenean vitae felis eu libero tempus vestibulum. Cras in molestie urna. Proin volutpat egestas tellus quis laoreet. ``` ``` 野尾都名擢魔遊メソイ、るぬうみなんそぬ巣区都れムキアチイミチヨネヘヨ遊そ。んあまめハッレイ、しこゆせかむつなる名絵舳保しめね二素他離離巣樹るて列絵露魔等ねふゃす、う知遊こめ屋課エイエヨミ課日留、よゆツョヤヒ無鵜きけひ。らきへも都野ちえ、な津瀬るカニモネマへら差屋のかあ素魔鵜根ま瀬個にそおるもまみふ。保よかすよさろりためたてほ御露無都やゅむ無根よくえソヌソモ譜個えすた。 まえちえのも派目保魔名。そむえ。れふる雲留列さらめ名擢魔いと、ひつ知無等ゃふせさほょ、とく差派譜舳つあほ瀬夜、派保目遊差せっゅ列瀬阿ちうもく御夜瀬。よふよ遊差ふあ。 お素知おも根留目目津津遊ぬゅるゅ列列魔無ゆつもちョナヒヤ「ヌへいょせ氏阿課譜」差二。目毛ゅ舳離くくなほもひめにんヘシフラマつつろゆい御もえてっめは氏ふ以毛個雲瀬夜鵜素夜保そ、日せほつむゆ離根えりやせるかはれのやゅめょるっ課二いりおま魔阿野つゅめ魔以雲雲、とうあ、夜ょ派留まほい差魔御、保瀬知野根留。区遊離けひた。区レソソ。 ``` ``` 表両約村悪境福測社鑑図元関前項経均賀。際検的断台漠始高写織前拠発係聞。業前切長野婚芸帯宅車図間月所。鹿趣功心育海頭週紀件力青告稿府届波。表責工棋剖条財図社目種夜上。続属応以罰培転員歳事壁拝開堀止者。記距力現綱催応西本政険年的旅。陸速鑑節三権票係犯後問停。感活細格組沢詰度民回力鑑況。労機恨紙粗浜訃供大目戦抜給事想。 使増岡個定載北安体属践希学。所好転転策陸間激況謙洋布読報。囲勢民意惑思選載億引傷務駒。北民社界負恐自羽形産階体削募。毎億部立進話索表伝財像込事写。情先衝任軽倫能倉暴区上名。進経現経老均振堅東広事初近枝時昇掲埼。味分前応直変禁岩善物住予市化済納円。購発産土生拠児療攻華六窃体止応起原隆侍亮。新暮新入迫発親録出自航森問線選。 ```
185 KiB
Owner

Oh... that's unfortunate... For now I don't know how to treat it...
I'll see what I can do

Oh... that's unfortunate... For now I don't know how to treat it... I'll see what I can do
Owner

May I ask you to retest? I reworked that piece, may be the error went away?)

May I ask you to retest? I reworked that piece, may be the error went away?)
Owner

I think I know why it's happening and it's my fault: the default font for the system surely doesn't have those Japaneze and Chineze symbols, so, when I measure it probably imagines it like if it was going to render them as those quads, fillers... And when the message sizes are measured and everything is calculated the actual label of the text ends up being painted it has differet font and different size, that's why it gets clipped.
So.. I need to, somehow, get this situation, measure it in font and text agnostic way... I have no idea yet where do I even start with it

I think I know why it's happening and it's my fault: the default font for the system surely doesn't have those Japaneze and Chineze symbols, so, when I measure it probably imagines it like if it was going to render them as those quads, fillers... And when the message sizes are measured and everything is calculated the actual label of the text ends up being painted it has differet font and different size, that's why it gets clipped. So.. I need to, somehow, get this situation, measure it in font and text agnostic way... I have no idea yet where do I even start with it
Owner

Let's see, I'll try to measure it myself keeping in mind a set of fonts...
I asked on here, may be someone will share his wisdom?
https://stackoverflow.com/questions/71894044/qt-font-agnostic-text-bounding-rect

Let's see, I'll try to measure it myself keeping in mind a set of fonts... I asked on here, may be someone will share his wisdom? https://stackoverflow.com/questions/71894044/qt-font-agnostic-text-bounding-rect
blue added the
Bug
label 2022-04-17 12:33:41 +00:00
blue added this to the 0.3.0 milestone 2022-04-17 12:33:46 +00:00
blue added reference fontMeasure 2022-04-17 12:33:52 +00:00
Owner

It's bad, measuring text is one of the hardest tasks ever, there is hinting and kerning, responsible Qt code is huge... not sure I can find a flaw there...

It's bad, measuring text is one of the hardest tasks ever, there is hinting and kerning, responsible Qt code is huge... not sure I can find a flaw there...
Owner

I think I got it: had to rewrite the way I render message body. Also had to handle mouse events manually to make mouse selection work in this way of rendering.
Now those examples you sent, they look just fine!
Thank you again for reporting this issue

I think I got it: had to rewrite the way I render message body. Also had to handle mouse events manually to make mouse selection work in this way of rendering. Now those examples you sent, they look just fine! Thank you again for reporting this issue
blue closed this issue 2022-05-04 16:23:44 +00:00
Author
Contributor

Awesome! Glad you found the TextBrowser workaround.

Awesome! Glad you found the TextBrowser workaround.
Owner

I'm so sorry it took me so long(

I'm so sorry it took me so long(
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blue/squawk#59
No description provided.