freetype
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ft] Large delta_y for hinted vs unhinted "COMBINING CARON BELOW" glyph


From: Nigel Tao
Subject: [ft] Large delta_y for hinted vs unhinted "COMBINING CARON BELOW" glyph
Date: Wed, 30 Oct 2013 12:48:40 +1100

I'm looking at glyphs 733 and 734 in DejaVuSans-Oblique.ttf.

ttx says that 733 is "uni032C", or "COMBINING CARON BELOW". It is a
1-component composite glyph; glyph 649 is "CARON".

    <TTGlyph name="uni032C" xMin="-790" yMin="-492" xMax="-151" yMax="-116">
      <component glyphName="caron" x="-1200" y="-1754" flags="0x1004"/>
      <instructions><assembly>
          PUSHB[ ]  /* 2 values pushed */
          0 10
          SVTCA[0]
          SRP0[ ]
          ALIGNRP[ ]
          IUP[0]
        </assembly></instructions>
    </TTGlyph>

The (vertical) difference between the hinted and unhinted COMBINING
CARON BELOW glyphs seems excessive (more than 0.5em) compared to the
change for similar glyphs (e.g. indexes 730, 731, 732, 735) and for
the CARON (index 649), both from eyeballing it in ftgrid, and from the
command line program below. Its output is:

Freetype version 2.5.0
#649 without hinting, p0 is ( 228,  394)
#649 with    hinting, p0 is ( 160,  384) delta_y =  -10
#730 without hinting, p0 is (-127,  -30)
#730 with    hinting, p0 is (-127,  -30) delta_y =    0
#731 without hinting, p0 is ( -63,  -32)
#731 with    hinting, p0 is ( -63,  -32) delta_y =    0
#732 without hinting, p0 is (-183, -117)
#732 with    hinting, p0 is (-183, -117) delta_y =    0
#733 without hinting, p0 is (-156, -182)
#733 with    hinting, p0 is (-224, -704) delta_y = -522
#734 without hinting, p0 is (-179,  -64)
#734 with    hinting, p0 is (-224, -576) delta_y = -512
#735 without hinting, p0 is (-255,  -73)
#735 with    hinting, p0 is (-319,  -64) delta_y =    9

My question is: is this a bug in freetype, a bug in the font, or is
this all working as intended and a hinted "COMBINING CARON BELOW"
really is much different from its unhinted version?

--------
#include <stdio.h>
#include <ft2build.h>
#include FT_FREETYPE_H

void usage(char** argv) {
  fprintf(stderr, "usage: %s font_size font_file
[with_hinting|sans_hinting]\n", argv[0]);
}

#define font_name "/usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Oblique.ttf"
#define font_size 10

int main(int argc, char** argv) {
  FT_Error error;
  FT_Library library;
  FT_Face face;
  FT_Outline* o;
  FT_Int major, minor, patch;
  FT_Int i, j;
  FT_Pos last_y;

  error = FT_Init_FreeType(&library);
  if (error) {
    fprintf(stderr, "FT_Init_FreeType: error #%d\n", error);
    return 1;
  }
  FT_Library_Version(library, &major, &minor, &patch);
  printf("Freetype version %d.%d.%d\n", major, minor, patch);
  error = FT_New_Face(library, font_name, 0, &face);
  if (error) {
    fprintf(stderr, "FT_New_Face: error #%d\n", error);
    return 1;
  }
  error = FT_Set_Char_Size(face, 0, font_size*64, 0, 0);
  if (error) {
    fprintf(stderr, "FT_Set_Char_Size: error #%d\n", error);
    return 1;
  }
  last_y = 0;
  for (i = 0; i < 736; i++) {
    if ((i != 649) && (i < 730))
      continue;
    for (j = 0; j < 2; j++) {
      error = FT_Load_Glyph(face, i, j ? FT_LOAD_DEFAULT : FT_LOAD_NO_HINTING);
      if (error) {
        fprintf(stderr, "FT_Load_Glyph: glyph %d: error #%d\n", i, error);
        return 1;
      }
      if (face->glyph->format != FT_GLYPH_FORMAT_OUTLINE) {
        fprintf(stderr, "glyph format for glyph %d is not
FT_GLYPH_FORMAT_OUTLINE\n", i);
        return 1;
      }
      o = &face->glyph->outline;
      if (o->n_points < 1) {
        fprintf(stderr, "empty glyph outline for glyph %d\n", i);
        return 1;
      }
      printf("#%d %s hinting, p0 is (%4ld, %4ld)",
          i, j ? "with   " : "without", o->points[0].x, o->points[0].y);
      if (j) {
        printf(" delta_y = %4ld", o->points[0].y - last_y);
      }
      printf("\n");
      last_y = o->points[0].y;
    }
  }
  return 0;
}
--------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]