Bug 492202 - [block selection] Zoom In/Out commands modify the non-block-selection font
Summary: [block selection] Zoom In/Out commands modify the non-block-selection font
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.6   Edit
Hardware: All All
: P3 normal with 3 votes (vote)
Target Milestone: ---   Edit
Assignee: Platform-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 502201 509108 509113 519676 535607 560794 578993 (view as bug list)
Depends on: 476037
Blocks:
  Show dependency tree
 
Reported: 2016-04-21 13:27 EDT by Markus Keller CLA
Modified: 2022-03-02 05:41 EST (History)
13 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2016-04-21 13:27:34 EDT
In a text or Java editor, enable Block Selection (Alt+Shift+A).

Now, the Zoom In/Out commands modify the non-block-selection font instead of the currently used font.
Comment 1 Mickael Istria CLA 2016-04-24 12:25:45 EDT
On Linux, it seems even worse: using Ctrl+ when block selection is on seems to cause the IDE to freeze then stop.
Comment 2 Mickael Istria CLA 2016-04-24 12:30:08 EDT
I could see a StackOverflow in the log, that may be related:

java.lang.StackOverflowError
  at org.eclipse.swt.graphics.TextLayout.computeRuns(TextLayout.java:104)
  at org.eclipse.swt.graphics.TextLayout.getLineCount(TextLayout.java:1061)
  at org.eclipse.swt.custom.StyledTextRenderer.getTextLayout(StyledTextRenderer.java:983)
  at org.eclipse.swt.custom.StyledTextRenderer.getTextLayout(StyledTextRenderer.java:714)
  at org.eclipse.swt.custom.StyledText.getPointAtOffset(StyledText.java:5497)
  at org.eclipse.swt.custom.StyledText.setCaretLocation(StyledText.java:8613)
  at org.eclipse.swt.custom.StyledTextRenderer.getTextLayout(StyledTextRenderer.java:1017)
  at org.eclipse.swt.custom.StyledTextRenderer.getTextLayout(StyledTextRenderer.java:714)
  [... repeat chorus ad lib...]


This part of the issue seems more like a SWT Bug.
Comment 3 Mickael Istria CLA 2016-04-25 05:18:21 EDT
(In reply to Mickael Istria from comment #2)
> I could see a StackOverflow in the log, that may be related:

This StackOverflow seems caused by some other editor(s?) being open. I closed all editors, reopened a JDT one and didn't get this error again. I didn't manage to get any hint about which editor, or combination of editors caused the issue.

Once this StackOverflow doesn't happen, I can reproduce the reported issue. The cause is that the handler is using "textEditor.getSymbolicFontName()" which doesn't return the "current" font, but the "declared" one in editor description.
I don't know a good solution to get the "current" font, some hints would be welcome.
Although, as a kind of not reliable workaround and for IDE consistency, I suggest that by default we make the default Text font inherit from the block-selection font.
Comment 4 Mickael Istria CLA 2016-04-25 05:44:38 EDT
[the stack overflow is already reported and fixed, see bug 490743]
Comment 5 Mickael Istria CLA 2016-04-25 06:47:40 EDT
Or maybe can we assume that for all text editors, when the block selection is on, the block-selection font is the one to tweak? We could hardcode that rule in the handler, but I'm not sure of whether all text editors do handle selection block the same way (using an alternative font).
Comment 6 Stephan Wahlbrink CLA 2016-08-24 07:59:49 EDT
A related issue occurs in the Wikitext editor of Mylyn.

The current implementation of AbstractTextZoomHandler resizes the default text font (org.eclipse.mylyn.wikitext.ui.presentation.textFont), but not the monospace font used for code regions.
Comment 7 Mickael Istria CLA 2016-08-24 08:41:32 EDT
(In reply to Stephan Wahlbrink from comment #6)
> The current implementation of AbstractTextZoomHandler resizes the default
> text font (org.eclipse.mylyn.wikitext.ui.presentation.textFont), but not the
> monospace font used for code regions.

As there seems to be no generic relationship between both fonts (the AbstractTextEditor misses a method to retrieve all used fonts inside editor and there is not one default to the other and vice-versa), I don't have a clue of a better way to determine that the "code" font size should be increased.
What we can think of to generalize the AbstractTextZoomHandler is to compare the font size only rather than the whole FontData when computing the affected fonts, but that wouldn't work in your case since:
* There's no defaultsTo
* Both font don't have the same size by default
Comment 8 Mickael Istria CLA 2016-08-24 08:42:56 EDT
(In reply to Mickael Istria from comment #3)
> Although, as a kind of not reliable workaround and for IDE consistency, I
> suggest that by default we make the default Text font inherit from the
> block-selection font.

or vice-versa.
@Markus: do you think adding defaultsTo from one to the other would be ok?
Comment 9 Stephan Wahlbrink CLA 2016-08-24 10:29:49 EDT
A declarative way to mark a font definition as text editor font would be helpful to get all fonts to change.

(In reply to Mickael Istria from comment #7)
* Both font don't have the same size by default

IMHO all text editor fonts should be resized, independent of the current configuration. If a different font is configured by the user, that font should be resized by the same factor/step.
Comment 10 Mickael Istria CLA 2016-08-24 10:33:45 EDT
(In reply to Stephan Wahlbrink from comment #9)
> IMHO all text editor fonts should be resized, independent of the current
> configuration. If a different font is configured by the user, that font
> should be resized by the same factor/step.

There is no such thing as "text editors font" in the internal models. Font are declared but there's no way to decide in which context they're used. So we cannot just increase all font sizes defined in IDE as many of them aren't for editor.

> A declarative way to mark a font definition as text editor font would be helpful to get all fonts to change.

Does the editor definition accept extra properties that we could use to find additional fonts involved?
Comment 11 Stephan Wahlbrink CLA 2016-08-30 06:13:56 EDT
(In reply to Mickael Istria from comment #10)
> There is no such thing as "text editors font" in the internal models. Font
> are declared but there's no way to decide in which context they're used. So
> we cannot just increase all font sizes defined in IDE as many of them aren't
> for editor.

I wanted to note, that the current implementation not only requires that the font is the defaultTo the "Text Font", but also requires the same font data.

If you set the block selection font defaultTo "Text Font", zoom in/zoom out does not longer work, when the user configures a custom font. But IMHO the custom font should be resized by the same step.
Comment 12 Dani Megert CLA 2016-10-12 09:21:36 EDT
*** Bug 502201 has been marked as a duplicate of this bug. ***
Comment 13 Dani Megert CLA 2016-10-12 11:41:34 EDT
*** Bug 502201 has been marked as a duplicate of this bug. ***
Comment 14 Eclipse Genie CLA 2016-10-13 04:32:15 EDT
New Gerrit change created: https://git.eclipse.org/r/83087
Comment 16 Mickael Istria CLA 2016-10-13 13:33:37 EDT
Despite not being a true solution, this patch should greatly improve the situation (unless user directly customize their block selection font)
Comment 17 Eclipse Genie CLA 2016-10-14 03:48:51 EDT
New Gerrit change created: https://git.eclipse.org/r/83184
Comment 19 Dani Megert CLA 2016-10-14 03:49:44 EDT
(In reply to Mickael Istria from comment #16)
> Despite not being a true solution, this patch should greatly improve the
> situation (unless user directly customize their block selection font)

I reverted that change, since it destroys the block selection feature if a non-monospaced font is used.
Comment 20 Mickael Istria CLA 2016-10-14 04:19:05 EDT
But the default text font is a monospace, isn't it? I don't see how the defaultsTo changes anything regarding ability for user to destroy this feature.
Comment 21 Mickael Istria CLA 2016-10-14 04:30:08 EDT
I believe this issue with block selection requring to be monospace should be handled separately and not block this change. see bug 505951 for a proposal.
Comment 22 Dani Megert CLA 2016-10-14 04:55:24 EDT
(In reply to Mickael Istria from comment #20)
> But the default text font is a monospace, isn't it? I don't see how the
> defaultsTo changes anything regarding ability for user to destroy this
> feature.

The whole point of the block selection font is that it works automatically even if the user changes the Text, Java or any other editor font. This has to stay that way. The suggested workaround is not acceptable.
Comment 23 Dani Megert CLA 2016-10-14 04:57:21 EDT
(In reply to Dani Megert from comment #22)
> The suggested workaround is not acceptable.

Plus, it only works around that particular scenario. There might be other contributed fonts that behave the same and are also broken
Comment 24 Mickael Istria CLA 2016-10-14 05:21:31 EDT
(In reply to Dani Megert from comment #23)
> Plus, it only works around that particular scenario. There might be other
> contributed fonts that behave the same and are also broken

Indeed, there are. I can't find the bug # right now, but somewhere someone from mylyn wikitext reported that as their editors use multiple fonts, only one is zoomed. A solution for it would be to introduce a new API in platform text to ask an editor about "all used Text fonts"
Comment 25 Markus Keller CLA 2016-10-21 05:22:34 EDT
(In reply to Mickael Istria from comment #24)
> I can't find the bug # right now, but somewhere someone
> from mylyn wikitext reported that as their editors use multiple fonts, only
> one is zoomed.

It's this bug, use Ctrl+F.

> A solution for it would be to introduce a new API in platform
> text to ask an editor about "all used Text fonts"

Sounds good. Make sure that the new API won't make the fix for bug 482913 harder.
Comment 26 Joe Merten CLA 2016-12-12 16:22:36 EST
*** Bug 509109 has been marked as a duplicate of this bug. ***
Comment 27 Joe Merten CLA 2016-12-14 08:27:48 EST
see also https://bugs.eclipse.org/bugs/show_bug.cgi?id=509108
Comment 28 Mickael Istria CLA 2017-03-22 07:15:38 EDT
I believe the root issue is that when block selection is set, the "textEditor.getSymbolicFontName()" is expected to return the main active font of the editor, in this case, the block selection one.
Comment 29 Mickael Istria CLA 2017-03-22 07:16:37 EDT
*** Bug 509108 has been marked as a duplicate of this bug. ***
Comment 30 Mickael Istria CLA 2017-07-14 18:08:31 EDT
*** Bug 519676 has been marked as a duplicate of this bug. ***
Comment 31 Mickael Istria CLA 2017-09-11 06:28:17 EDT
From https://bugs.eclipse.org/bugs/show_bug.cgi?id=461441#c4
"""
Maybe we can simply make a special case of the "Block Selection" font in the AbstractTextZoomHandler: if we see that the modified font has the same font data as the block selection one and if the regular Text Font is part of the pool of fonts to modify, we include the BLock Selection font (and inheriting descendants) to the pool of fonts to be modified.
That would probably match users expectation properly and wouldn't risk to break the way Block Selection font is used or defined.
"""
Comment 32 Mickael Istria CLA 2017-09-11 06:37:27 EDT
I've got a few questions, mostly for Dani about this:
* Is there a way to detect whether a font is monospaced or not programatically?
* If so, could we place a warning when Block Selection font is changed to non-monospace to remind user that they broke a rule?
* If so, could we "link" through inheritance the Block Selection font as a sub-font of the Default one, and then the warning would pop-up if Block Selection (or parent one when inheriting) font is editor to non-monospace one?
Comment 33 Dani Megert CLA 2018-06-07 06:30:36 EDT
*** Bug 535607 has been marked as a duplicate of this bug. ***
Comment 34 Rolf Theunissen CLA 2019-07-26 08:36:34 EDT
(In reply to Mickael Istria from comment #32)
> I've got a few questions, mostly for Dani about this:
> * Is there a way to detect whether a font is monospaced or not
> programatically?

A quick check in SWT Font and FontData show that this is not implemented in SWT. At least on Windows this information is available in LOGFONT.lfPitchAndFamily. See Bug 74292 for this API request.

> * If so, could we place a warning when Block Selection font is changed to
> non-monospace to remind user that they broke a rule?
> * If so, could we "link" through inheritance the Block Selection font as a
> sub-font of the Default one, and then the warning would pop-up if Block
> Selection (or parent one when inheriting) font is editor to non-monospace
> one?

Instead of falling back to some font, the current selected font could also be forced to be monospaced, See 69253. This would also prevent problems when the bold gryph is different from the normal one.
Comment 35 Rolf Theunissen CLA 2020-03-05 08:12:28 EST
*** Bug 560794 has been marked as a duplicate of this bug. ***
Comment 36 Lukas Eder CLA 2021-06-29 02:41:12 EDT
I was going to create a duplicate of this issue then I found this one.

I work on different types of screens with different resolutions. One has a 3840x2160 resolution with Windows scaling of 150%. On that screen, I like Eclipse to use bigger fonts, so I hit Ctrl-Shift-+ to change the font size.

Unfortunately, this short cut doesn't affect the text editor block selection font, even when I'm in block selection mode, and I'm a heavy user of that feature. The going back and forth is quite annoying. In a different work environment, I have smaller resolutions, where I don't need to zoom in. There, the default settings work just fine.

I understand the rationales discussed here and in https://bugs.eclipse.org/bugs/show_bug.cgi?id=278831, that block selection may require a separate font specification in some scenarios, but in mine, which I believe is quite default, I've never changed any font settings in Eclipse other than zooming in and out for *all* fonts, I much prefer it to be a selection-only feature, not switching fonts entirely.

So, how about:

- Having some sort of toggle whether the block selection font has been changed at all by the user
- If not, then pretend it doesn't exist as a separate setting, and let it use whatever font the current editor is using
Comment 37 Mickael Istria CLA 2021-06-29 04:18:29 EDT
I'm considering trying the opposite of what was attempted in comment #15: the block selection has to be a monospace font, and we'd like the block and regular font to have a relationship so the zoom command would propagate, and by default, the regular font is monospaced; so we can probably make the default text font "defaultTo" the block selection one.
Comment 38 Mickael Istria CLA 2021-06-29 04:35:37 EDT
But FWIW, I believe that block selection is not really worth the investment now; and building a more natural multi caret experience directly in StyledText and TextEditor without need of a block selection will allow users to not have to both with block selection and font management; and may even allow to start deprecating the block selection at some point.
See bug 562676 and related ones.
Comment 39 Lukas Eder CLA 2021-06-29 04:43:49 EDT
> and building a more natural multi caret experience directly in StyledText and TextEditor without need of a block selection will allow users to not have to both with block selection and font management

Can't disagree with that! :)
Comment 40 Rolf Theunissen CLA 2022-03-01 08:59:59 EST
*** Bug 578993 has been marked as a duplicate of this bug. ***
Comment 41 Rolf Theunissen CLA 2022-03-02 05:41:06 EST
*** Bug 509113 has been marked as a duplicate of this bug. ***