mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2024-11-18 10:08:29 +01:00
dict_tilesToString sig change; remove glyph-measuring API just added
(since it belongs in drawing, not dict)
This commit is contained in:
parent
dc84bd22df
commit
f082c6ad2e
2 changed files with 25 additions and 40 deletions
|
@ -100,9 +100,11 @@ dict_numTileFaces( DictionaryCtxt* dict )
|
||||||
|
|
||||||
XP_U16
|
XP_U16
|
||||||
dict_tilesToString( DictionaryCtxt* ctxt, Tile* tiles, XP_U16 nTiles,
|
dict_tilesToString( DictionaryCtxt* ctxt, Tile* tiles, XP_U16 nTiles,
|
||||||
XP_UCHAR* buf )
|
XP_UCHAR* buf, XP_U16 bufSize )
|
||||||
{
|
{
|
||||||
XP_UCHAR* bufIn = buf;
|
XP_UCHAR* bufp = buf;
|
||||||
|
XP_UCHAR* end = bufp + bufSize;
|
||||||
|
XP_U16 result = 0;
|
||||||
|
|
||||||
while ( nTiles-- ) {
|
while ( nTiles-- ) {
|
||||||
Tile tile = *tiles++;
|
Tile tile = *tiles++;
|
||||||
|
@ -111,18 +113,29 @@ dict_tilesToString( DictionaryCtxt* ctxt, Tile* tiles, XP_U16 nTiles,
|
||||||
if ( IS_SPECIAL(face) ) {
|
if ( IS_SPECIAL(face) ) {
|
||||||
XP_UCHAR* chars = ctxt->chars[(XP_U16)face];
|
XP_UCHAR* chars = ctxt->chars[(XP_U16)face];
|
||||||
XP_U16 len = XP_STRLEN( chars );
|
XP_U16 len = XP_STRLEN( chars );
|
||||||
XP_MEMCPY( buf, chars, len );
|
if ( bufp + len >= end ) {
|
||||||
buf += len;
|
bufp = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
XP_MEMCPY( bufp, chars, len );
|
||||||
|
bufp += len;
|
||||||
} else {
|
} else {
|
||||||
XP_ASSERT ( tile != ctxt->blankTile ); /* printing blank should be
|
XP_ASSERT ( tile != ctxt->blankTile ); /* printing blank should be
|
||||||
handled by specials
|
handled by specials
|
||||||
mechanism */
|
mechanism */
|
||||||
*buf++ = face;
|
if ( bufp + 1 >= end ) {
|
||||||
|
bufp = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
*bufp++ = face;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*buf = '\0';
|
if ( bufp != NULL && bufp < end ) {
|
||||||
return buf - bufIn;
|
*bufp = '\0';
|
||||||
|
result = bufp - buf;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
} /* dict_tilesToString */
|
} /* dict_tilesToString */
|
||||||
|
|
||||||
Tile
|
Tile
|
||||||
|
@ -282,15 +295,6 @@ common_destructor( DictionaryCtxt* dict )
|
||||||
XP_FREE( dict->mpool, dict );
|
XP_FREE( dict->mpool, dict );
|
||||||
} /* dict */
|
} /* dict */
|
||||||
|
|
||||||
#if defined TALL_FONTS && defined DEBUG
|
|
||||||
static void
|
|
||||||
dict_getFaceBounds_assert( DictionaryCtxt* dict, XP_UCHAR i,
|
|
||||||
XP_FontBounds* bounds )
|
|
||||||
{
|
|
||||||
XP_ASSERT(0);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void
|
void
|
||||||
dict_loadFromStream( DictionaryCtxt* dict, XWStreamCtxt* stream )
|
dict_loadFromStream( DictionaryCtxt* dict, XWStreamCtxt* stream )
|
||||||
{
|
{
|
||||||
|
@ -302,9 +306,6 @@ dict_loadFromStream( DictionaryCtxt* dict, XWStreamCtxt* stream )
|
||||||
XP_ASSERT( !dict->destructor );
|
XP_ASSERT( !dict->destructor );
|
||||||
dict->destructor = common_destructor;
|
dict->destructor = common_destructor;
|
||||||
dict->func_dict_getShortName = dict_getName; /* default */
|
dict->func_dict_getShortName = dict_getName; /* default */
|
||||||
#if defined TALL_FONTS && defined DEBUG
|
|
||||||
dict->func_dict_getFaceBounds = dict_getFaceBounds_assert;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
nFaces = (XP_U8)stream_getBits( stream, 6 );
|
nFaces = (XP_U8)stream_getBits( stream, 6 );
|
||||||
maxCountBits = (XP_U16)stream_getBits( stream, 3 );
|
maxCountBits = (XP_U16)stream_getBits( stream, 3 );
|
||||||
|
|
|
@ -33,6 +33,8 @@ extern "C" {
|
||||||
#define LETTER_NONE '\0'
|
#define LETTER_NONE '\0'
|
||||||
#define IS_SPECIAL(face) (((XP_CHAR16)(face)) < 0x0020)
|
#define IS_SPECIAL(face) (((XP_CHAR16)(face)) < 0x0020)
|
||||||
|
|
||||||
|
typedef XP_U8 XP_LangCode;
|
||||||
|
|
||||||
typedef XP_U16 XP_CHAR16;
|
typedef XP_U16 XP_CHAR16;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
@ -54,20 +56,6 @@ typedef struct SpecialBitmaps {
|
||||||
XP_Bitmap smallBM;
|
XP_Bitmap smallBM;
|
||||||
} SpecialBitmaps;
|
} SpecialBitmaps;
|
||||||
|
|
||||||
#ifdef TALL_FONTS
|
|
||||||
/* This guy's used to vertically center glyphs within cells. The impetus
|
|
||||||
is the circle-A char in Danish which starts higher than most and must
|
|
||||||
be drawn (on Palm) starting at a smaller y value if the bottom is to be
|
|
||||||
visible. */
|
|
||||||
typedef struct XP_FontBounds {
|
|
||||||
XP_S16 topOffset; /* how many pixels from the top of the drawing
|
|
||||||
area is the first pixel set in the glyph */
|
|
||||||
XP_U16 height; /* How many rows tall is the image? */
|
|
||||||
} XP_FontBounds;
|
|
||||||
|
|
||||||
typedef XP_U16 XP_LangCode; /* corresponds to the XLOC_HEADER field in
|
|
||||||
dawg/./info.txt files */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct DictionaryCtxt {
|
struct DictionaryCtxt {
|
||||||
void (*destructor)( DictionaryCtxt* dict );
|
void (*destructor)( DictionaryCtxt* dict );
|
||||||
|
@ -75,10 +63,6 @@ struct DictionaryCtxt {
|
||||||
array_edge* (*func_edge_for_index)( DictionaryCtxt* dict, XP_U32 index );
|
array_edge* (*func_edge_for_index)( DictionaryCtxt* dict, XP_U32 index );
|
||||||
array_edge* (*func_dict_getTopEdge)( DictionaryCtxt* dict );
|
array_edge* (*func_dict_getTopEdge)( DictionaryCtxt* dict );
|
||||||
XP_UCHAR* (*func_dict_getShortName)( DictionaryCtxt* dict );
|
XP_UCHAR* (*func_dict_getShortName)( DictionaryCtxt* dict );
|
||||||
#ifdef TALL_FONTS
|
|
||||||
void (*func_dict_getFaceBounds)( DictionaryCtxt* dict, Tile tile,
|
|
||||||
XP_FontBounds* bounds );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
array_edge* topEdge;
|
array_edge* topEdge;
|
||||||
array_edge* base; /* the physical beginning of the dictionary; not
|
array_edge* base; /* the physical beginning of the dictionary; not
|
||||||
|
@ -137,7 +121,7 @@ struct DictionaryCtxt {
|
||||||
#define dict_edge_for_index(d, i) (*((d)->func_edge_for_index))((d), (i))
|
#define dict_edge_for_index(d, i) (*((d)->func_edge_for_index))((d), (i))
|
||||||
#define dict_getTopEdge(d) (*((d)->func_dict_getTopEdge))(d)
|
#define dict_getTopEdge(d) (*((d)->func_dict_getTopEdge))(d)
|
||||||
#define dict_getShortName(d) (*((d)->func_dict_getShortName))(d)
|
#define dict_getShortName(d) (*((d)->func_dict_getShortName))(d)
|
||||||
#define dict_getFaceBounds(d,n,p) (*((d)->func_dict_getFaceBounds))((d),(n),(p))
|
|
||||||
|
|
||||||
XP_Bool dict_tilesAreSame( DictionaryCtxt* dict1, DictionaryCtxt* dict2 );
|
XP_Bool dict_tilesAreSame( DictionaryCtxt* dict1, DictionaryCtxt* dict2 );
|
||||||
|
|
||||||
|
@ -148,7 +132,7 @@ XP_U16 dict_numTiles( DictionaryCtxt* ctxt, Tile tile );
|
||||||
XP_U16 dict_numTileFaces( DictionaryCtxt* ctxt );
|
XP_U16 dict_numTileFaces( DictionaryCtxt* ctxt );
|
||||||
|
|
||||||
XP_U16 dict_tilesToString( DictionaryCtxt* ctxt, Tile* tiles, XP_U16 nTiles,
|
XP_U16 dict_tilesToString( DictionaryCtxt* ctxt, Tile* tiles, XP_U16 nTiles,
|
||||||
XP_UCHAR* buf );
|
XP_UCHAR* buf, XP_U16 bufSize );
|
||||||
XP_UCHAR* dict_getName( DictionaryCtxt* ctxt );
|
XP_UCHAR* dict_getName( DictionaryCtxt* ctxt );
|
||||||
|
|
||||||
Tile dict_tileForString( DictionaryCtxt* dict, XP_UCHAR* key );
|
Tile dict_tileForString( DictionaryCtxt* dict, XP_UCHAR* key );
|
||||||
|
|
Loading…
Reference in a new issue