more KGFontState/KGFont cleanup

This commit is contained in:
Christopher Lloyd 2008-12-03 22:21:32 +00:00
parent 98f5dfe452
commit 3a6215ce9a
9 changed files with 54 additions and 14 deletions

View File

@ -16,3 +16,9 @@ CGFontRef CGFontCreateWithFontName(NSString *name) {
void CGFontRelease(CGFontRef self){
[self release];
}
size_t CGFontGetNumberOfGlyphs(CGFontRef self) {
return [self numberOfGlyphs];
}

View File

@ -9,7 +9,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
#import "KGContext.h"
#import "KGBitmapContext.h"
#import "KGGraphicsState.h"
#import "KGFontState.h"
#import "KGColor.h"
#import "KGColorSpace.h"
#import "KGMutablePath.h"
@ -797,16 +796,7 @@ static inline KGGraphicsState *currentState(KGContext *self){
}
-(void)showText:(const char *)text length:(unsigned)length {
unichar unicode[length];
CGGlyph glyphs[length];
int i;
// FIX, encoding
for(i=0;i<length;i++)
unicode[i]=text[i];
[[currentState(self) fontState] getGlyphs:glyphs forCharacters:unicode length:length];
[self showGlyphs:glyphs count:length];
KGInvalidAbstractInvocation();
}
-(void)showText:(const char *)text length:(unsigned)length atPoint:(float)x:(float)y {

View File

@ -15,4 +15,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
-(NSString *)fontName;
-(size_t)numberOfGlyphs;
@end

View File

@ -27,4 +27,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
return _name;
}
-(size_t)numberOfGlyphs {
return 0;
}
@end

View File

@ -69,6 +69,19 @@ static inline BOOL transformIsFlipped(CGAffineTransform matrix){
[self currentState]->_textTransform.ty+=advancement.height;
}
-(void)showText:(const char *)text length:(unsigned)length {
unichar unicode[length];
CGGlyph glyphs[length];
int i;
// FIX, encoding
for(i=0;i<length;i++)
unicode[i]=text[i];
[[[self currentState] fontState] getGlyphs:glyphs forCharacters:unicode length:length];
[self showGlyphs:glyphs count:length];
}
-(void)deviceSelectFontWithName:(NSString *)name pointSize:(float)pointSize antialias:(BOOL)antialias {
int height=(pointSize*GetDeviceCaps(_dc,LOGPIXELSY))/72.0;

View File

@ -219,6 +219,7 @@ static RECT NSRectToRECT(NSRect rect) {
[self establishFontState];
}
-(void)deviceClipReset {
[_deviceContext clipReset];
}
@ -347,6 +348,18 @@ static RECT NSRectToRECT(NSRect rect) {
[self currentState]->_textTransform.ty+=advancement.height;
}
-(void)showText:(const char *)text length:(unsigned)length {
unichar unicode[length];
CGGlyph glyphs[length];
int i;
// FIX, encoding
for(i=0;i<length;i++)
unicode[i]=text[i];
[[[self currentState] fontState] getGlyphs:glyphs forCharacters:unicode length:length];
[self showGlyphs:glyphs count:length];
}
// The problem is that the GDI gradient fill is a linear/stitched filler and the
// Mac one is a sampling one. So to preserve color variation we stitch together a lot of samples

View File

@ -1,9 +1,6 @@
#import <AppKit/KGFontState.h>
@interface KGFontState_gdi : KGFontState {
CGFontMetrics _metrics;
struct CGGlyphRangeTable *_glyphRangeTable;
struct CGGlyphMetricsSet *_glyphInfoSet;
BOOL _useMacMetrics;
}

View File

@ -395,6 +395,19 @@
cairo_font_face_destroy(face);
}
-(void)showText:(const char *)text length:(unsigned)length {
unichar unicode[length];
CGGlyph glyphs[length];
int i;
// FIX, encoding
for(i=0;i<length;i++)
unicode[i]=text[i];
[[[self currentState] fontState] getGlyphs:glyphs forCharacters:unicode length:length];
[self showGlyphs:glyphs count:length];
}
-(void)flush {
cairo_surface_flush(_surface);
}

View File

@ -22,3 +22,5 @@ typedef unsigned short CGGlyph;
COREGRAPHICS_EXPORT CGFontRef CGFontCreateWithFontName(NSString *name);
COREGRAPHICS_EXPORT void CGFontRelease(CGFontRef self);
COREGRAPHICS_EXPORT size_t CGFontGetNumberOfGlyphs(CGFontRef self);