[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

rjw rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:54:20 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit f9376f377c20db5537281c4dea49158a3da313c2
Author: rjw <rjw at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Aug 27 18:23:48 2003 +0000

    	Fixed 3385478.  Look for an exact match for font names (using PS names)	before matching on family names.
    
    	Also added logging to help debug now resolved binding problem.
    
            Reviewed by Maciej.
    
            * Misc.subproj/WebKitLogging.h:
            * Misc.subproj/WebKitLogging.m:
            * WebCoreSupport.subproj/WebTextRendererFactory.m:
            (-[WebTextRendererFactory fontWithFamily:traits:size:]):
            * WebView.subproj/WebView.m:
            (-[WebView addObserver:forKeyPath:options:context:]):
            (-[WebView removeObserver:forKeyPath:]):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4901 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index f827300..a0f3055 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,19 @@
+2003-08-26  Richard Williamson   <rjw at apple.com>
+
+	Fixed 3385478.  Look for an exact match for font names (using PS names)	before matching on family names.
+
+	Also added logging to help debug now resolved binding problem.
+
+        Reviewed by Maciej.
+
+        * Misc.subproj/WebKitLogging.h:
+        * Misc.subproj/WebKitLogging.m:
+        * WebCoreSupport.subproj/WebTextRendererFactory.m:
+        (-[WebTextRendererFactory fontWithFamily:traits:size:]):
+        * WebView.subproj/WebView.m:
+        (-[WebView addObserver:forKeyPath:options:context:]):
+        (-[WebView removeObserver:forKeyPath:]):
+
 2003-08-26  Darin Adler  <darin at apple.com>
 
         Reviewed by Maciej.
@@ -27,6 +43,7 @@
 
         Reviewed by Maciej.
 
+>>>>>>> 1.2044
         - fixed 3321247 -- window size box disappears from Help window (caused by WebKit NSView hackery)
 
         * WebView.subproj/WebHTMLViewPrivate.m:
diff --git a/WebKit/Misc.subproj/WebKitLogging.h b/WebKit/Misc.subproj/WebKitLogging.h
index a6e2ef5..2df6c8a 100644
--- a/WebKit/Misc.subproj/WebKitLogging.h
+++ b/WebKit/Misc.subproj/WebKitLogging.h
@@ -17,6 +17,7 @@ extern WebLogChannel WebKitLogLoading;
 
 extern WebLogChannel WebKitLogFontCache;
 extern WebLogChannel WebKitLogFontSubstitution;
+extern WebLogChannel WebKitLogFontSelection;
 extern WebLogChannel WebKitLogDownload;
 extern WebLogChannel WebKitLogDocumentLoad;
 extern WebLogChannel WebKitLogPlugins;
diff --git a/WebKit/Misc.subproj/WebKitLogging.m b/WebKit/Misc.subproj/WebKitLogging.m
index 3f9e1d1..023696a 100644
--- a/WebKit/Misc.subproj/WebKitLogging.m
+++ b/WebKit/Misc.subproj/WebKitLogging.m
@@ -13,6 +13,7 @@ WebLogChannel WebKitLogLoading =      		{ 0x00000040, "WebKitLogLevel", WebLogCh
 
 WebLogChannel WebKitLogFontCache =    		{ 0x00000100, "WebKitLogLevel", WebLogChannelUninitialized };
 WebLogChannel WebKitLogFontSubstitution =	{ 0x00000200, "WebKitLogLevel", WebLogChannelUninitialized };
+WebLogChannel WebKitLogFontSelection =	        { 0x02000000, "WebKitLogLevel", WebLogChannelUninitialized };
 WebLogChannel WebKitLogDownload =     		{ 0x00000800, "WebKitLogLevel", WebLogChannelUninitialized };
 WebLogChannel WebKitLogDocumentLoad =		{ 0x00001000, "WebKitLogLevel", WebLogChannelUninitialized };
 WebLogChannel WebKitLogPlugins =		{ 0x00002000, "WebKitLogLevel", WebLogChannelUninitialized };
@@ -30,4 +31,5 @@ WebLogChannel WebKitLogFileDatabaseActivity =   { 0x00400000, "WebKitLogLevel",
 
 WebLogChannel WebKitLogHistory =                { 0x00800000, "WebKitLogLevel", WebLogChannelUninitialized };
 
-WebLogChannel WebKitLogBindings =                { 0x01000000, "WebKitLogLevel", WebLogChannelUninitialized };
+WebLogChannel WebKitLogBindings =               { 0x01000000, "WebKitLogLevel", WebLogChannelUninitialized };
+
diff --git a/WebKit/WebCoreSupport.subproj/WebTextRendererFactory.m b/WebKit/WebCoreSupport.subproj/WebTextRendererFactory.m
index 0ba16d4..1aa9f7e 100644
--- a/WebKit/WebCoreSupport.subproj/WebTextRendererFactory.m
+++ b/WebKit/WebCoreSupport.subproj/WebTextRendererFactory.m
@@ -326,28 +326,49 @@ static BOOL betterChoice(NSFontTraitMask desiredTraits, int desiredWeight,
     return NO;
 }
 
+// Family name is somewhat of a misnomer here.  We first attempt to find an exact match
+// comparing the desiredFamily to the PostScript name of the installed fonts.  If that fails
+// we then do a search based on the family names of the installed fonts.
 - (NSFont *)fontWithFamily:(NSString *)desiredFamily traits:(NSFontTraitMask)desiredTraits size:(float)size
 {
+    NSFontManager *fontManager = [NSFontManager sharedFontManager];
+    
+    LOG (FontSelection, "looking for %@ with traits %x\n", desiredFamily, desiredTraits);
+    
+    // Look for an exact match first.
+    NSEnumerator *availableFonts = [[fontManager availableFonts] objectEnumerator];
+    NSString *availableFont;
+    while ((availableFont = [availableFonts nextObject])) {
+        if ([desiredFamily caseInsensitiveCompare:availableFont] == NSOrderedSame) {
+            NSFont *nameMatchedFont = [NSFont fontWithName:desiredFamily size:size];
+            NSFontTraitMask traits = [fontManager traitsOfFont:nameMatchedFont];
+            
+            if ((traits & desiredTraits) == desiredTraits){
+                LOG (FontSelection, "returning exact match\n\n");
+                return  [fontManager convertFont: [NSFont fontWithName:desiredFamily size:size] toHaveTrait:desiredTraits];
+            }
+            LOG (FontSelection, "found exact match, but not desired traits, available traits %x\n", traits);
+            break;
+        }
+    }
+    
     // Do a simple case insensitive search for a matching font family.
     // NSFontManager requires exact name matches.
     // This addresses the problem of matching arial to Arial, etc., but perhaps not all the issues.
-    NSEnumerator *e = [[[NSFontManager sharedFontManager] availableFontFamilies] objectEnumerator];
+    NSEnumerator *e = [[fontManager availableFontFamilies] objectEnumerator];
     NSString *availableFamily;
     while ((availableFamily = [e nextObject])) {
         if ([desiredFamily caseInsensitiveCompare:availableFamily] == NSOrderedSame) {
             break;
         }
     }
-    if (availableFamily == nil) {
-        return nil;
-    }
     
     // Found a family, now figure out what weight and traits to use.
     BOOL choseFont = false;
     int chosenWeight = 0;
     NSFontTraitMask chosenTraits = 0;
 
-    NSArray *fonts = [[NSFontManager sharedFontManager] availableMembersOfFontFamily:availableFamily];    
+    NSArray *fonts = [fontManager availableMembersOfFontFamily:availableFamily];    
     unsigned n = [fonts count];
     unsigned i;
     for (i = 0; i < n; i++) {
@@ -379,10 +400,16 @@ static BOOL betterChoice(NSFontTraitMask desiredTraits, int desiredWeight,
     }
     
     if (!choseFont) {
+        LOG (FontSelection, "nothing appropriate to return\n\n");
         return nil;
     }
+
+    NSFont *font = [fontManager fontWithFamily:availableFamily traits:chosenTraits weight:chosenWeight size:size];
+    
+    LOG (FontSelection, "returning font family %@ (%@) traits %x\n\n", 
+            availableFamily, [[[font fontDescriptor] fontAttributes] objectForKey: NSFontNameAttribute], chosenTraits);
     
-    return [[NSFontManager sharedFontManager] fontWithFamily:availableFamily traits:chosenTraits weight:chosenWeight size:size];
+    return font;
 }
 
 typedef struct {
diff --git a/WebKit/WebView.subproj/WebView.m b/WebKit/WebView.subproj/WebView.m
index f43d882..d58cb19 100644
--- a/WebKit/WebView.subproj/WebView.m
+++ b/WebKit/WebView.subproj/WebView.m
@@ -18,6 +18,7 @@
 #import <WebKit/WebHTMLView.h>
 #import <WebKit/WebIconDatabase.h>
 #import <WebKit/WebKitErrors.h>
+#import <WebKit/WebKitLogging.h>
 #import <WebKit/WebKitStatisticsPrivate.h>
 #import <WebKit/WebNSPasteboardExtras.h>
 #import <WebKit/WebNSURLExtras.h>
@@ -820,3 +821,20 @@ static WebFrame *incrementFrame(WebFrame *curr, BOOL forward, BOOL wrapFlag)
 }
 
 @end
+
+ at implementation WebView (WebDebugBinding)
+
+- (void)addObserver:(NSObject *)anObserver forKeyPath:(NSString *)keyPath options:(NSKeyValueObservingOptions)options context:(void *)context
+{
+    LOG (Bindings, "addObserver:%p forKeyPath:%@ options:%x context:%p", anObserver, keyPath, options, context);
+    [super addObserver:anObserver forKeyPath:keyPath options:options context:context];
+}
+
+- (void)removeObserver:(NSObject *)anObserver forKeyPath:(NSString *)keyPath
+{
+    LOG (Bindings, "removeObserver:%p forKeyPath:%@", anObserver, keyPath);
+    [super removeObserver:anObserver forKeyPath:keyPath];
+}
+
+ at end
+

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list