-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Use MSWord compatible RTF sequence for background text color #16035
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WOW, great find! |
lhecker
reviewed
Sep 26, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
lhecker
approved these changes
Sep 27, 2023
DHowett
approved these changes
Sep 27, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
glorious!
DHowett
changed the title
Use MSWord compatible RTF sequence for sending background text color
Use MSWord compatible RTF sequence for background text color
Sep 27, 2023
DHowett
pushed a commit
that referenced
this pull request
Dec 15, 2023
The `GenRTF(...)` was using `\highlight` control word for sending background text color in the RTF format during a copy command. This doesn't work correctly, since many applications (E.g. MSWord) don't support full RGB with `\highlight`, and instead uses an approximation of what is received. For example, `rgb(197, 15, 31)` becomes `rgb(255, 0, 255)`. Also, the standard way of using background colors is `\cbN` control word, which isn't supported as per the [RTF Spec 1.9.1] in Word. But it briefly mentioned a workaround at Pg. 23, which seems to work on all the RTF editors I tested. The PR makes the changes to use `\chshdng0\chcbpatN` for the background coloring. Also did some refactoring to make the implementation concise. ## Validation Steps Performed Verified that the background is correctly copied on below editors: - MSWord - WordPad - LibreOffice - Outlook [RTF Spec 1.9.1]: https://msopenspecs.azureedge.net/files/Archive_References/[MSFT-RTF].pdf (cherry picked from commit 310814b) Service-Card-Id: 91349195 Service-Version: 1.19
DHowett
pushed a commit
that referenced
this pull request
Jan 23, 2024
The `GenRTF(...)` was using `\highlight` control word for sending background text color in the RTF format during a copy command. This doesn't work correctly, since many applications (E.g. MSWord) don't support full RGB with `\highlight`, and instead uses an approximation of what is received. For example, `rgb(197, 15, 31)` becomes `rgb(255, 0, 255)`. Also, the standard way of using background colors is `\cbN` control word, which isn't supported as per the [RTF Spec 1.9.1] in Word. But it briefly mentioned a workaround at Pg. 23, which seems to work on all the RTF editors I tested. The PR makes the changes to use `\chshdng0\chcbpatN` for the background coloring. Also did some refactoring to make the implementation concise. ## Validation Steps Performed Verified that the background is correctly copied on below editors: - MSWord - WordPad - LibreOffice - Outlook [RTF Spec 1.9.1]: https://msopenspecs.azureedge.net/files/Archive_References/[MSFT-RTF].pdf (cherry picked from commit 310814b) Service-Card-Id: 91349197 Service-Version: 1.18
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
GenRTF(...)
was using\highlight
control word for sending background text color in the RTF format during a copy command. This doesn't work correctly, since many applications (E.g. MSWord) don't support full RGB with\highlight
, and instead uses an approximation of what is received. For example,rgb(197, 15, 31)
becomesrgb(255, 0, 255)
. Also, the standard way of using background colors is\cbN
control word, which isn't supported as per the RTF Spec 1.9.1 in Word.But it briefly mentioned a workaround at Pg. 23, which seems to work on all the RTF editors I tested:
The PR makes the changes to use
\chshdng0\chcbpatN
for the background coloring.Also did some refactoring to make the implementation concise.
Validation Steps Performed
Verified that the background is correctly copied on below editors: