-
Notifications
You must be signed in to change notification settings - Fork 85
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
Background text of attributed string does not work properly on High Sierra #101
Comments
Does the same happen if you run the libui drawtext example on High Sierra? |
4th Line: "text background color" has a yellow-ish background Interesting. I can't reproduce this, unfortunately. |
Oh, yes. So it seems a bug on bindings... |
Then why does it work on Sierra? 😕 |
We should investigate 🕵🏻♂️ |
I'd guess somewhere in here? After that, it's out of our control. libui-node/src/Font/AttributedString.cc Lines 70 to 79 in 4d72285
Could you check if libui drawtext example: static void appendWithAttribute(const char *what, uiAttribute *attr, uiAttribute *attr2)
{
size_t start, end;
start = uiAttributedStringLen(attrstr);
end = start + strlen(what);
uiAttributedStringAppendUnattributed(attrstr, what);
uiAttributedStringSetAttribute(attrstr, attr, start, end);
if (attr2 != NULL)
uiAttributedStringSetAttribute(attrstr, attr2, start, end);
} |
Does it work correctly with libui-napi? |
No, it work the same as libui-node 😭 |
I discovered that the problem go away if I change the text passed to the AttributedString constructor. |
This attributed string: const str = new libui.AttributedString(
'Drawing strings with libui is done with the uiAttributedString and uiDrawTextLayout objects.\n' +
'uiAttributedString lets you have a variety of attributes: font family, font size, font weight,' +
'font italicness, font stretch, text color',
FontAttribute.newColor(new libui.Color(0.75, 0.25, 0.5, 0.75)));
str.appendAttributed('text background color', FontAttribute.newBackgroundColor(
new libui.Color(0.5, 0.5, 0.25, 0.5)));
str.appendUnattributed(', underline style, and '); renders to this: This one: const str = new libui.AttributedString(
'Drawing strings with ',
FontAttribute.newColor(new libui.Color(0.75, 0.25, 0.5, 0.75)));
str.appendAttributed('text background color', FontAttribute.newBackgroundColor(
new libui.Color(0.5, 0.5, 0.25, 0.5)));
str.appendUnattributed(', underline style, and '); renders correctly: Maybe there is a problem when an attributed string part spans throw multiple lines? |
The problem even appear/disappear if I resize the window. |
That might be it. Does the libui drawtext example behave the same?
So if you "remove" the line break in the background color region? |
Exactly...
Yes, the libui drawtext example has the same behaviour. It just happens that the background text by default does not break on lines, you have to resize the window: |
Time to open a issue on libui with that gif... |
I'll have to research if libui is using the API incorrectly (if not, there should be other apps experiencing this). |
examples/text.js:
Expected (correct on Sierra):
High Sierra:
Need test whether this is an issue of libui.
The text was updated successfully, but these errors were encountered: