[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Devel] PCF Accelerator parsing (was: pcfdriver.c memory leak)
From: |
Detlef Würkner |
Subject: |
[Devel] PCF Accelerator parsing (was: pcfdriver.c memory leak) |
Date: |
Thu, 07 Feb 2002 15:10:31 +0100 |
I wrote:
> The accel values are negative sometimes, more in the next mail.
When comparing the pcfread.c from XFree86 with the pcfread.c from
FreeType2, I find a difference in the parsing of the accelerator
tables.
XFree86 version:
----8<----
static Bool
pcfGetAccel(pFontInfo, file, tables, ntables, type)
[...]
pcfGetMetric(file, format, &pFontInfo->minbounds);
pcfGetMetric(file, format, &pFontInfo->maxbounds);
if (PCF_FORMAT_MATCH(format, PCF_ACCEL_W_INKBOUNDS)) {
pcfGetMetric(file, format, &pFontInfo->ink_minbounds);
pcfGetMetric(file, format, &pFontInfo->ink_maxbounds);
[...]
static
pcfGetMetric(file, format, metric)
FontFilePtr file;
CARD32 format;
xCharInfo *metric;
{
metric->leftSideBearing = pcfGetINT16(file, format);
metric->rightSideBearing = pcfGetINT16(file, format);
metric->characterWidth = pcfGetINT16(file, format);
metric->ascent = pcfGetINT16(file, format);
metric->descent = pcfGetINT16(file, format);
metric->attributes = pcfGetINT16(file, format);
}
static
pcfGetCompressedMetric(file, format, metric)
FontFilePtr file;
CARD32 format;
xCharInfo *metric;
{
metric->leftSideBearing = pcfGetINT8(file, format) - 0x80;
metric->rightSideBearing = pcfGetINT8(file, format) - 0x80;
metric->characterWidth = pcfGetINT8(file, format) - 0x80;
metric->ascent = pcfGetINT8(file, format) - 0x80;
metric->descent = pcfGetINT8(file, format) - 0x80;
metric->attributes = 0;
}
----8<----
pcfGetAccel() never calls pcfGetCompressedMetric(). Now the FreeType2
version:
----8<----
static FT_Error
pcf_get_accel( FT_Stream stream,
PCF_Face face,
FT_ULong type )
[...]
error = pcf_get_metric( stream, format, &(accel->minbounds) );
if ( error )
goto Bail;
error = pcf_get_metric( stream, format, &(accel->maxbounds) );
if ( error )
goto Bail;
if ( PCF_FORMAT_MATCH( format, PCF_ACCEL_W_INKBOUNDS ) )
{
error = pcf_get_metric( stream, format, &(accel->ink_minbounds) );
if ( error )
goto Bail;
error = pcf_get_metric( stream, format, &(accel->ink_maxbounds) );
[...]
static FT_Error
pcf_get_metric( FT_Stream stream,
FT_ULong format,
PCF_Metric metric )
{
FT_Error error = PCF_Err_Ok;
if ( PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
{
if ( PCF_BYTE_ORDER( format ) == MSBFirst )
error = pcf_parse_metric( stream, pcf_metric_msb_header, metric );
else
error = pcf_parse_metric( stream, pcf_metric_header, metric );
}
else
error = pcf_parse_compressed_metric( stream, metric );
^^^^^^^^^^^^^^^^^^^^^^^^^^^
----8<----
Here pcf_get_accel() can call pcf_parse_compressed_metric(). Without
XFree86 and bdftopcf running here I cant definitely tell whether the
metrics in the accelerator tables are always uncompressed, but a quick
test with an additional boolean variable passed to pcf_get_metric()
and stating whether it was called from pcf_get_accel() or not and if
yes always use pcf_parse_metric() was ok.
Problem font example:
lib/X11/fonts/75dpi/lutBS14-ISO8859-1.pcf seems to have a negative
face->accel.maxbounds.characterWidth,
lib/X11/fonts/75dpi/lutBS24-ISO8859-1.pcf has a positive
face->accel.maxbounds.characterWidth.
Ciao, Detlef
--
_ // address@hidden
\X/ Detlef Wuerkner, Langgoens/Germany