mirror of
https://github.com/gnustep/libs-back.git
synced 2025-02-23 20:01:22 +00:00
Added glyph methods needed for new text system.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@15850 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
422914a158
commit
7376de0848
1 changed files with 61 additions and 0 deletions
|
@ -99,6 +99,19 @@ static NSMutableDictionary *_globalFontDictionary = nil;
|
|||
return extents.width;
|
||||
}
|
||||
|
||||
- (float) widthOfGlyphs: (const NSGlyph *) glyphs lenght: (int) len
|
||||
{
|
||||
XGlyphInfo extents;
|
||||
|
||||
XftTextExtents16 ([XGServer currentXDisplay],
|
||||
font_info,
|
||||
glyphs,
|
||||
len,
|
||||
&extents);
|
||||
|
||||
return extents.width;
|
||||
}
|
||||
|
||||
- (NSMultibyteGlyphPacking)glyphPacking
|
||||
{
|
||||
return NSTwoByteGlyphPacking;
|
||||
|
@ -226,6 +239,54 @@ static NSMutableDictionary *_globalFontDictionary = nil;
|
|||
XftDrawDestroy(xftdraw);
|
||||
}
|
||||
|
||||
- (void) drawGlyphs: (const NSGlyph *) glyphs lenght: (int) len
|
||||
onDisplay: (Display*) xdpy drawable: (Drawable) draw
|
||||
with: (GC) xgcntxt at: (XPoint) xp
|
||||
{
|
||||
XftDraw *xftdraw;
|
||||
XftColor xftcolor;
|
||||
XColor dummyc;
|
||||
XGCValues values;
|
||||
XGGState *state = [(XGContext *)GSCurrentContext() currentGState];
|
||||
Region xregion = [state xClipRegion];
|
||||
int defaultScreen = DefaultScreen(xdpy);
|
||||
Colormap colmap = DefaultColormap(xdpy, defaultScreen);
|
||||
|
||||
/* ready to draw */
|
||||
xftdraw = XftDrawCreate(xdpy, draw,
|
||||
DefaultVisual(xdpy, defaultScreen),
|
||||
colmap);
|
||||
if(xftdraw == NULL)
|
||||
return;
|
||||
|
||||
/* sort out the drawing colour */
|
||||
XGetGCValues(xdpy, xgcntxt,
|
||||
GCForeground | GCBackground,
|
||||
&values);
|
||||
|
||||
dummyc.pixel = values.foreground;
|
||||
XQueryColor(xdpy, colmap, &dummyc);
|
||||
xftcolor.color.red = dummyc.red;
|
||||
xftcolor.color.green = dummyc.green;
|
||||
xftcolor.color.blue = dummyc.blue;
|
||||
xftcolor.color.alpha = 0xffff;
|
||||
xftcolor.pixel = values.foreground;
|
||||
|
||||
// set up clipping
|
||||
if(xregion != None)
|
||||
{
|
||||
XftDrawSetClip(xftdraw, xregion);
|
||||
XDestroyRegion(xregion);
|
||||
}
|
||||
|
||||
/* do it */
|
||||
XftDrawString16(xftdraw, &xftcolor, font_info,
|
||||
xp.x, xp.y, (XftChar16*)glyphs, len);
|
||||
|
||||
/* tidy up */
|
||||
XftDrawDestroy(xftdraw);
|
||||
}
|
||||
|
||||
- (void) draw: (const char*) s lenght: (int) len
|
||||
onDisplay: (Display*) xdpy drawable: (Drawable) draw
|
||||
with: (GC) xgcntxt at: (XPoint) xp
|
||||
|
|
Loading…
Reference in a new issue