Cache used fonts in context

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@11430 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 2001-11-20 05:00:20 +00:00
parent bef0fa9983
commit db7b620c03
6 changed files with 45 additions and 28 deletions

View file

@ -1,3 +1,14 @@
2001-11-19 Adam Fedor <fedor@gnu.org>
* Headers/gnustep/gui/NSGraphicsContext.h: Add usedFonts ivar.
New methods for caching used fonts.
* Source/NSGraphicsContect.m (-useFont): Moved from NSFont.
(-resetUsedFonts, -usedFonts): Likewise.
* Source/NSFont.m (+useFont:): Use them.
* Source/NSView.m (-endDocument): Likewise.
* Model/GMArchiver.m (-decodeSelectorWithName:): Use correct 0 value.
2001-11-18 Gregory John Casamento <greg_casamento@yahoo.com>
* Tools/gopen.m: added a tool which works like the OPENSTEP 4.2/Mach

View file

@ -51,7 +51,6 @@
@class NSFont;
/*
* Backing Store Types
*/
@ -125,6 +124,7 @@ typedef enum _GSWindowInputState
NSMutableArray *focus_stack;
NSMutableArray *event_queue;
NSMapTable *drag_types;
NSMutableSet *usedFonts;
}
+ (NSGraphicsContext*) currentContext;
@ -147,6 +147,7 @@ typedef enum _GSWindowInputState
- (void) saveGraphicsState;
- (void) wait;
+ (void) waitAllContexts;
@end
#ifndef NO_GNUSTEP
@ -175,6 +176,10 @@ APPKIT_DECLARE NSGraphicsContext *GSCurrentContext();
- (id <NSDraggingInfo>)_dragInfo;
- (void) _postExternalEvent: (NSEvent*)event;
/* Private methods for printing */
- (void) useFont: (NSString *)fontName;
- (void) resetUsedFonts;
- (NSSet *) usedFonts;
@end
#endif

View file

@ -926,7 +926,7 @@ static NSMutableDictionary* classToAliasMappings = nil;
{
NSString* selectorName = [self decodeStringWithName: name];
return selectorName ? NSSelectorFromString (selectorName) : NULL;
return selectorName ? NSSelectorFromString (selectorName) : (SEL)0;
}
- (char) decodeCharWithName: (NSString*)name

View file

@ -45,9 +45,6 @@ static BOOL boldSystemCacheNeedsRecomputing = NO;
static BOOL userCacheNeedsRecomputing = NO;
static BOOL userFixedCacheNeedsRecomputing = NO;
/* Set used to keep track of fonts we are using */
static NSMutableSet *usedFonts = nil;
@interface NSFont (Private)
- (id) initWithName: (NSString*)name
matrix: (const float*)fontMatrix;
@ -397,21 +394,7 @@ setNSFont(NSString* key, NSFont* font)
+ (void) useFont: (NSString*)name
{
if (usedFonts == nil)
usedFonts = RETAIN([NSMutableSet setWithCapacity: 2]);
[usedFonts addObject: name];
}
+ (void) resetUsedFonts
{
if (usedFonts)
[usedFonts removeAllObjects];
}
+ (NSSet *) usedFonts
{
return usedFonts;
[GSCurrentContext() useFont: name];
}
//
@ -512,7 +495,7 @@ setNSFont(NSString* key, NSFont* font)
NSGraphicsContext *ctxt = GSCurrentContext();
[ctxt setFont: self];
[NSFont useFont: fontName];
[ctxt useFont: fontName];
}
//

View file

@ -216,6 +216,7 @@ NSGraphicsContext *GSCurrentContext()
initWithCapacity: 32];
drag_types = NSCreateMapTable(NSIntMapKeyCallBacks,
NSObjectMapValueCallBacks, 0);
usedFonts = nil;
/*
* The classMethodTable dictionary and the list of all contexts must both
@ -387,6 +388,28 @@ NSGraphicsContext *GSCurrentContext()
[self subclassResponsibility: _cmd];
}
- (void) useFont: (NSString*)name
{
if ([self isDrawingToScreen] == YES)
return;
if (usedFonts == nil)
usedFonts = RETAIN([NSMutableSet setWithCapacity: 2]);
[usedFonts addObject: name];
}
- (void) resetUsedFonts
{
if (usedFonts)
[usedFonts removeAllObjects];
}
- (NSSet *) usedFonts
{
return usedFonts;
}
@end
@implementation NSGraphicsContext (Private)

View file

@ -76,11 +76,6 @@ struct NSWindow_struct
@defs(NSWindow)
};
@interface NSFont (NSViewFonts)
+ (void) resetUsedFonts;
+ (NSSet *) usedFonts;
@end
@implementation NSView
/*
@ -2900,7 +2895,7 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
[self endSetup];
}
[NSFont resetUsedFonts];
[ctxt resetUsedFonts];
/* Make sure we set the visible rect so everything is printed. */
[self _rebuildCoordinates];
_visibleRect = _bounds;
@ -2975,7 +2970,7 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
pages = ceil((float)pages / nup);
DPSPrintf(ctxt, "%%%%Pages: %d\n", pages);
}
fontNames = [NSFont usedFonts];
fontNames = [ctxt usedFonts];
if (fontNames && [fontNames count])
{
NSString *name;