Skip to content

Commit

Permalink
FIX: issue red#3861 (Height of text face not adjusting to wrapped text).
Browse files Browse the repository at this point in the history
  • Loading branch information
qtxie committed May 20, 2020
1 parent cf2a750 commit 378c39d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions modules/view/VID.red
Expand Up @@ -458,6 +458,7 @@ system/view/VID: context [
][
sz: any [face/size 0x0]
min-sz: either find containers face/type [sz][
if opts/size-x [face/size: as-pair opts/size-x 0]
(any [pad 0x0]) + any [
all [
any [face/text series? face/data face/font]
Expand Down
17 changes: 15 additions & 2 deletions modules/view/backends/windows/gui.reds
Expand Up @@ -288,7 +288,10 @@ get-text-size: func [
hwnd [handle!]
dc [handle!]
size [tagSIZE]
face-sz [red-pair!]
rc [RECT_STRUCT value]
w [integer!]
h [integer!]
bbox [RECT_STRUCT_FLOAT32 value]
][
size: declare tagSIZE
Expand All @@ -300,19 +303,29 @@ get-text-size: func [
hwnd: GetDesktopWindow
]
values: object/get-values face
face-sz: as red-pair! values + FACE_OBJ_SIZE
dc: GetWindowDC hwnd

if null? hFont [hFont: default-font]
saved: SelectObject hwnd hFont
GetClientRect hWnd rc

rc/left: 0 rc/top: 0
w: 0 h: 0
if TYPE_OF(face-sz) = TYPE_PAIR [
w: dpi-scale face-sz/x
h: dpi-scale face-sz/y
]
if zero? w [w: 7FFFFFFFh]
if zero? h [h: 7FFFFFFFh]
rc/right: w
rc/bottom: h
render-text values hwnd dc rc str :bbox

SelectObject hwnd saved
ReleaseDC hwnd dc

size/width: as integer! ceil as float! bbox/width
size/height: as integer! ceil as float! bbox/height

if pair <> null [
pair/x: as integer! ceil as float! bbox/width * 100 / dpi-factor
pair/y: as integer! ceil as float! bbox/height * 100 / dpi-factor
Expand Down

0 comments on commit 378c39d

Please sign in to comment.