mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 04:39:45 +00:00
Store each glyph name only once in PostScript driver.
This commit is contained in:
parent
92205aaf98
commit
efb6460e79
@ -9,6 +9,7 @@ IMPORTS = user32 gdi32 winspool.drv kernel32 ntdll
|
||||
|
||||
C_SRCS = \
|
||||
afm.c \
|
||||
agl.c \
|
||||
bitblt.c \
|
||||
bitmap.c \
|
||||
brush.c \
|
||||
@ -17,6 +18,7 @@ C_SRCS = \
|
||||
driver.c \
|
||||
escape.c \
|
||||
font.c \
|
||||
glyphlist.c \
|
||||
graphics.c \
|
||||
init.c \
|
||||
objects.c \
|
||||
|
@ -88,7 +88,7 @@ static void PSDRV_AFMGetCharMetrics(AFM *afm, FILE *fp)
|
||||
}
|
||||
|
||||
else if(!strncmp("N ", item, 2)) {
|
||||
strncpy( metric->N, value, sizeof(metric->N) );
|
||||
metric->N = PSDRV_GlyphName(value);
|
||||
}
|
||||
|
||||
else if(!strncmp("B ", item, 2)) {
|
||||
@ -96,7 +96,7 @@ static void PSDRV_AFMGetCharMetrics(AFM *afm, FILE *fp)
|
||||
&metric->B.urx, &metric->B.ury);
|
||||
|
||||
/* Store height of Aring to use as lfHeight */
|
||||
if(metric->N && !strncmp(metric->N, "Aring", 5))
|
||||
if(metric->N && !strncmp(metric->N->sz, "Aring", 5))
|
||||
afm->FullAscender = metric->B.ury;
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ static void PSDRV_AFMGetCharMetrics(AFM *afm, FILE *fp)
|
||||
}
|
||||
|
||||
TRACE("Metrics for '%s' WX = %f B = %f,%f - %f,%f\n",
|
||||
metric->N, metric->WX, metric->B.llx, metric->B.lly,
|
||||
metric->N->sz, metric->WX, metric->B.llx, metric->B.lly,
|
||||
metric->B.urx, metric->B.ury);
|
||||
}
|
||||
|
||||
@ -407,7 +407,7 @@ static void PSDRV_ReencodeCharWidths(AFM *afm)
|
||||
continue;
|
||||
}
|
||||
for (j = 0, metric = afm->Metrics; j < afm->NumofMetrics; j++, metric++) {
|
||||
if(!strcmp(metric->N, PSDRV_ANSIVector[i])) {
|
||||
if(metric->N && !strcmp(metric->N->sz, PSDRV_ANSIVector[i])) {
|
||||
afm->CharWidths[i] = metric->WX;
|
||||
break;
|
||||
}
|
||||
@ -447,7 +447,7 @@ static void PSDRV_DumpFontList(void)
|
||||
* PSDRV_GetFontMetrics
|
||||
*
|
||||
* Only exported function in this file. Parses all afm files listed in
|
||||
* [afmfiles] of wine.conf .
|
||||
* [afmfiles] and [afmdirs] of wine.conf .
|
||||
*/
|
||||
|
||||
static void PSDRV_ReadAFMDir(const char* afmdir) {
|
||||
@ -487,6 +487,9 @@ BOOL PSDRV_GetFontMetrics(void)
|
||||
char key[256];
|
||||
char value[256];
|
||||
|
||||
if (PSDRV_GlyphListInit() != 0)
|
||||
return FALSE;
|
||||
|
||||
while (PROFILE_EnumWineIniString( "afmfiles", idx++, key, sizeof(key), value, sizeof(value)))
|
||||
{
|
||||
AFM* afm = PSDRV_AFMParse(value);
|
||||
@ -504,6 +507,7 @@ BOOL PSDRV_GetFontMetrics(void)
|
||||
value, sizeof (value)); ++idx)
|
||||
PSDRV_ReadAFMDir (value);
|
||||
|
||||
PSDRV_DumpGlyphList();
|
||||
PSDRV_DumpFontList();
|
||||
return TRUE;
|
||||
}
|
||||
|
3182
dlls/wineps/agl.c
Normal file
3182
dlls/wineps/agl.c
Normal file
File diff suppressed because it is too large
Load Diff
195
dlls/wineps/glyphlist.c
Normal file
195
dlls/wineps/glyphlist.c
Normal file
@ -0,0 +1,195 @@
|
||||
/*******************************************************************************
|
||||
*
|
||||
* Functions and data structures used to maintain a single list of glyph
|
||||
* names. The list is sorted alphabetically and each name appears only
|
||||
* once. After all font information has been read, the 'index' field of
|
||||
* each GLYPHNAME structure is initialized, so future sorts/searches can
|
||||
* be done without comparing strings.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "psdrv.h"
|
||||
#include "debugtools.h"
|
||||
|
||||
DEFAULT_DEBUG_CHANNEL(psdrv);
|
||||
|
||||
#define GLYPHLIST_ALLOCSIZE 1024
|
||||
|
||||
static GLYPHNAME **glyphList = NULL;
|
||||
static INT glyphListSize = 0;
|
||||
|
||||
/*******************************************************************************
|
||||
* PSDRV_GlyphListInit
|
||||
*
|
||||
* Allocates initial block of memory for the glyph list and copies pointers to
|
||||
* the AGL glyph names into it; returns 0 on success, 1 on failure
|
||||
*
|
||||
*/
|
||||
INT PSDRV_GlyphListInit()
|
||||
{
|
||||
INT i;
|
||||
|
||||
/*
|
||||
* Compute the smallest multiple of GLYPHLIST_ALLOCSIZE that is
|
||||
* greater than or equal to PSDRV_AGLGlyphNamesSize
|
||||
*
|
||||
*/
|
||||
glyphListSize = PSDRV_AGLGlyphNamesSize;
|
||||
i = ((glyphListSize + GLYPHLIST_ALLOCSIZE - 1) / GLYPHLIST_ALLOCSIZE) *
|
||||
GLYPHLIST_ALLOCSIZE;
|
||||
|
||||
TRACE("glyphList will initially hold %i glyph names\n", i);
|
||||
|
||||
glyphList = (GLYPHNAME **) HeapAlloc(PSDRV_Heap, 0,
|
||||
i * sizeof(GLYPHNAME *));
|
||||
if (glyphList == NULL)
|
||||
{
|
||||
ERR("Failed to allocate %i bytes of memory\n", i * sizeof(GLYPHNAME *));
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < glyphListSize; ++i)
|
||||
glyphList[i] = PSDRV_AGLGlyphNames + i;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* GlyphListInsert
|
||||
*
|
||||
* Inserts a copy of the glyph name into the list at the index, growing the
|
||||
* list if necessary; returns index on success (-1 on failure)
|
||||
*
|
||||
* _glyphname is a version of GLYPHNAME with non-constant members, so it can
|
||||
* be initialized without generating compiler warnings
|
||||
*
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
INT index;
|
||||
LPSTR sz;
|
||||
} _glyphname;
|
||||
|
||||
inline INT GlyphListInsert(LPCSTR szName, INT index)
|
||||
{
|
||||
_glyphname *g;
|
||||
|
||||
g = (_glyphname *)HeapAlloc(PSDRV_Heap, 0,
|
||||
sizeof(GLYPHNAME) + strlen(szName) + 1);
|
||||
if (g == NULL)
|
||||
{
|
||||
ERR("Failed to allocate %i bytes of memory\n",
|
||||
sizeof(GLYPHNAME) + strlen(szName) + 1);
|
||||
return -1;
|
||||
}
|
||||
|
||||
g->index = -1;
|
||||
g->sz = (LPSTR)(g + 1);
|
||||
strcpy(g->sz, szName);
|
||||
|
||||
if (glyphListSize % GLYPHLIST_ALLOCSIZE == 0) /* grow the list? */
|
||||
{
|
||||
GLYPHNAME **newGlyphList;
|
||||
|
||||
newGlyphList = (GLYPHNAME **) HeapReAlloc(PSDRV_Heap, 0, glyphList,
|
||||
(glyphListSize + GLYPHLIST_ALLOCSIZE) * sizeof(GLYPHNAME *));
|
||||
if (newGlyphList == NULL)
|
||||
{
|
||||
ERR("Failed to allocate %i bytes of memory\n", (glyphListSize +
|
||||
GLYPHLIST_ALLOCSIZE) * sizeof (GLYPHNAME *));
|
||||
HeapFree(PSDRV_Heap, 0, g);
|
||||
return -1;
|
||||
}
|
||||
|
||||
glyphList = newGlyphList;
|
||||
|
||||
TRACE("glyphList will now hold %i glyph names\n",
|
||||
glyphListSize + GLYPHLIST_ALLOCSIZE);
|
||||
}
|
||||
|
||||
if (index < glyphListSize)
|
||||
{
|
||||
memmove(glyphList + (index + 1), glyphList + index,
|
||||
(glyphListSize - index) * sizeof(GLYPHNAME *));
|
||||
}
|
||||
|
||||
glyphList[index] = (GLYPHNAME *)g;
|
||||
++glyphListSize;
|
||||
|
||||
TRACE("Added '%s' at glyphList[%i] (glyphListSize now %i)\n",
|
||||
glyphList[index]->sz, index, glyphListSize);
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* GlyphListSearch
|
||||
*
|
||||
* Searches the specified portion of the list for the glyph name and inserts it
|
||||
* in the list if necessary; returns the index at which the name (now) resides
|
||||
* (-1 if unable to insert it)
|
||||
*
|
||||
*/
|
||||
static INT GlyphListSearch(LPCSTR szName, INT loIndex, INT hiIndex)
|
||||
{
|
||||
INT midIndex, cmpResult;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (loIndex > hiIndex)
|
||||
return GlyphListInsert(szName, loIndex);
|
||||
|
||||
midIndex = (loIndex + hiIndex) >> 1;
|
||||
|
||||
cmpResult = strcmp(szName, glyphList[midIndex]->sz);
|
||||
|
||||
if (cmpResult == 0)
|
||||
{
|
||||
TRACE("Found '%s' at glyphList[%i]\n", glyphList[midIndex]->sz,
|
||||
midIndex);
|
||||
return midIndex;
|
||||
}
|
||||
|
||||
if (cmpResult < 0)
|
||||
hiIndex = midIndex - 1;
|
||||
else
|
||||
loIndex = midIndex + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* PSDRV_GlyphName
|
||||
*
|
||||
* Searches the glyph name list for the provided name, adds it to the list if
|
||||
* necessary, and returns a pointer to it (NULL if unable to add it)
|
||||
*
|
||||
*/
|
||||
const GLYPHNAME *PSDRV_GlyphName(LPCSTR szName)
|
||||
{
|
||||
INT index;
|
||||
|
||||
TRACE("'%s'\n", szName);
|
||||
|
||||
index = GlyphListSearch(szName, 0, glyphListSize - 1);
|
||||
if (index < 0)
|
||||
return NULL;
|
||||
|
||||
return glyphList[index];
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* PSDRV_DumpGlyphList
|
||||
*
|
||||
* Print contents of glyph list for debugging purposes
|
||||
*
|
||||
*/
|
||||
VOID PSDRV_DumpGlyphList()
|
||||
{
|
||||
INT i;
|
||||
|
||||
TRACE("%i glyph names:\n", glyphListSize);
|
||||
|
||||
for (i = 0; i < glyphListSize; ++i)
|
||||
TRACE(" glyphList[%i] -> '%s'\n", i, glyphList[i]->sz);
|
||||
}
|
@ -14,6 +14,25 @@
|
||||
#include "wine/wingdi16.h"
|
||||
#include "winspool.h"
|
||||
|
||||
typedef struct {
|
||||
INT index;
|
||||
const LPCSTR sz;
|
||||
} GLYPHNAME;
|
||||
|
||||
typedef struct {
|
||||
LONG UV;
|
||||
const GLYPHNAME *const name;
|
||||
} UNICODEGLYPH;
|
||||
|
||||
typedef struct {
|
||||
INT size;
|
||||
const UNICODEGLYPH *const glyphs;
|
||||
} UNICODEVECTOR;
|
||||
|
||||
extern const INT PSDRV_AGLGlyphNamesSize;
|
||||
extern GLYPHNAME PSDRV_AGLGlyphNames[];
|
||||
extern const UNICODEVECTOR PSDRV_AdobeGlyphList;
|
||||
|
||||
typedef struct {
|
||||
float llx, lly, urx, ury;
|
||||
} AFMBBOX;
|
||||
@ -27,7 +46,7 @@ typedef struct _tagAFMLIGS {
|
||||
typedef struct _tagAFMMETRICS {
|
||||
int C; /* character */
|
||||
float WX;
|
||||
char N[32]; /* name */
|
||||
const GLYPHNAME *N; /* name */
|
||||
AFMBBOX B;
|
||||
AFMLIGS *L; /* Ligatures */
|
||||
} AFMMETRICS;
|
||||
@ -382,6 +401,9 @@ extern DWORD PSDRV_DeviceCapabilities(LPSTR lpszDriver, LPCSTR lpszDevice,
|
||||
WORD fwCapability, LPSTR lpszOutput,
|
||||
LPDEVMODEA lpdm);
|
||||
VOID PSDRV_DrawLine( DC *dc );
|
||||
INT PSDRV_GlyphListInit();
|
||||
const GLYPHNAME *PSDRV_GlyphName(LPCSTR szName);
|
||||
VOID PSDRV_DumpGlyphList();
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user