Backend support for appendBezierPathWithPackedGlyphs:.

Implementation of coveredCharacterSet on GSXftFontInfo.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@26436 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fredkiefer 2008-04-07 13:51:28 +00:00
parent 5a01087f39
commit 9b97919bcf
7 changed files with 177 additions and 6 deletions

View file

@ -1,3 +1,16 @@
2008-04-07 Fred Kiefer <FredKiefer@gmx.de>
* Source/art/ftfont.m,
* Source/art/ftfont-old.m (-glyphPacking): Add missing method.
* Source/gsc/GSContext.m
(-appendBezierPathWithPackedGlyphs:path:): Send on to gstate.
* Headers/gsc/GSGStateOps.h
(-appendBezierPathWithPackedGlyphs:path:): New method.
* Source/gsc/GSGState.m (-DPScharpath:,
-appendBezierPathWithPackedGlyphs:path:): Implement these methods.
* Source/xlib/GSXftFontInfo.m (-coveredCharacterSet) Add missing
method.
2008-04-04 Fred Kiefer <FredKiefer@gmx.de>
* Source/winlib/WIN32FontInfo.m

View file

@ -54,6 +54,8 @@
- (void) DPSawidthshow: (float)cx : (float)cy : (int)c : (float)ax : (float)ay
: (const char*)s;
- (void) DPScharpath: (const char*)s : (int)b;
- (void) appendBezierPathWithPackedGlyphs: (const char *)packedGlyphs
path: (NSBezierPath*)aPath;
- (void) DPSshow: (const char*)s;
- (void) DPSwidthshow: (float)x : (float)y : (int)c : (const char*)s;
- (void) DPSxshow: (const char*)s : (const float*)numarray : (int)size;

View file

@ -2358,6 +2358,11 @@ static int filters[3][7]=
return NSNullGlyph;
}
- (NSMultibyteGlyphPacking) glyphPacking
{
return NSFourByteGlyphPacking;
}
@end

View file

@ -2095,10 +2095,9 @@ add code to avoid loading bitmaps for glyphs */
#endif
}
- (void) appendBezierPathWithGlyphs: (NSGlyph *)glyphs
count: (int)count
toBezierPath: (NSBezierPath *)path
count: (int)count
toBezierPath: (NSBezierPath *)path
{
int i;
NSGlyph glyph;
@ -2242,6 +2241,11 @@ static int filters[3][7]=
return NSNullGlyph;
}
- (NSMultibyteGlyphPacking) glyphPacking
{
return NSFourByteGlyphPacking;
}
@end

View file

@ -346,6 +346,12 @@ static NSMapTable *gtable;
[gstate DPScharpath: s : b];
}
- (void) appendBezierPathWithPackedGlyphs: (const char *)packedGlyphs
path: (NSBezierPath*)aPath
{
[gstate appendBezierPathWithPackedGlyphs: packedGlyphs path: aPath];
}
- (void) DPSshow: (const char *)s
{
[gstate DPSshow: s];

View file

@ -50,7 +50,9 @@
/* Designated initializer. */
- initWithDrawContext: (GSContext *)drawContext
{
[super init];
self = [super init];
if (!self)
return nil;
drawcontext = drawContext;
offset = NSMakePoint(0, 0);
@ -469,9 +471,71 @@ typedef enum {
isRelative: YES];
}
- (void) DPScharpath: (const char*)s : (int)b
- (void) DPScharpath: (const char*)s : (int)count
{
[self subclassResponsibility: _cmd];
NSGlyph glBuf[count];
int i;
if (!font)
return;
// FIXME
for (i = 0; i < count; i++)
{
glBuf[i] = [font glyphForCharacter: s[i]];
}
CHECK_PATH;
[font appendBezierPathWithGlyphs: glBuf
count: count
toBezierPath: path];
}
- (void) appendBezierPathWithPackedGlyphs: (const char *)packedGlyphs
path: (NSBezierPath*)aPath
{
unsigned int count = packedGlyphs[0];
NSMultibyteGlyphPacking packing;
NSGlyph glBuf[count];
int i;
int j;
unsigned char a, b, c, d;
if (!font)
return;
packing = [font glyphPacking];
j = 1;
for (i = 0; i < count; i++)
{
switch (packing)
{
case NSOneByteGlyphPacking:
glBuf[i] = (NSGlyph)packedGlyphs[j++];
break;
case NSTwoByteGlyphPacking:
a= packedGlyphs[j++];
glBuf[i] = (NSGlyph)((a << 8) | packedGlyphs[j++]);
break;
case NSFourByteGlyphPacking:
a = packedGlyphs[j++];
b = packedGlyphs[j++];
c = packedGlyphs[j++];
d = packedGlyphs[j++];
glBuf[i] = (NSGlyph)((a << 24) | (b << 16)
| (c << 8) | d);
break;
case NSJapaneseEUCGlyphPacking:
case NSAsciiWithDoubleByteEUCGlyphPacking:
default:
// FIXME
break;
}
}
[font appendBezierPathWithGlyphs: glBuf
count: count
toBezierPath: aPath];
}
- (void) DPSshow: (const char*)s

View file

@ -32,6 +32,8 @@
#include "xlib/XGPrivate.h"
#include "xlib/XGGState.h"
#include "x11/XGServer.h"
#include <Foundation/NSByteOrder.h>
#include <Foundation/NSCharacterSet.h>
#include <Foundation/NSData.h>
#include <Foundation/NSDebug.h>
#include <Foundation/NSDictionary.h>
@ -284,6 +286,81 @@ static NSArray *faFromFc(FcPattern *pat)
[super dealloc];
}
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
#if __INT_MIN__ == 0x7fffffff
#define Ones(mask) __builtin_popcount(mask)
#else
#define Ones(mask) __builtin_popcountl((mask) & 0xffffffff)
#endif
#else
/* Otherwise fall back on HACKMEM 169. */
static int
Ones(unsigned int mask)
{
register unsigned int tmp;
tmp = n - ((n >> 1) & 033333333333)
- ((n >> 2) & 011111111111);
return ((tmp + (tmp >> 3)) & 030707070707) % 63;
}
#endif
- (NSCharacterSet*) coveredCharacterSet
{
if (coveredCharacterSet == nil)
{
if (!((XftFont *)font_info)->charset)
return nil;
else
{
NSMutableData *d = [NSMutableData new];
unsigned count = 0;
FcCharSet *charset = ((XftFont *)font_info)->charset;
FcChar32 ucs4;
FcChar32 map[FC_CHARSET_MAP_SIZE];
FcChar32 next;
if (!d)
return nil;
for (ucs4 = FcCharSetFirstPage(charset, map, &next);
ucs4 != FC_CHARSET_DONE;
ucs4 = FcCharSetNextPage(charset, map, &next))
{
unsigned int i;
NSRange aRange;
unsigned int max;
aRange = NSMakeRange(ucs4, FC_CHARSET_MAP_SIZE * sizeof(FcChar32));
max = NSMaxRange(aRange);
// Round up to a suitable plane size
max = ((max + 8191) >> 13) << 13;
[d setLength: max];
// Do some byte swapping, if needed.
if (NSHostByteOrder() == NS_BigEndian)
{
map[i] = NSSwapInt(map[i]);
}
for (i = 0; i < FC_CHARSET_MAP_SIZE; i++)
if (map[i])
{
count += Ones(map[i]);
}
[d replaceBytesInRange: aRange withBytes: map];
}
ASSIGN(coveredCharacterSet,
[NSCharacterSet characterSetWithBitmapRepresentation: d]);
numberOfGlyphs = count;
RELEASE(d);
}
}
return coveredCharacterSet;
}
- (float) widthOfString: (NSString*)string
{
XGlyphInfo extents;