[PR #4731] [MERGED] Avoid splitting surrogate pairs when breaking runs for scaling #25913

Open
opened 2026-01-31 09:12:36 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/4731
Author: @miniksa
Created: 2/26/2020
Status: Merged
Merged: 2/26/2020
Merged by: @undefined

Base: masterHead: dev/miniksa/broken_layout


📝 Commits (1)

  • f892200 Don't split surrogate pairs when breaking runs for scaling. Affects emoji rendering. #4704

📊 Changes

1 file changed (+5 additions, -2 deletions)

View changed files

📝 src/renderer/dx/CustomTextLayout.cpp (+5 -2)

📄 Description

Summary of the Pull Request

  • Surrogate pairs are being split in half with the run splitting check.

References

  • Related to #4708 but not going to fix it.

PR Checklist

Detailed Description of the Pull Request / Additional comments

  • The adjustment of the run heights in the correction function reports back a text index and a scaling factor. However, I didn't remember at the time that the text is being stored as UTF-16. So the index given can be pointing to the high surrogate of a pair. Thus adding 1 to split "after" the text character, then backing up by 1 isn't valid in if the index given was for a high surrogate.

The quick fix is to advance by two if it's a high surrogate and one otherwise.

Validation Steps Performed

  • Used the sample code from #4704 to print the house emoji in various situations into the buffer.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/4731 **Author:** [@miniksa](https://github.com/miniksa) **Created:** 2/26/2020 **Status:** ✅ Merged **Merged:** 2/26/2020 **Merged by:** [@undefined](undefined) **Base:** `master` ← **Head:** `dev/miniksa/broken_layout` --- ### 📝 Commits (1) - [`f892200`](https://github.com/microsoft/terminal/commit/f89220041d82d1c360830937139e271ffc890c3a) Don't split surrogate pairs when breaking runs for scaling. Affects emoji rendering. #4704 ### 📊 Changes **1 file changed** (+5 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/renderer/dx/CustomTextLayout.cpp` (+5 -2) </details> ### 📄 Description ## Summary of the Pull Request - Surrogate pairs are being split in half with the run splitting check. ## References - Related to #4708 but not going to fix it. ## PR Checklist * [x] Closes #4704 * [x] I work here. * [x] I am a core contributor. ## Detailed Description of the Pull Request / Additional comments - The adjustment of the run heights in the correction function reports back a text index and a scaling factor. However, I didn't remember at the time that the text is being stored as UTF-16. So the index given can be pointing to the high surrogate of a pair. Thus adding 1 to split "after" the text character, then backing up by 1 isn't valid in if the index given was for a high surrogate. The quick fix is to advance by two if it's a high surrogate and one otherwise. ## Validation Steps Performed - Used the sample code from #4704 to print the house emoji in various situations into the buffer. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:12:36 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#25913