wineps.drv: Add a heuristic to cope with resolution strings of the form "nnnmmmdpi" (ie without the 'x' separator).
This commit is contained in:
parent
bc426ab059
commit
f7f5ed1996
|
@ -516,6 +516,70 @@ static char *PSDRV_PPDGetWord(char *str, char **next)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/************************************************************
|
||||||
|
* parse_resolution
|
||||||
|
*
|
||||||
|
* Helper to extract x and y resolutions from a resolution entry.
|
||||||
|
* Returns TRUE on successful parsing, otherwise FALSE.
|
||||||
|
*
|
||||||
|
* The ppd spec says that entries can either be:
|
||||||
|
* "nnndpi"
|
||||||
|
* or
|
||||||
|
* "nnnxmmmdpi"
|
||||||
|
* in the former case return sz.cx == cx.cy == nnn.
|
||||||
|
*
|
||||||
|
* There are broken ppd files out there (notably from Samsung) that
|
||||||
|
* use the form "nnnmmmdpi", so we have to work harder to spot these.
|
||||||
|
* We use a transition from a zero to a non-zero digit as separator
|
||||||
|
* (and fail if we find more than one of these). We also don't bother
|
||||||
|
* trying to parse "dpi" in case that's missing.
|
||||||
|
*/
|
||||||
|
static BOOL parse_resolution(const char *str, SIZE *sz)
|
||||||
|
{
|
||||||
|
int tmp[2];
|
||||||
|
int *cur;
|
||||||
|
BOOL had_zero;
|
||||||
|
const char *c;
|
||||||
|
|
||||||
|
if(sscanf(str, "%dx%d", tmp, tmp + 1) == 2)
|
||||||
|
{
|
||||||
|
sz->cx = tmp[0];
|
||||||
|
sz->cy = tmp[1];
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp[0] = 0;
|
||||||
|
tmp[1] = -1;
|
||||||
|
cur = tmp;
|
||||||
|
had_zero = FALSE;
|
||||||
|
for(c = str; isdigit(*c); c++)
|
||||||
|
{
|
||||||
|
if(!had_zero || *c == '0')
|
||||||
|
{
|
||||||
|
*cur *= 10;
|
||||||
|
*cur += *c - '0';
|
||||||
|
if(*c == '0')
|
||||||
|
had_zero = TRUE;
|
||||||
|
}
|
||||||
|
else if(cur != tmp)
|
||||||
|
return FALSE;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cur++;
|
||||||
|
*cur = *c - '0';
|
||||||
|
had_zero = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(tmp[0] == 0) return FALSE;
|
||||||
|
|
||||||
|
sz->cx = tmp[0];
|
||||||
|
if(tmp[1] != -1)
|
||||||
|
sz->cy = tmp[1];
|
||||||
|
else
|
||||||
|
sz->cy = sz->cx;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* PSDRV_AddSlot
|
* PSDRV_AddSlot
|
||||||
*
|
*
|
||||||
|
@ -605,8 +669,14 @@ PPD *PSDRV_ParsePPD(char *fname)
|
||||||
|
|
||||||
else if((!strcmp("*DefaultResolution", tuple.key)) ||
|
else if((!strcmp("*DefaultResolution", tuple.key)) ||
|
||||||
(!strcmp("*DefaultJCLResolution", tuple.key))) {
|
(!strcmp("*DefaultJCLResolution", tuple.key))) {
|
||||||
sscanf(tuple.value, "%d", &(ppd->DefaultResolution));
|
SIZE sz;
|
||||||
TRACE("DefaultResolution = %d\n", ppd->DefaultResolution);
|
if(parse_resolution(tuple.value, &sz))
|
||||||
|
{
|
||||||
|
TRACE("DefaultResolution %dx%d\n", sz.cx, sz.cy);
|
||||||
|
ppd->DefaultResolution = sz.cx;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
WARN("failed to parse DefaultResolution %s\n", debugstr_a(tuple.value));
|
||||||
}
|
}
|
||||||
|
|
||||||
else if(!strcmp("*Font", tuple.key)) {
|
else if(!strcmp("*Font", tuple.key)) {
|
||||||
|
|
Loading…
Reference in New Issue