zevlg / telega.el

GNU Emacs telegram client (unofficial)
https://zevlg.github.io/telega.el/
GNU General Public License v3.0
1.09k stars 85 forks source link

Adjust the ascent to avoid gaps between avatar slices. #410

Closed BlindingDark closed 1 year ago

BlindingDark commented 1 year ago

This PR tries to calculate the maximum decent for the characters used in the username, and then use that to set the ascent for the upper half slice of the avatar. For the slice of the lower half of the avatar, it is unrealistic to calculate the ascent of the line where it is, because for example, the content of the reply message has not been fetched when the avatar is inserted. So I decided to provide an option telega-avatar-slice-2-ascent, the default is 100 which is the maximum value of ascent, which is to do our best to make it higher than other text. And even setting it to 100 seems to have almost no visual impact. Anyway, no harm in having it as a custom option.

This PR can solve most of the avatar gaps problems, such as this one mentioned in the following issue. image https://github.com/zevlg/telega.el/issues/317#issuecomment-930042574

For the avatar of the three lines in @replies, I choose to not touch the original logic, that is keep the ascent as 'center, because we did not calculate the ascent of the second line, so we cannot get the correct height for the third line.

Please let me know if you have any suggestions, thanks! :pray:

BlindingDark commented 1 year ago

Currently using this implementation will not be able to update the avatar, which may affect existing functionality, so I decided to close this PR.