[truetype] Fix `MPS' instruction.

According to Greg Hitchcock, MPS in DWrite really returns the point
size.

* src/truetype/ttobjs.h (TT_SizeRec): Add `point_size' member.

* src/truetype/ttdriver.c (tt_size_request): Set `point_size'.

* src/truetype/ttinterp.h (TT_ExecContextRec): Add `pointSize'
member.

* src/truetype/ttinterp.c (TT_Load_Context): Updated.
(Ins_MPS): Fix instruction.
This commit is contained in:
Werner Lemberg 2016-08-22 19:32:34 +02:00
parent 4927953f6c
commit a4c2a31138
5 changed files with 54 additions and 7 deletions

View File

@ -1,3 +1,20 @@
2016-08-16 Werner Lemberg <wl@gnu.org>
[truetype] Fix `MPS' instruction.
According to Greg Hitchcock, MPS in DWrite really returns the point
size.
* src/truetype/ttobjs.h (TT_SizeRec): Add `point_size' member.
* src/truetype/ttdriver.c (tt_size_request): Set `point_size'.
* src/truetype/ttinterp.h (TT_ExecContextRec): Add `pointSize'
member.
* src/truetype/ttinterp.c (TT_Load_Context): Updated.
(Ins_MPS): Fix instruction.
2016-08-16 Werner Lemberg <wl@gnu.org>
[lzw] Optimize last commit.

View File

@ -339,6 +339,25 @@
{
error = tt_size_reset( ttsize );
ttsize->root.metrics = ttsize->metrics;
#ifdef TT_USE_BYTECODE_INTERPRETER
/* for the `MPS' bytecode instruction we need the point size */
{
FT_UInt resolution = ttsize->metrics.x_ppem > ttsize->metrics.y_ppem
? req->horiResolution
: req->vertResolution;
/* if we don't have a resolution value, assume 72dpi */
if ( req->type == FT_SIZE_REQUEST_TYPE_SCALES ||
!resolution )
resolution = 72;
ttsize->point_size = FT_MulDiv( ttsize->ttmetrics.ppem,
64 * 72,
resolution );
}
#endif
}
return error;

View File

@ -397,6 +397,7 @@
exec->maxIDefs = size->max_instruction_defs;
exec->FDefs = size->function_defs;
exec->IDefs = size->instruction_defs;
exec->pointSize = size->point_size;
exec->tt_metrics = size->ttmetrics;
exec->metrics = size->metrics;
@ -2580,13 +2581,20 @@
Ins_MPS( TT_ExecContext exc,
FT_Long* args )
{
/* Note: The point size should be irrelevant in a given font program; */
/* we thus decide to return only the PPEM value. */
#if 0
args[0] = exc->metrics.pointSize;
#else
args[0] = exc->func_cur_ppem( exc );
#endif
if ( NO_SUBPIXEL_HINTING )
{
/* Microsoft's GDI bytecode interpreter always returns value 12; */
/* we return the current PPEM value instead. */
args[0] = exc->func_cur_ppem( exc );
}
else
{
/* A possible practical application of the MPS instruction is to */
/* implement optical scaling and similar features, which should be */
/* based on perceptual attributes, thus independent of the */
/* resolution. */
args[0] = exc->pointSize;
}
}

View File

@ -170,6 +170,7 @@ FT_BEGIN_HEADER
pts,
twilight;
FT_Long pointSize; /* in 26.6 format */
FT_Size_Metrics metrics;
TT_Size_Metrics tt_metrics; /* size metrics */

View File

@ -286,6 +286,8 @@ FT_BEGIN_HEADER
#ifdef TT_USE_BYTECODE_INTERPRETER
FT_Long point_size; /* for the `MPS' bytecode instruction */
FT_UInt num_function_defs; /* number of function definitions */
FT_UInt max_function_defs;
TT_DefArray function_defs; /* table of function definitions */