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

Height of text face not adjusting to wrapped text. #3861

Open
fergus4 opened this issue Apr 27, 2019 · 14 comments
Open

Height of text face not adjusting to wrapped text. #3861

fergus4 opened this issue Apr 27, 2019 · 14 comments
Labels

Comments

@fergus4
Copy link

fergus4 commented Apr 27, 2019

When text face induces wrap due to length exceeding text face width, height is not adjusted to accommodate the wrapped text below and text is cut off.

Example:

view [
	size 100x300
	text 100 "sdsad sadsad  fghgfh gerr nghn fsdfsd fghfgh sfsdf"
	return
	text 100x100 "sdsad sadsad  fghgfh gerr nghn fsdfsd fghfgh sfsdf"
]

In rebol text face height will adjust to accommodate all the wrapped text.

Windows 10
All others not tested

Red 0.6.4 for Windows built 13-Apr-2019/2:27:16-04:00 commit #fb18d4e
@bitbegin
Copy link
Collaborator

some limits with "GdipMeasureString"

Duplicate of #3760

@bitbegin
Copy link
Collaborator

Duplicate of #2757

@bitbegin bitbegin self-assigned this Jul 30, 2019
@bitbegin bitbegin added the GUI label Jul 30, 2019
bitbegin added a commit to bitbegin/red that referenced this issue Jul 30, 2019
@bitbegin
Copy link
Collaborator

temp solution bitbegin@13d0409

@hiiamboris
Copy link
Collaborator

hiiamboris commented Feb 25, 2020

  1. mentioned issues are not duplicates as they contain explicit lines, while this issue is about word wrapped text
  2. I don't think text face should be wrapped without the wrap flag, while it is - and I do consider this a bug: view [text 100x100 "sdsad sadsad fghgfh gerr nghn fsdfsd fghfgh sfsdf"]:
  3. GdipMeasureString has nothing to do with this issue. The issue is in calc-size calling size-text on a face that is not yet created and which handle is zero. get-text-size replaces zero with the handle of desktop window and ` uses width & height of desktop window:
    if null? hwnd [
    hwnd: GetDesktopWindow
    ]
    GetClientRect hWnd rc

size-text is an unbelievable mess: it calls gui/get-text-size, which calls base/render-text (what base has to do with other faces text size??), which in turn calls base/update-base-text, which calls GdipMeasureString. Root problem is the complexity of this twisted chain of calls as it cries for refactoring ;)

But a more immediate solution might be in passing planned face dimensions down the rabbit hole into render-text (which currently uses GetClientRect to obtain these).

@hiiamboris
Copy link
Collaborator

See also #4557

@bitbegin bitbegin removed their assignment Nov 11, 2020
@qtxie
Copy link
Contributor

qtxie commented Sep 25, 2022

size-text is an unbelievable mess: it calls gui/get-text-size, which calls base/render-text (what base has to do with other faces text size??), which in turn calls base/update-base-text, which calls GdipMeasureString.

That's @hiiamboris who wrote the code...
0f549f9#diff-f2e387060e079bd2b85d2637577a5538c9403cd7b7ad089d44461958938bf638R290

@hiiamboris
Copy link
Collaborator

Don't give me too much credit, I only replaced GDI measurement with GDI+ one.

@qtxie
Copy link
Contributor

qtxie commented Sep 25, 2022

Root problem is that we mix GDI, GDI+ and D2D together. The initial version only use GDI and just one get-text-size call, no this twisted chain of calls. I think now we can get rid of GDI+. GDI is still needed as we use native control.

@dockimbel
Copy link
Member

What View/Draw features would we loose if we drop GDI+?

@hiiamboris
Copy link
Collaborator

GDI has no wrapping for it's text label at all IIRC.

@qtxie
Copy link
Contributor

qtxie commented Sep 25, 2022

What View/Draw features would we loose if we drop GDI+?

Nothing as we use D2D now.

GDI has no wrapping for it's text label at all IIRC.

Yes. That's the limitation of it. Working around it results in complex code. The native controls use GDI to draw the text. If we use GDI+ or D2D APIs to measure it, we'll get slightly different result. Which will cause other issues.

@hiiamboris
Copy link
Collaborator

I mean the reason we can write base wrap or text wrap in VID is because we're using GDI+ for their text. Or we could use D2D, but then @qtxie says it's heavy.

@qtxie
Copy link
Contributor

qtxie commented Sep 25, 2022

I mean the reason we can write base wrap or text wrap in VID is because we're using GDI+ for their text. Or we could use D2D, but then @qtxie says it's heavy.

Use D2D for base face, yes, we already use it. I always has no problem with heavy solution. But I'm sure someone will do some benchmarks and complain about it later. For text face, see my note above. The native controls use GDI to draw the text. If we use GDI+ or D2D APIs to measure it, we'll get slightly different result. Which will cause other issues. We'll open a worm box by working around it.

@hiiamboris
Copy link
Collaborator

Are you using D2D for text face too then? It can't be GDI, since it supports wrapping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants