Skip to content
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

RSLabel wrongly reports width with italics, breaks RSComposite #64

Open
JanBliznicenko opened this issue May 8, 2024 · 0 comments
Open

Comments

@JanBliznicenko
Copy link
Contributor

JanBliznicenko commented May 8, 2024

RSLabel reports the same width for both normal and italics, although text in italic is wider. If the label is then placed in a RSComposite, it crops part of the text or, if italics text is changed back to normal, it leaves part of previous render there.

example

Example that produces the result in the screenshot:

canvas := RSCanvas new.
canvas @ RSDraggableCanvasInteraction @ RSZoomableCanvasInteraction.
canvas camera scale: 4.

labelW := RSLabel new.
labelW text: 'W'.
labelW italic.
compositeW := RSComposite new.
compositeW add: labelW.
canvas add: compositeW.

labelM := RSLabel new.
labelM text: 'M'.
labelM italic.
compositeM := RSComposite new.
compositeM add: labelM.
compositeM translateBy: 0@20.
canvas add: compositeM.

canvas open.
[50 milliseconds wait.
labelM normal.
labelM signalUpdate.] forkAt: Processor userBackgroundPriority 

Possible unit test:

| label normalWidth italicWidth |
label := RSLabel new.
label text: 'M'.
normalWidth := label width.
label italic.
italicWidth := label width.
self assert: italicWidth > (normalWidth + 0.001)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant