Implement basic -GSShowGlyphs:: handling.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/branches/text-system-branch@15712 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Alexander Malmberg 2003-01-26 16:24:49 +00:00
parent a4769c3383
commit 5ce6ead747
4 changed files with 73 additions and 1 deletions

View file

@ -1,3 +1,9 @@
2003-01-26 17:22 Alexander Malmberg <alexander@malmberg.org>
* Headers/xlib/XGPrivate.h, Source/xlib/XGFont.m,
Source/xlib/XGState.m: Implement basic version of -GSShowGlyphs::
with a few helpers.
2003-01-26 17:15 Alexander Malmberg <alexander@malmberg.org>
* Source/art/ftfont.m (-advancementForGlyph:): Return correct

View file

@ -74,6 +74,11 @@ extern unsigned long XGFontPropULong(Display *dpy, XFontStruct *font_struct,
- (float) widthOf: (const char*) s lenght: (int) len;
- (void) setActiveFor: (Display*) xdpy gc: (GC) xgcntxt;
- (void) drawGlyphs: (const NSGlyph *) glyphs lenght: (int) len
onDisplay: (Display*) xdpy drawable: (Drawable) draw
with: (GC) xgcntxt at: (XPoint) xp;
- (float) widthOfGlyphs: (const NSGlyph *) glyphs lenght: (int) len;
@end
/* In XGBitmap.m */

View file

@ -126,7 +126,7 @@ static BOOL XGInitAtoms(Display *dpy)
- (void) dealloc
{
if (font_info != NULL)
XUnloadFont([XGServer currentXDisplay], font_info->fid);
XFreeFont([XGServer currentXDisplay], font_info);
[super dealloc];
}
@ -208,6 +208,14 @@ static BOOL XGInitAtoms(Display *dpy)
XDrawString(xdpy, draw, xgcntxt, xp.x, xp.y, s, len);
}
- (void) drawGlyphs: (const NSGlyph *) glyphs lenght: (int) len
onDisplay: (Display*) xdpy drawable: (Drawable) draw
with: (GC) xgcntxt at: (XPoint) xp
{
// This font must already be active!
XDrawString16(xdpy, draw, xgcntxt, xp.x, xp.y, glyphs, len);
}
- (float) widthOfString: (NSString*)string
{
NSData *d = [string dataUsingEncoding: mostCompatibleStringEncoding
@ -224,6 +232,11 @@ static BOOL XGInitAtoms(Display *dpy)
return XTextWidth(font_info, s, len);
}
- (float) widthOfGlyphs: (const NSGlyph *) glyphs lenght: (int) len
{
return XTextWidth16(font_info, glyphs, len);
}
- (void) setActiveFor: (Display*) xdpy gc: (GC) xgcntxt
{
XGCValues gcv;

View file

@ -1347,6 +1347,54 @@ typedef enum {
[path relativeMoveToPoint: NSMakePoint(width * scale.width, 0)];
}
- (void) GSShowGlyphs: (const NSGlyph *)glyphs : (size_t) length
{
int width;
NSSize scale;
XPoint xp;
if (font == nil)
{
NSLog(@"DPS (xgps): no font set\n");
return;
}
COPY_GC_ON_CHANGE;
if (draw == 0)
{
DPS_WARN(DPSinvalidid, @"No Drawable defined for show");
return;
}
if ((cstate & COLOR_FILL) == 0)
[self setColor: &fillColor state: COLOR_FILL];
width = [(XGFontInfo *)font widthOfGlyphs: glyphs lenght: length];
xp = XGWindowPointToX(self, [path currentPoint]);
// Hack: Only draw when alpha is not zero
if (drawingAlpha == NO || fillColor.field[AINDEX] != 0.0)
[(XGFontInfo *)font drawGlyphs: glyphs lenght: length
onDisplay: XDPY drawable: draw
with: xgcntxt at: xp];
if (drawingAlpha)
{
NSAssert(alpha_buffer, NSInternalInconsistencyException);
[self setAlphaColor: fillColor.field[AINDEX]];
[(XGFontInfo *)font drawGlyphs: glyphs lenght: length
onDisplay: XDPY drawable: alpha_buffer
with: agcntxt at: xp];
}
/* Note we update the current point according to the current
transformation scaling, although the text isn't currently
scaled (FIXME). */
scale = [ctm sizeInMatrixSpace: NSMakeSize(1, 1)];
//scale = NSMakeSize(1, 1);
[path relativeMoveToPoint: NSMakePoint(width * scale.width, 0)];
}
- (void)DPSwidthshow: (float)x : (float)y : (int)c : (const char *)s
{
float arr[2];