# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1618436205 0 # Node ID 79732eb2deef77875d3c1e84b664ce6fdc9e2110 # Parent 4fba0b9453eea293ea7ee0057316140baa98e5a5 Mac: Port control empty text size calculation fix from iOS. diff -r 4fba0b9453ee -r 79732eb2deef mac/dw.m --- 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])