Revision: 2862
          http://skim-app.svn.sourceforge.net/skim-app/?rev=2862&view=rev
Author:   hofman
Date:     2007-09-09 11:11:45 -0700 (Sun, 09 Sep 2007)

Log Message:
-----------
Try to find the font from the FDF string.

Modified Paths:
--------------
    trunk/SKFDFParser.m

Modified: trunk/SKFDFParser.m
===================================================================
--- trunk/SKFDFParser.m 2007-09-09 17:32:04 UTC (rev 2861)
+++ trunk/SKFDFParser.m 2007-09-09 18:11:45 UTC (rev 2862)
@@ -40,6 +40,7 @@
 #import <Quartz/Quartz.h>
 #import "NSScanner_SKExtensions.h"
 #import "NSCharacterSet_SKExtensions.h"
+#import "SKStringConstants.h"
 
 
 @interface SKFDFParser (SKPrivate)
@@ -436,6 +437,31 @@
             } else {
                 success = NO;
             }
+        } else if ([key isEqualToString:@"DA"]) {
+            if (value = [self stringValue:value]) {
+                NSScanner *scanner = [NSScanner scannerWithString:value];
+                NSString *fontName;
+                float fontSize;
+                if ([scanner scanUpToString:@"Tf" intoString:NULL] && [scanner 
isAtEnd] == NO) {
+                    unsigned location = [scanner scanLocation];
+                    NSRange r = [value rangeOfString:@"/" 
options:NSBackwardsSearch range:NSMakeRange(0, location)];
+                    if (r.location != NSNotFound) {
+                        [scanner setScanLocation:NSMaxRange(r)];
+                        if ([scanner scanCharactersFromSet:[NSCharacterSet 
nonWhitespaceAndNewlineCharacterSet] intoString:&fontName] && 
+                            [scanner scanFloat:&fontSize] && 
+                            [scanner scanString:@"Tf" intoString:NULL] && 
+                            [scanner scanLocation] == location + 2) {
+                            NSFont *font = [NSFont fontWithName:fontName 
size:fontSize];
+                            if (font == nil) {
+                                fontName = [[NSUserDefaults 
standardUserDefaults] stringForKey:SKTextNoteFontNameKey];
+                                font = [NSFont fontWithName:fontName 
size:fontSize];
+                            }
+                            if (font)
+                                [dictionary setObject:font forKey:@"font"];
+                        }
+                    }
+                }
+            }
         }
     }
     return success ? dictionary : nil;


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to