From cb27bde95d30f4ed51d1e8a8f0465338f7d10d04 Mon Sep 17 00:00:00 2001 From: FredKiefer Date: Sun, 11 Jun 2000 00:32:28 +0000 Subject: [PATCH] Very basic implementation of glyph layout methods git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@6661 72102866-910b-0410-8b05-ffd578937521 --- Source/GSFontInfo.m | 96 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 94 insertions(+), 2 deletions(-) diff --git a/Source/GSFontInfo.m b/Source/GSFontInfo.m index a6fedf792..073657085 100644 --- a/Source/GSFontInfo.m +++ b/Source/GSFontInfo.m @@ -163,7 +163,7 @@ static GSFontEnumerator *sharedEnumerator = nil; { int i; [super init]; - fontDictionary = [[NSMutableDictionary dictionaryWithCapacity:25] retain]; + ASSIGN(fontDictionary, [NSMutableDictionary dictionaryWithCapacity:25]); for (i = 0; i < 256; i++) widths[i] = 0.0; return self; @@ -301,6 +301,12 @@ static GSFontEnumerator *sharedEnumerator = nil; return widths; } +- (float)defaultLineHeightForFont +{ + // ascent plus descent plus some suitable linegap + return [self ascender] + [self descender] + [self pointSize]/ 11.0; +} + - (NSSize) advancementForGlyph: (NSGlyph)aGlyph { return NSMakeSize(0,0); @@ -316,6 +322,11 @@ static GSFontEnumerator *sharedEnumerator = nil; return NO; } +- (NSMultibyteGlyphPacking)glyphPacking +{ + return NSOneByteGlyphPacking; +} + - (NSGlyph) glyphWithName: (NSString*)glyphName { return 0; @@ -325,7 +336,88 @@ static GSFontEnumerator *sharedEnumerator = nil; precededByGlyph: (NSGlyph)prevGlyph isNominal: (BOOL*)nominal { - return NSMakePoint(0,0); + NSSize advance; + + if (nominal) + *nominal = YES; + + if (curGlyph == NSControlGlyph || prevGlyph == NSControlGlyph) + return NSZeroPoint; + + if (curGlyph == NSNullGlyph) + advance = [self advancementForGlyph: prevGlyph]; + else + // Should check kerning + advance = [self advancementForGlyph: prevGlyph]; + + return NSMakePoint(advance.width, advance.height); +} + +- (NSPoint)positionOfGlyph:(NSGlyph)aGlyph + forCharacter:(unichar)aChar + struckOverRect:(NSRect)aRect +{ + return NSZeroPoint; +} + +- (NSPoint)positionOfGlyph:(NSGlyph)aGlyph + struckOverGlyph:(NSGlyph)baseGlyph + metricsExist:(BOOL *)flag +{ + if (flag) + *flag = NO; + + return NSZeroPoint; +} + +- (NSPoint)positionOfGlyph:(NSGlyph)aGlyph + struckOverRect:(NSRect)aRect + metricsExist:(BOOL *)flag +{ + if (flag) + *flag = NO; + + return NSZeroPoint; +} + +- (NSPoint)positionOfGlyph:(NSGlyph)aGlyph + withRelation:(NSGlyphRelation)relation + toBaseGlyph:(NSGlyph)baseGlyph + totalAdvancement:(NSSize *)offset + metricsExist:(BOOL *)flag +{ + NSRect baseRect = [self boundingRectForGlyph: baseGlyph]; + NSPoint point = NSZeroPoint; + + if (flag) + *flag = NO; + + if (relation == NSGlyphBelow) + { + point = baseRect.origin; + } + else + { + point = NSMakePoint(baseRect.origin.x, NSMaxY(baseRect)); + } + + if (offset) + { + NSSize baseSize = [self advancementForGlyph: baseGlyph]; + NSSize aSize = [self advancementForGlyph: aGlyph]; + + if (baseSize.width > aSize.width) + *offset = baseSize; + else + *offset = aSize; + } + + return point; +} + +- (NSStringEncoding)mostCompatibleStringEncoding +{ + return NSASCIIStringEncoding; } - (float) widthOfString: (NSString*)string