From 3cdcb6e0b9a06708d7f1ab1c41c44b80ab77d5cf Mon Sep 17 00:00:00 2001 From: Adam Fedor Date: Mon, 10 Feb 2003 04:32:38 +0000 Subject: [PATCH] * Source/gsc/GSStreamContext.m (-GSShowGlyphs::): Implement to use glyphshow if font gives back glyph names, otherwise use previous hack. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@15919 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 6 ++++ Source/gsc/GSStreamContext.m | 58 +++++++++++++++++++++++++----------- 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index c3f9afc..7370754 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2003-02-09 Adam Fedor + + * Source/gsc/GSStreamContext.m (-GSShowGlyphs::): Implement to use + glyphshow if font gives back glyph names, otherwise use previous + hack. + 2003-02-09 Fred Kiefer * Source/gsc/GSStreamContext.m diff --git a/Source/gsc/GSStreamContext.m b/Source/gsc/GSStreamContext.m index c455d2c..e870e5e 100644 --- a/Source/gsc/GSStreamContext.m +++ b/Source/gsc/GSStreamContext.m @@ -43,6 +43,7 @@ @interface GSStreamContext (Private) +- (void) output: (const char*)s length: (size_t)length; - (void) output: (const char*)s; @end @@ -204,6 +205,7 @@ fprintf(gstream, "/%s findfont ", [[(GSFontInfo *)fontref fontName] cString]); fprintf(gstream, "[%g %g %g %g %g %g] ", m[0], m[1], m[2], m[3], m[4], m[5]); fprintf(gstream, " makefont setfont\n"); + [super GSSetFont: fontref]; } - (void) GSSetFontSize: (float)size @@ -213,22 +215,38 @@ - (void) GSShowText: (const char *)string : (size_t)length { - [self notImplemented: _cmd]; + fprintf(gstream, "("); + [self output:string length: length]; + fprintf(gstream, ") show\n"); } - (void) GSShowGlyphs: (const NSGlyph *)glyphs : (size_t)length { -// HACK to get some print output until the new glyph text system is fully implemented - char string[length+1]; - int i; - - for (i = 0; i < length; i++) - { - string[i] = glyphs[i]; - } - string[length] = 0; - [self DPSshow: string]; -// [self notImplemented: _cmd]; + GSFontInfo *font = gstate->font; + if ([font respondsToSelector: @selector(nameOfGlyph:)]) + { + int i; + + for (i = 0; i < length; i++) + { + fprintf(gstream, "/%s glyphshow\n",[font nameOfGlyph: glyphs[i]]); + } + } + else + { + /* If backend doesn't handle nameOfGlyph, assume the glyphs are + just mapped to characters. This is the case for the xlib backend + (at least for now). */ + char string[length+1]; + int i; + + for (i = 0; i < length; i++) + { + string[i] = glyphs[i]; + } + string[length] = 0; + [self DPSshow: string]; + } } @@ -768,13 +786,13 @@ writeHex(FILE *gstream, const unsigned char *data, int count) @implementation GSStreamContext (Private) -- (void) output: (const char*)s + - (void) output: (const char*)s length: (size_t)length { - const char *t = s; + int i; - while (*t) + for (i = 0; i < length; i++) { - switch (*t) + switch (s[i]) { case '(': fputs("\\(", gstream); @@ -783,11 +801,15 @@ writeHex(FILE *gstream, const unsigned char *data, int count) fputs("\\)", gstream); break; default: - fputc(*t, gstream); + fputc(s[i], gstream); break; } - t++; } } +- (void) output: (const char*)s +{ + [self output: s length: strlen(s)]; +} + @end