Mercurial > dwindows
changeset 2465:79732eb2deef
Mac: Port control empty text size calculation fix from iOS.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Wed, 14 Apr 2021 21:36:45 +0000 |
parents | 4fba0b9453ee |
children | cfb14192753c |
files | mac/dw.m |
diffstat | 1 files changed, 12 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mac/dw.m Wed Apr 14 21:35:21 2021 +0000 +++ b/mac/dw.m Wed Apr 14 21:36:45 2021 +0000 @@ -4978,8 +4978,18 @@ /* If we have a string... * calculate the size with the current font. */ - if(nsstr && [nsstr length]) - dw_font_text_extents_get(object, NULL, (char *)[nsstr UTF8String], &thiswidth, &thisheight); + if(nsstr) + { + int textwidth, textheight; + + /* If we have an empty string, use "gT" to get the most height for the font */ + dw_font_text_extents_get(object, NULL, [nsstr length] ? (char *)[nsstr UTF8String] : "gT", &textwidth, &textheight); + + if(textheight > thisheight) + thisheight = textheight; + if(textwidth > thiswidth) + thiswidth = textwidth; + } /* Handle static text fields */ if([object isKindOfClass:[NSTextField class]] && ![object isEditable])