mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 07:00:46 +00:00
Use GSFont classes in place of backend poseAs classes
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@6390 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
6409269e52
commit
db09827113
9 changed files with 555 additions and 161 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2000-03-27 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Changes to use "helper" class for getting backend
|
||||
font information rather than poseAs classes.
|
||||
* Headers/gnustep/gui/NSFont.h: New ivar.
|
||||
* Headers/gnustep/gui/NSFontManager.h: New ivar.
|
||||
* Source/NSFont.m: Changes to use GSFontInfo classes for
|
||||
getting font information.
|
||||
* Source/NSFontManager.m: Likewise for GSFontEnumerator.
|
||||
* Source/GSFontInfo.m: New file.
|
||||
|
||||
2000-03-27 Nicola Pero <n.pero@mi.flashnet.it>
|
||||
|
||||
* Source/NSTableView.m ([-tile]): Access ivar _frame.
|
||||
|
|
120
Headers/gnustep/gui/GSFontInfo.h
Normal file
120
Headers/gnustep/gui/GSFontInfo.h
Normal file
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
GSFontInfo.h
|
||||
|
||||
Private class for handling font info
|
||||
|
||||
Copyright (C) 2000 Free Software Foundation, Inc.
|
||||
|
||||
Author: Adam Fedor <fedor@gnu.org>
|
||||
Date: Mar 2000
|
||||
|
||||
This file is part of the GNUstep.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#ifndef __GSFontInfo_h_INCLUDE_
|
||||
#define __GSFontInfo_h_INCLUDE_
|
||||
|
||||
#include <AppKit/NSFont.h>
|
||||
#include <AppKit/NSFontManager.h>
|
||||
|
||||
@class NSMutableDictionary;
|
||||
@class NSMutableSet;
|
||||
|
||||
@interface GSFontEnumerator : NSObject
|
||||
{
|
||||
id fontManager;
|
||||
NSMutableSet *allFontNames;
|
||||
NSMutableDictionary *allFontFamilies;
|
||||
NSMutableDictionary* fontInfoDictionary;
|
||||
}
|
||||
|
||||
+ (void) setDefaultClass: (Class)defaultClass;
|
||||
+ sharedEnumeratorWithFontManager: manager;
|
||||
- (NSArray*) allFonts;
|
||||
- (NSArray*) availableFonts;
|
||||
- (NSArray*) availableFontFamilies;
|
||||
- (NSArray*) availableMembersOfFontFamily: (NSString*)family;
|
||||
@end
|
||||
|
||||
@interface GSFontInfo : NSObject
|
||||
{
|
||||
NSMutableDictionary* fontDictionary;
|
||||
|
||||
// metrics of the font
|
||||
NSString *fontName;
|
||||
NSString *familyName;
|
||||
float matrix[6];
|
||||
float italicAngle;
|
||||
NSString *weight;
|
||||
float underlinePosition;
|
||||
float underlineThickness;
|
||||
float capHeight;
|
||||
float xHeight;
|
||||
float descender;
|
||||
float ascender;
|
||||
float widths[256];
|
||||
NSSize maximumAdvancement;
|
||||
NSSize minimumAdvancement;
|
||||
NSString *encodingScheme;
|
||||
NSRect fontBBox;
|
||||
BOOL isFixedPitch;
|
||||
BOOL isBaseFont;
|
||||
}
|
||||
|
||||
+ (void) setDefaultClass: (Class)defaultClass;
|
||||
+ (GSFontInfo*) fontInfoForFontName: (NSString*)fontName
|
||||
matrix: (const float *)fmatrix;
|
||||
|
||||
- (GSFontInfo*) newTransformedFontInfoForMatrix: (const float*)fmatrix;
|
||||
- (void) transformUsingMatrix: (const float*)fmatrix;
|
||||
|
||||
- (NSDictionary *)afmDictionary;
|
||||
- (NSString *)afmFileContents;
|
||||
- (NSRect)boundingRectForFont;
|
||||
- (NSString *)displayName;
|
||||
- (NSString *)familyName;
|
||||
- (NSString *)fontName;
|
||||
- (NSString *)encodingScheme;
|
||||
- (BOOL)isFixedPitch;
|
||||
- (BOOL)isBaseFont;
|
||||
- (float)ascender;
|
||||
- (float)descender;
|
||||
- (float)capHeight;
|
||||
- (float)italicAngle;
|
||||
- (NSSize)maximumAdvancement;
|
||||
- (NSSize)minimumAdvancement;
|
||||
- (float)underlinePosition;
|
||||
- (float)underlineThickness;
|
||||
- (float)xHeight;
|
||||
- (float)widthOfString:(NSString *)string;
|
||||
- (float *)widths;
|
||||
|
||||
- (NSSize) advancementForGlyph: (NSGlyph)aGlyph;
|
||||
- (NSRect) boundingRectForGlyph: (NSGlyph)aGlyph;
|
||||
- (BOOL) glyphIsEncoded: (NSGlyph)aGlyph;
|
||||
- (NSGlyph) glyphWithName: (NSString*)glyphName;
|
||||
- (NSPoint) positionOfGlyph: (NSGlyph)curGlyph
|
||||
precededByGlyph: (NSGlyph)prevGlyph
|
||||
isNominal: (BOOL*)nominal;
|
||||
- (float) widthOfString: (NSString*)string;
|
||||
|
||||
- (NSFontTraitMask) traits;
|
||||
- (int) weight;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* __GSFontInfo_h_INCLUDE_ */
|
|
@ -47,14 +47,11 @@ extern const float *NSFontIdentityMatrix;
|
|||
|
||||
@interface NSFont : NSObject <NSCoding>
|
||||
{
|
||||
// Font attributes
|
||||
NSString *fontName;
|
||||
float matrix[6];
|
||||
|
||||
BOOL matrixExplicitlySet;
|
||||
|
||||
// Reserved for back-end use
|
||||
void *be_font_reserved;
|
||||
id fontInfo;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -79,6 +79,7 @@ typedef enum {
|
|||
NSMenu *_fontMenu;
|
||||
NSFontTag _storedTag;
|
||||
NSFontTraitMask _trait;
|
||||
id _fontEnumerator;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -144,6 +144,7 @@ GSTrackingRect.m \
|
|||
GSServicesManager.m \
|
||||
tiff.m \
|
||||
externs.m \
|
||||
GSFontInfo.m \
|
||||
GSTable.m \
|
||||
GSHbox.m \
|
||||
GSVbox.m \
|
||||
|
|
349
Source/GSFontInfo.m
Normal file
349
Source/GSFontInfo.m
Normal file
|
@ -0,0 +1,349 @@
|
|||
/*
|
||||
GSFontInfo
|
||||
|
||||
Private class for handling font info
|
||||
|
||||
Copyright (C) 2000 Free Software Foundation, Inc.
|
||||
|
||||
Author: Adam Fedor <fedor@gnu.org>
|
||||
Date: Mar 2000
|
||||
|
||||
This file is part of the GNUstep.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#include <AppKit/GSFontInfo.h>
|
||||
#include <Foundation/NSDictionary.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSSet.h>
|
||||
#include <Foundation/NSValue.h>
|
||||
|
||||
static Class fontEnumeratorClass = Nil;
|
||||
static Class fontInfoClass = Nil;
|
||||
|
||||
static GSFontEnumerator *sharedEnumerator = nil;
|
||||
|
||||
@interface NSFontManager (GNUstepBackend)
|
||||
- (BOOL) _includeFont: (NSString*)fontName;
|
||||
@end
|
||||
|
||||
@implementation GSFontEnumerator
|
||||
|
||||
+ (void) setDefaultClass: (Class)defaultClass
|
||||
{
|
||||
fontEnumeratorClass = defaultClass;
|
||||
}
|
||||
|
||||
- initWithFontManager: manager
|
||||
{
|
||||
[super init];
|
||||
fontManager = manager;
|
||||
return self;
|
||||
}
|
||||
|
||||
+ sharedEnumeratorWithFontManager: manager
|
||||
{
|
||||
if (!sharedEnumerator)
|
||||
sharedEnumerator = [[fontEnumeratorClass alloc]
|
||||
initWithFontManager: manager];
|
||||
return sharedEnumerator;
|
||||
}
|
||||
|
||||
- (NSArray*) allFonts
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSArray*) availableFonts
|
||||
{
|
||||
int i;
|
||||
NSArray *fontsList;
|
||||
NSMutableArray *fontNames;
|
||||
|
||||
fontsList = [self allFonts];
|
||||
fontNames = [NSMutableArray arrayWithCapacity: [fontsList count]];
|
||||
|
||||
for (i = 0; i < [fontsList count]; i++)
|
||||
{
|
||||
NSFont *font = (NSFont*)[fontsList objectAtIndex: i];
|
||||
NSString *name = [font fontName];
|
||||
|
||||
if ([fontManager _includeFont: name])
|
||||
[fontNames addObject: name];
|
||||
}
|
||||
|
||||
return fontNames;
|
||||
}
|
||||
|
||||
- (NSArray*) availableFontFamilies
|
||||
{
|
||||
int i;
|
||||
NSArray *fontsList;
|
||||
NSMutableSet *fontFamilies;
|
||||
|
||||
fontsList = [self allFonts];
|
||||
fontFamilies = [NSMutableSet setWithCapacity: [fontsList count]];
|
||||
for (i = 0; i < [fontsList count]; i++)
|
||||
{
|
||||
NSFont *font = (NSFont*)[fontsList objectAtIndex: i];
|
||||
|
||||
[fontFamilies addObject: [font familyName]];
|
||||
}
|
||||
|
||||
return [fontFamilies allObjects];
|
||||
}
|
||||
|
||||
- (NSArray*) availableMembersOfFontFamily: (NSString*)family
|
||||
{
|
||||
int i, j;
|
||||
NSArray *fontFamilies = [self availableFontFamilies];
|
||||
NSMutableArray *fontNames = [NSMutableArray array];
|
||||
NSFontTraitMask traits;
|
||||
|
||||
for (i = 0; i < [fontFamilies count]; i++)
|
||||
{
|
||||
NSArray *fontDefs = [self availableMembersOfFontFamily:
|
||||
[fontFamilies objectAtIndex: i]];
|
||||
|
||||
for (j = 0; j < [fontDefs count]; j++)
|
||||
{
|
||||
NSArray *fontDef = [fontDefs objectAtIndex: j];
|
||||
|
||||
traits = [[fontDef objectAtIndex: 3] unsignedIntValue];
|
||||
// Check if the font has exactly the given mask
|
||||
//if (traits == fontTraitMask)
|
||||
{
|
||||
NSString *name = [fontDef objectAtIndex: 0];
|
||||
|
||||
if ([fontManager _includeFont: name])
|
||||
[fontNames addObject: name];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fontNames;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface GSFontInfo (Backend)
|
||||
-initWithFontName: (NSString *)fontName matrix: (const float *)fmatrix;
|
||||
@end
|
||||
|
||||
@implementation GSFontInfo
|
||||
|
||||
+ (void) setDefaultClass: (Class)defaultClass
|
||||
{
|
||||
fontInfoClass = defaultClass;
|
||||
}
|
||||
|
||||
+ (GSFontInfo*) fontInfoForFontName: (NSString*)nfontName
|
||||
matrix: (const float *)fmatrix;
|
||||
{
|
||||
return AUTORELEASE([[fontInfoClass alloc] initWithFontName: nfontName
|
||||
matrix: fmatrix]);
|
||||
}
|
||||
|
||||
- init
|
||||
{
|
||||
int i;
|
||||
[super init];
|
||||
fontDictionary = [[NSMutableDictionary dictionaryWithCapacity:25] retain];
|
||||
for (i = 0; i < 256; i++)
|
||||
widths[i] = 0.0;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(fontDictionary);
|
||||
RELEASE(fontName);
|
||||
RELEASE(familyName);
|
||||
RELEASE(weight);
|
||||
RELEASE(encodingScheme);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- copyWithZone: (NSZone *)zone
|
||||
{
|
||||
GSFontInfo *copy;
|
||||
copy = (GSFontInfo*) NSCopyObject (self, 0, zone);
|
||||
RETAIN(fontDictionary);
|
||||
RETAIN(fontName);
|
||||
RETAIN(familyName);
|
||||
RETAIN(weight);
|
||||
RETAIN(encodingScheme);
|
||||
return copy;
|
||||
}
|
||||
|
||||
- (void) set
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (GSFontInfo*) newTransformedFontInfoForMatrix: (const float*)fmatrix
|
||||
{
|
||||
GSFontInfo* new = NSCopyObject(self, 0, [self zone]);
|
||||
|
||||
[new transformUsingMatrix: fmatrix];
|
||||
return AUTORELEASE(new);
|
||||
}
|
||||
|
||||
- (void) transformUsingMatrix: (const float*)matrix
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
||||
- (NSDictionary*) afmDictionary
|
||||
{
|
||||
return fontDictionary;
|
||||
}
|
||||
|
||||
- (NSString *)afmFileContents
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSString*) encodingScheme
|
||||
{
|
||||
return encodingScheme;
|
||||
}
|
||||
|
||||
- (NSRect) boundingRectForFont
|
||||
{
|
||||
return fontBBox;
|
||||
}
|
||||
|
||||
- (NSString*) displayName
|
||||
{
|
||||
return familyName;
|
||||
}
|
||||
|
||||
- (NSString*) familyName
|
||||
{
|
||||
return familyName;
|
||||
}
|
||||
|
||||
- (NSString*) fontName
|
||||
{
|
||||
return fontName;
|
||||
}
|
||||
|
||||
- (BOOL) isBaseFont
|
||||
{
|
||||
return isBaseFont;
|
||||
}
|
||||
|
||||
- (BOOL) isFixedPitch
|
||||
{
|
||||
return isFixedPitch;
|
||||
}
|
||||
|
||||
- (float) ascender
|
||||
{
|
||||
return ascender;
|
||||
}
|
||||
|
||||
- (float) descender
|
||||
{
|
||||
return descender;
|
||||
}
|
||||
|
||||
- (float) capHeight
|
||||
{
|
||||
return capHeight;
|
||||
}
|
||||
|
||||
- (float) italicAngle
|
||||
{
|
||||
return italicAngle;
|
||||
}
|
||||
|
||||
- (NSSize) maximumAdvancement
|
||||
{
|
||||
return maximumAdvancement;
|
||||
}
|
||||
|
||||
- (NSSize) minimumAdvancement
|
||||
{
|
||||
return minimumAdvancement;
|
||||
}
|
||||
|
||||
- (float) underlinePosition
|
||||
{
|
||||
return underlinePosition;
|
||||
}
|
||||
|
||||
- (float) underlineThickness
|
||||
{
|
||||
return underlineThickness;
|
||||
}
|
||||
|
||||
- (float) xHeight
|
||||
{
|
||||
return xHeight;
|
||||
}
|
||||
|
||||
- (float*) widths
|
||||
{
|
||||
return widths;
|
||||
}
|
||||
|
||||
- (NSSize) advancementForGlyph: (NSGlyph)aGlyph
|
||||
{
|
||||
return NSMakeSize(0,0);
|
||||
}
|
||||
|
||||
- (NSRect) boundingRectForGlyph: (NSGlyph)aGlyph
|
||||
{
|
||||
return NSZeroRect;
|
||||
}
|
||||
|
||||
- (BOOL) glyphIsEncoded: (NSGlyph)aGlyph;
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSGlyph) glyphWithName: (NSString*)glyphName
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (NSPoint) positionOfGlyph: (NSGlyph)curGlyph
|
||||
precededByGlyph: (NSGlyph)prevGlyph
|
||||
isNominal: (BOOL*)nominal
|
||||
{
|
||||
return NSMakePoint(0,0);
|
||||
}
|
||||
|
||||
- (float) widthOfString: (NSString*)string
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (NSFontTraitMask) traits
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (int) weight
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@end
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include <AppKit/NSFont.h>
|
||||
#include <AppKit/NSFontManager.h>
|
||||
#include <AppKit/GSFontInfo.h>
|
||||
|
||||
@implementation NSFont
|
||||
|
||||
|
@ -158,13 +159,19 @@ void setNSFont(NSString* key, NSFont* font)
|
|||
}
|
||||
#endif
|
||||
|
||||
/* The following method should be rewritten in the backend and it has to be
|
||||
called as part of the implementation. */
|
||||
- initWithName:(NSString*)name matrix:(const float*)fontMatrix
|
||||
{
|
||||
[fontsUsed addObject:name];
|
||||
fontName = RETAIN(name);
|
||||
memcpy(matrix, fontMatrix, sizeof(matrix));
|
||||
fontInfo = RETAIN([GSFontInfo fontInfoForFontName: name matrix: fontMatrix]);
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (NSFont*)fontWithName:(NSString*)name
|
||||
matrix:(const float*)fontMatrix
|
||||
{
|
||||
[fontsUsed addObject:name];
|
||||
return nil;
|
||||
return AUTORELEASE([[NSFont alloc] initWithName: name matrix: fontMatrix]);
|
||||
}
|
||||
|
||||
+ (NSFont*)fontWithName:(NSString*)name
|
||||
|
@ -188,7 +195,8 @@ void setNSFont(NSString* key, NSFont* font)
|
|||
//
|
||||
- (void)dealloc
|
||||
{
|
||||
[fontName release];
|
||||
RELEASE(fontName);
|
||||
RELEASE(fontInfo);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -197,50 +205,48 @@ void setNSFont(NSString* key, NSFont* font)
|
|||
//
|
||||
- (void)set
|
||||
{
|
||||
[fontInfo set];
|
||||
}
|
||||
|
||||
//
|
||||
// Querying the Font
|
||||
//
|
||||
- (float)pointSize { return matrix[3]; }
|
||||
- (NSString*)fontName { return fontName; }
|
||||
- (const float*)matrix { return matrix; }
|
||||
- (float)pointSize { return [fontInfo pointSize]; }
|
||||
- (NSString*)fontName { return fontName; }
|
||||
- (const float*)matrix { return matrix; }
|
||||
|
||||
/* The backends should rewrite the following methods to provide a more
|
||||
appropiate behavior than these. */
|
||||
|
||||
- (NSString *)encodingScheme { return nil; }
|
||||
- (NSString*)familyName { return nil; }
|
||||
- (NSRect)boundingRectForFont { return NSZeroRect; }
|
||||
- (BOOL)isFixedPitch { return NO; }
|
||||
- (BOOL)isBaseFont { return YES; }
|
||||
- (NSString *)encodingScheme { return [fontInfo encodingScheme]; }
|
||||
- (NSString*)familyName { return [fontInfo familyName]; }
|
||||
- (NSRect)boundingRectForFont { return [fontInfo boundingRectForFont]; }
|
||||
- (BOOL)isFixedPitch { return [fontInfo isFixedPitch]; }
|
||||
- (BOOL)isBaseFont { return [fontInfo isBaseFont]; }
|
||||
|
||||
/* Usually the display name of font is the font name. */
|
||||
- (NSString*)displayName { return fontName; }
|
||||
- (NSString*)displayName { return fontName; }
|
||||
|
||||
- (NSDictionary*)afmDictionary { return nil; }
|
||||
- (NSString*)afmFileContents { return nil; }
|
||||
- (NSFont*)printerFont { return self; }
|
||||
- (NSFont*)screenFont { return self; }
|
||||
- (float)ascender { return 0.0; }
|
||||
- (float)descender { return 0.0; }
|
||||
- (float)capHeight { return 0.0; }
|
||||
- (float)italicAngle { return 0.0; }
|
||||
- (NSSize)maximumAdvancement { return NSZeroSize; }
|
||||
- (NSSize)minimumAdvancement { return NSZeroSize; }
|
||||
- (float)underlinePosition { return 0.0; }
|
||||
- (float)underlineThickness { return 0.0; }
|
||||
- (float)xHeight { return 0.0; }
|
||||
- (NSDictionary*)afmDictionary { return [fontInfo afmDictionary]; }
|
||||
- (NSString*)afmFileContents { return [fontInfo afmFileContents]; }
|
||||
- (NSFont*)printerFont { return self; }
|
||||
- (NSFont*)screenFont { return self; }
|
||||
- (float)ascender { return [fontInfo ascender]; }
|
||||
- (float)descender { return [fontInfo descender]; }
|
||||
- (float)capHeight { return [fontInfo capHeight]; }
|
||||
- (float)italicAngle { return [fontInfo italicAngle]; }
|
||||
- (NSSize)maximumAdvancement { return [fontInfo maximumAdvancement]; }
|
||||
- (NSSize)minimumAdvancement { return [fontInfo minimumAdvancement]; }
|
||||
- (float)underlinePosition { return [fontInfo underlinePosition]; }
|
||||
- (float)underlineThickness { return [fontInfo underlineThickness]; }
|
||||
- (float)xHeight { return [fontInfo xHeight]; }
|
||||
|
||||
/* Computing font metrics attributes */
|
||||
- (float)widthOfString:(NSString*)string
|
||||
{
|
||||
return 0;
|
||||
return [fontInfo widthOfString: string];
|
||||
}
|
||||
|
||||
- (float*)widths
|
||||
{
|
||||
return NULL;
|
||||
return [fontInfo widths];
|
||||
}
|
||||
|
||||
/* The following methods have to implemented by backends */
|
||||
|
@ -250,29 +256,30 @@ void setNSFont(NSString* key, NSFont* font)
|
|||
//
|
||||
- (NSSize)advancementForGlyph:(NSGlyph)aGlyph
|
||||
{
|
||||
return NSZeroSize;
|
||||
return [fontInfo advancementForGlyph: aGlyph];
|
||||
}
|
||||
|
||||
- (NSRect)boundingRectForGlyph:(NSGlyph)aGlyph
|
||||
{
|
||||
return NSZeroRect;
|
||||
return [fontInfo boundingRectForGlyph: aGlyph];
|
||||
}
|
||||
|
||||
- (BOOL)glyphIsEncoded:(NSGlyph)aGlyph
|
||||
{
|
||||
return NO;
|
||||
return [fontInfo glyphIsEncoded: aGlyph ];
|
||||
}
|
||||
|
||||
- (NSGlyph)glyphWithName:(NSString*)glyphName
|
||||
{
|
||||
return -1;
|
||||
return [fontInfo glyphWithName: glyphName ];
|
||||
}
|
||||
|
||||
- (NSPoint)positionOfGlyph:(NSGlyph)curGlyph
|
||||
precededByGlyph:(NSGlyph)prevGlyph
|
||||
isNominal:(BOOL *)nominal
|
||||
{
|
||||
return NSZeroPoint;
|
||||
return [fontInfo positionOfGlyph: curGlyph precededByGlyph: prevGlyph
|
||||
isNominal: nominal];
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -38,46 +38,9 @@
|
|||
#include <AppKit/NSFontPanel.h>
|
||||
#include <AppKit/NSMenu.h>
|
||||
#include <AppKit/NSMenuItem.h>
|
||||
#include <AppKit/GSFontInfo.h>
|
||||
|
||||
|
||||
@interface NSFontManager (GNUstepBackend)
|
||||
/*
|
||||
* A backend for this class must always implement the methods
|
||||
* traitsOfFont: and weightOfFont:
|
||||
* It can either implement the method _allFonts to return an array
|
||||
* of all the known fonts for the backend (as NSFont objects) or,
|
||||
* supply a differnt implementation of the methods that use this:
|
||||
* availableFonts, availableFontFamilies, availableFontNamesWithTraits,
|
||||
* availableMembersOfFontFamily and fontNamed: hasTraits:
|
||||
* The second is the more efficent way and should be prefered.
|
||||
* A backend should also provide a better implementation for the method
|
||||
* fontWithFamily: traits: weight: size:
|
||||
* And it can also provide differnt implemantions for the basic font
|
||||
* conversion methods.
|
||||
* The idea is that the front end class defines an easy to subclass
|
||||
* set of methods, so that a backend can start of with just a few methods but
|
||||
* can become as fast and flexible as it wants.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Have the backend determine the fonts and families available
|
||||
* FIXME: This method should rather be part of a subclass initialize method
|
||||
*/
|
||||
- (void) enumerateFontsAndFamilies;
|
||||
|
||||
/*
|
||||
* The backend can use this method to check if a font
|
||||
* is accepted by the delegate. Otherwise it should not be listed.
|
||||
*/
|
||||
- (BOOL) _includeFont: (NSString*)fontName;
|
||||
|
||||
/*
|
||||
* List all the fonts as NSFont objects
|
||||
*/
|
||||
- (NSArray*) _allFonts;
|
||||
|
||||
@end
|
||||
|
||||
/*
|
||||
* Class variables
|
||||
*/
|
||||
|
@ -125,8 +88,6 @@ static Class fontPanelClass = Nil;
|
|||
{
|
||||
NSDebugLog(@"Initializing NSFontManager fonts\n");
|
||||
sharedFontManager = [[fontManagerClass alloc] init];
|
||||
// enumerate the available fonts
|
||||
[sharedFontManager enumerateFontsAndFamilies];
|
||||
}
|
||||
return sharedFontManager;
|
||||
}
|
||||
|
@ -136,10 +97,17 @@ static Class fontPanelClass = Nil;
|
|||
*/
|
||||
- (id) init
|
||||
{
|
||||
if (sharedFontManager && self != sharedFontManager)
|
||||
{
|
||||
RELEASE(self);
|
||||
return sharedFontManager;
|
||||
}
|
||||
self = [super init];
|
||||
|
||||
_action = @selector(changeFont:);
|
||||
_storedTag = NSNoFontChangeAction;
|
||||
_fontEnumerator = RETAIN([GSFontEnumerator
|
||||
sharedEnumeratorWithFontManager: self]);
|
||||
|
||||
return self;
|
||||
}
|
||||
|
@ -148,7 +116,7 @@ static Class fontPanelClass = Nil;
|
|||
{
|
||||
TEST_RELEASE(_selectedFont);
|
||||
TEST_RELEASE(_fontMenu);
|
||||
|
||||
TEST_RELEASE(_fontEnumerator);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
|
@ -157,41 +125,12 @@ static Class fontPanelClass = Nil;
|
|||
*/
|
||||
- (NSArray*) availableFonts
|
||||
{
|
||||
int i;
|
||||
NSArray *fontsList;
|
||||
NSMutableArray *fontNames;
|
||||
|
||||
fontsList = [self _allFonts];
|
||||
fontNames = [NSMutableArray arrayWithCapacity: [fontsList count]];
|
||||
|
||||
for (i = 0; i < [fontsList count]; i++)
|
||||
{
|
||||
NSFont *font = (NSFont*)[fontsList objectAtIndex: i];
|
||||
NSString *name = [font fontName];
|
||||
|
||||
if ([self _includeFont: name])
|
||||
[fontNames addObject: name];
|
||||
}
|
||||
|
||||
return fontNames;
|
||||
return [_fontEnumerator availableFonts];
|
||||
}
|
||||
|
||||
- (NSArray*) availableFontFamilies
|
||||
{
|
||||
int i;
|
||||
NSArray *fontsList;
|
||||
NSMutableSet *fontFamilies;
|
||||
|
||||
fontsList = [self _allFonts];
|
||||
fontFamilies = [NSMutableSet setWithCapacity: [fontsList count]];
|
||||
for (i = 0; i < [fontsList count]; i++)
|
||||
{
|
||||
NSFont *font = (NSFont*)[fontsList objectAtIndex: i];
|
||||
|
||||
[fontFamilies addObject: [font familyName]];
|
||||
}
|
||||
|
||||
return [fontFamilies allObjects];
|
||||
return [_fontEnumerator availableFontFamilies];
|
||||
}
|
||||
|
||||
- (NSArray*) availableFontNamesWithTraits: (NSFontTraitMask)fontTraitMask
|
||||
|
@ -231,34 +170,7 @@ static Class fontPanelClass = Nil;
|
|||
*/
|
||||
- (NSArray*) availableMembersOfFontFamily: (NSString*)family
|
||||
{
|
||||
int i;
|
||||
NSArray *fontsList = [self _allFonts];
|
||||
NSMutableArray *fontDefs = [NSMutableArray array];
|
||||
|
||||
for (i = 0; i < [fontsList count]; i++)
|
||||
{
|
||||
NSFont *font = (NSFont*)[fontsList objectAtIndex: i];
|
||||
|
||||
if ([[font familyName] isEqualToString: family])
|
||||
{
|
||||
NSString *name = [font fontName];
|
||||
|
||||
if ([self _includeFont: name])
|
||||
{
|
||||
NSMutableArray *fontDef = [NSMutableArray arrayWithCapacity: 4];
|
||||
[fontDef addObject: name];
|
||||
// TODO How do I get the font extention name?
|
||||
[fontDef addObject: @""];
|
||||
[fontDef addObject: [NSNumber numberWithInt:
|
||||
[self weightOfFont: font]]];
|
||||
[fontDef addObject: [NSNumber numberWithUnsignedInt:
|
||||
[self traitsOfFont: font]]];
|
||||
[fontDefs addObject: fontDef];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fontDefs;
|
||||
return [_fontEnumerator availableMembersOfFontFamily: family];
|
||||
}
|
||||
|
||||
- (NSString*) localizedNameForFamily: (NSString*)family
|
||||
|
@ -753,14 +665,25 @@ static Class fontPanelClass = Nil;
|
|||
//
|
||||
- (NSFontTraitMask) traitsOfFont: (NSFont*)fontObject
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
GSFontInfo *info;
|
||||
NSFontTraitMask mask = 0;
|
||||
|
||||
info = [GSFontInfo fontInfoForFontName: [fontObject fontName]
|
||||
matrix: [fontObject matrix]];
|
||||
|
||||
if (info)
|
||||
mask = [info traits];
|
||||
return mask;
|
||||
}
|
||||
|
||||
- (int) weightOfFont: (NSFont*)fontObject
|
||||
{
|
||||
// TODO
|
||||
return 5;
|
||||
GSFontInfo *info;
|
||||
|
||||
info = [GSFontInfo fontInfoForFontName: [fontObject fontName]
|
||||
matrix: [fontObject matrix]];
|
||||
|
||||
return [info weight];
|
||||
}
|
||||
|
||||
- (BOOL) fontNamed: (NSString*)typeface
|
||||
|
@ -956,10 +879,6 @@ static Class fontPanelClass = Nil;
|
|||
|
||||
@implementation NSFontManager (GNUstepBackend)
|
||||
|
||||
- (void) enumerateFontsAndFamilies
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Ask delegate if to include a font
|
||||
*/
|
||||
|
@ -972,15 +891,4 @@ static Class fontPanelClass = Nil;
|
|||
return YES;
|
||||
}
|
||||
|
||||
- (NSArray*) _allFonts
|
||||
{
|
||||
NSArray *fontsList;
|
||||
|
||||
NSLog(@"NSFontManager _allFonts called: This should not happen");
|
||||
// Allocate the font list
|
||||
fontsList = [NSMutableArray array];
|
||||
|
||||
return fontsList;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -329,7 +329,7 @@ NSGraphicsContext *GSCurrentContext()
|
|||
return nil;
|
||||
}
|
||||
|
||||
- (void) _postExternalEvent: (NSEvent *)event;
|
||||
- (void) _postExternalEvent: (NSEvent *)event
|
||||
{
|
||||
[self subclassResponsibility: _cmd];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue