Skip to content

Commit

Permalink
FIX: issue red#3861 (temp solution by reszie height)
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbegin committed Jul 30, 2019
1 parent 3f14bf4 commit 13d0409
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
1 change: 0 additions & 1 deletion modules/view/backends/windows/base.reds
Expand Up @@ -693,7 +693,6 @@ update-base-text: func [
GdipDrawString graphic unicode/to-utf16 text -1 hFont :rect format hBrush
GdipDeleteBrush hBrush
][
rect/height: as float32! 1e6 ;-- allow some room for rendering, otherwise stops at height
GdipMeasureString graphic unicode/to-utf16 text -1 hFont :rect format bbox null null
]

Expand Down
18 changes: 15 additions & 3 deletions modules/view/backends/windows/gui.reds
Expand Up @@ -283,11 +283,13 @@ get-text-size: func [
/local
saved [handle!]
values [red-value!]
face-size [red-pair!]
hwnd [handle!]
dc [handle!]
size [tagSIZE]
rc [RECT_STRUCT value]
bbox [RECT_STRUCT_FLOAT32 value]
factor [float32!]
][
size: declare tagSIZE

Expand All @@ -298,6 +300,8 @@ get-text-size: func [
hwnd: GetDesktopWindow
]
values: object/get-values face
face-size: as red-pair! values + FACE_OBJ_SIZE

dc: GetWindowDC hwnd

if null? hFont [hFont: default-font]
Expand All @@ -307,13 +311,21 @@ get-text-size: func [

SelectObject hwnd saved
ReleaseDC hwnd dc


bbox/height: bbox/height * 1.1
if (as float32! face-size/x) < bbox/width [
factor: (bbox/width + as float32! 1.0) / as float32! face-size/x
factor: factor + as float32! 1.0
bbox/width: as float32! face-size/x
bbox/height: bbox/height * factor
]

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
pair/x: size/width * 100 / dpi-factor
pair/y: size/height * 100 / dpi-factor
]

size
Expand Down

0 comments on commit 13d0409

Please sign in to comment.