Hello,

Recently I noticed a change in default FreeType rendering
of one of the fonts I use; the change was not desirable
for this font, so I tried to reproduce the older behaviour.

I tested different configuration options from ftoption.h,
each time opening the font with FT_PARAM_TAG_UNPATENTED_HINTING,
as documented in ftoption.h, and without it.

I distiguish the interpreters by the form if the
outline: the 'unpatented' one produces a regular
rectangle (which is the desirable result),
the 'patented' one emits a trapezium.

The test program source and it's output is attached.
The command line was './dec lohit_hi.ttf 109', the font file being
http://savannah.nongnu.org/bugs/download.php?file_id=21450

It appears that:

When configured for FT_TRUETYPE_ENGINE_TYPE_NONE, it uses
the 'unpatented' bytecode interpreter in both cases;

When configured for FT_TRUETYPE_ENGINE_TYPE_UNPATENTED, it uses
the 'unpatented' bytecode interpreter when
ft2-truetype_tables.html#FT_PARAM_TAG_UNPATENTED_HINTING
documents the 'patented' one and vice versa;

When configured for FT_TRUETYPE_ENGINE_TYPE_PATENTED (current
default), it uses the 'patented' bytecode interpreter in both cases.

It means that either I do something wrong again (after all,
ftview shows rectangle in all configurations) or newer FreeType
versions in default configuration are uncapable to render
'certain Asian fonts' as they used to;
in the latter case, I'm really not sure what is intended,
but probably there should be more documentation details about it.
#include <stdio.h>
#include <stdlib.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_MODULE_H
#include FT_OUTLINE_H
#include FT_UNPATENTED_HINTING_H

static int
conic_to_func (const FT_Vector* control, const FT_Vector* to, void* p)
{
  printf ("conic_to (%i %i) (%i %i)\n", (int)control->x, (int)control->y,
	  (int)to->x, (int)to->y);
  return 0;
}

static int
cubic_to_func (const FT_Vector* ctl1, const FT_Vector* ctl2,
	       const FT_Vector* to, void* p)
{
  const FT_Vector *v1, *v2, *v3;

  v1 = ctl1;
  v2 = ctl2;
  v3 = to;

  printf ("cubic_to (%i %i) (%i %i) (%i %i)\n", (int)v1->x, (int)v1->y,
	  (int)v2->x, (int)v2->y, (int)v3->x, (int)v3->y);
  return 0;
}

static int
line_to_func (const FT_Vector* v, void* p)
{
  printf("line_to %i %i\n", (int)v->x, (int)v->y);
  return 0;
}
static int
move_to_func (const FT_Vector* v, void* p)
{
  printf("move_to (%i %i)\n", (int)v->x, (int)v->y);
  return 0;
}

static FT_Outline_Funcs outline_funcs =
{
  (FT_Outline_MoveToFunc)move_to_func,
  (FT_Outline_LineToFunc)line_to_func,
  (FT_Outline_ConicToFunc)conic_to_func,
  (FT_Outline_CubicToFunc)cubic_to_func,
  0, 0
};

static void
print_version (FT_Library l)
{
  FT_Int min, maj, pat;

  FT_Library_Version (l, &maj, &min, &pat);
  printf ("FreeType %i.%i.%i (", maj, min, pat);
  switch (FT_Get_TrueType_Engine_Type (l))
    {
    case FT_TRUETYPE_ENGINE_TYPE_NONE:
      printf ("FT_TRUETYPE_ENGINE_TYPE_NONE");
      break;
    case FT_TRUETYPE_ENGINE_TYPE_UNPATENTED:
      printf ("FT_TRUETYPE_ENGINE_TYPE_UNPATENTED");
      break;
    case FT_TRUETYPE_ENGINE_TYPE_PATENTED:
      printf ("FT_TRUETYPE_ENGINE_TYPE_PATENTED");
      break;
    }
  printf(")\n");
}

int
main (int argc, char **argv)
{
  int index = 1;
  FT_Library library;
  FT_Face face;
  FT_Error error;
  FT_GlyphSlot slot;
  FT_Open_Args args;
  FT_Parameter parameter;

  if (argc > 2)
    sscanf (argv[2], "%i", &index);
  error = FT_Init_FreeType (&library);
  if (error)
    {
      fprintf (stderr, "Can't load FreeType2 library\n");
      return !0;
    }
  print_version (library);

  args.flags = FT_OPEN_PATHNAME | FT_OPEN_PARAMS;
  args.pathname = argv[1];
  parameter.tag = FT_PARAM_TAG_UNPATENTED_HINTING;
  args.num_params = 1;
  args.params = &parameter;

  printf ("decomposing with FT_PARAM_TAG_UNPATENTED_HINTING\n");
  error = FT_Open_Face(library, &args, 0, &face);
  if (error)
    {
      fprintf(stderr, "Can't create face\n");
      return !0;
    }
  error = FT_Set_Char_Size (face, 20 * 64, 0, 100, 0);
  if (error)
    {
      fprintf(stderr, "Can't set char size\n");
      return !0;
    }
  error = FT_Load_Glyph (face, index, FT_LOAD_RENDER);
  if (error)
    {
      fprintf(stderr, "Can't load glyph index %i\n", index);
      return !0;
    }
  slot = face->glyph;
  FT_Outline_Decompose (&slot->outline, &outline_funcs, NULL);

  args.flags = FT_OPEN_PATHNAME;
  args.pathname = argv[1];
  args.num_params = 0;
  args.params = NULL;

  printf ("decomposing without FT_PARAM_TAG_UNPATENTED_HINTING\n");
  error = FT_Open_Face(library, &args, 0, &face);
  if (error)
    {
      fprintf(stderr, "Can't create face\n");
      return !0;
    }
  error = FT_Set_Char_Size (face, 20 * 64, 0, 100, 0);
  if (error)
    {
      fprintf(stderr, "Can't set char size\n");
      return !0;
    }
  error = FT_Load_Glyph (face, index, FT_LOAD_RENDER);
  if (error)
    {
      fprintf(stderr, "Can't load glyph index %i\n", index);
      return !0;
    }
  slot = face->glyph;
  FT_Outline_Decompose (&slot->outline, &outline_funcs, NULL);

  return 0;
}
FreeType 2.4.2 (FT_TRUETYPE_ENGINE_TYPE_NONE)
decomposing with FT_PARAM_TAG_UNPATENTED_HINTING
move_to (330 0)
line_to 330 1156
line_to 448 1156
line_to 448 0
line_to 330 0
line_to 330 0
decomposing without FT_PARAM_TAG_UNPATENTED_HINTING
move_to (330 0)
line_to 330 1156
line_to 448 1156
line_to 448 0
line_to 330 0
line_to 330 0
FreeType 2.4.2 (FT_TRUETYPE_ENGINE_TYPE_UNPATENTED)
decomposing with FT_PARAM_TAG_UNPATENTED_HINTING
move_to (290 0)
line_to 320 1152
line_to 406 1152
line_to 406 0
line_to 290 0
line_to 290 0
decomposing without FT_PARAM_TAG_UNPATENTED_HINTING
move_to (330 0)
line_to 330 1156
line_to 448 1156
line_to 448 0
line_to 330 0
line_to 330 0
FreeType 2.4.2 (FT_TRUETYPE_ENGINE_TYPE_PATENTED)
decomposing with FT_PARAM_TAG_UNPATENTED_HINTING
move_to (290 0)
line_to 320 1152
line_to 406 1152
line_to 406 0
line_to 290 0
line_to 290 0
decomposing without FT_PARAM_TAG_UNPATENTED_HINTING
move_to (290 0)
line_to 320 1152
line_to 406 1152
line_to 406 0
line_to 290 0
line_to 290 0
_______________________________________________
Freetype mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/freetype

Reply via email to