diff mac/dw.m @ 1230:75a773cdb626

Fixes to dw_font_text_extents_get() on Mac so it honors the font set with dw_pixmap_set_font(). Also added multi-page printing code to the test program to make sure that works properly on all platforms. It will print the selected file on page 2, or a centered error message if none is selected.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 16 Oct 2011 19:12:53 +0000
parents f5b79d8b0694
children bee6fc8119ec
line wrap: on
line diff
--- a/mac/dw.m	Tue Oct 11 23:37:21 2011 +0000
+++ b/mac/dw.m	Sun Oct 16 19:12:53 2011 +0000
@@ -5031,22 +5031,28 @@
 {
     id object = handle;
     NSString *nstr = [NSString stringWithUTF8String:text];
+    NSFont *font = nil;
+    /* Check the pixmap for associated object or font */
     if(pixmap)
     {
         object = pixmap->handle;
+        font = pixmap->font;
     }
     NSMutableDictionary *dict = [[NSMutableDictionary alloc] init];
-    if([object isMemberOfClass:[DWRender class]] || [object isKindOfClass:[NSControl class]])
-    {
-        NSFont *font = [object font];
-
-        if(font)
-        {
-            [dict setValue:font forKey:NSFontAttributeName];
-        }
-    }
+    /* If we didn't get a font from the pixmap... try the associated object */
+    if(!font && ([object isMemberOfClass:[DWRender class]] || [object isKindOfClass:[NSControl class]]))
+    {
+        font = [object font];
+    }
+    /* If we got a font... add it to the dictionary */
+    if(font)
+    {
+        [dict setValue:font forKey:NSFontAttributeName];
+    }
+    /* Calculate the size of the string */
     NSSize size = [nstr sizeWithAttributes:dict];
     [dict release];
+    /* Return whatever information we can */
     if(width)
     {
         *width = size.width;