[HarfBuzz] first tests of hb_ot_layout_lookup_collect_glyphs

Werner LEMBERG wl at gnu.org
Sun Jun 16 01:03:11 PDT 2013


[harfbuzz 79d1007a501fd63c0ba4d51038c513e6b8b94740]


Behdad,


the attached program gives the also attached output if applied to
`pala.ttf', version 1.00 (which is ooold).  Interestingly,
`hb_ot_layout_collect_lookups' returns incorrect values: According to
ttx (output also attached), the lookups affected by `smcp' are only 8
and 9, while my demo program reports 7 also...  And indeed, the first
four glyphs in the list are incorrect.  Note that the function seems
to work fine with other fonts like Libertine, or even `pala.ttf'
version 5.00.

I'm sending you `pala.ttf' v1 privately.


    Werner
-------------- next part --------------
#include <stdio.h>

#include <ft2build.h>
#include FT_FREETYPE_H

#include <hb.h>
#include <hb-ot.h>
#include <hb-ft.h>


int
main(int argc,
     char** argv)
{
  int ret = 0;

  FT_Error ft_error;
  FT_Library ft_library;
  FT_Face ft_face;

  hb_face_t* face;
  hb_set_t* lookups;
  hb_codepoint_t lookup_index;

  hb_set_t* glyphs;
  hb_codepoint_t glyph_index;

  hb_tag_t features[] =
  {
    HB_TAG ('s', 'm', 'c', 'p'),
    HB_TAG_NONE
  };  


  ft_error = FT_Init_FreeType(&ft_library);
  if (ft_error)
  {
    fprintf(stderr, "Calling `FT_Init_FreeType' failed.\n");
    ret = -1;
    goto Exit;
  }
  ft_error = FT_New_Face(ft_library, argv[1], 0, &ft_face);
  if (ft_error)
  {
    fprintf(stderr, "Can't create face for font `%s'\n", argv[1]);
    ret = -1;
    goto Exit;
  }
  
  face = hb_ft_face_create(ft_face, NULL);
  lookups = hb_set_create();
  glyphs = hb_set_create();

  hb_ot_layout_collect_lookups(face,
                               HB_OT_TAG_GSUB,
                               NULL,
                               NULL,
                               features,
                               lookups);

  printf("lookups used in `smcp' feature:\n");
  for (lookup_index = -1; hb_set_next(lookups, &lookup_index); )
  {
    printf("  %d\n", lookup_index);
    hb_ot_layout_lookup_collect_glyphs(face,
                                       HB_OT_TAG_GSUB,
                                       lookup_index,
                                       NULL,
                                       NULL,
                                       NULL,
                                       glyphs);
  }

  printf("\n");

  printf("resulting glyphs of `smcp' feature:\n");
  for (glyph_index = -1; hb_set_next(glyphs, &glyph_index); )
    printf("  %d\n", glyph_index);

  hb_set_destroy(glyphs);
  hb_set_destroy(lookups);
  hb_face_destroy(face);

Exit:
  FT_Done_FreeType(ft_library);

  return ret;
}
-------------- next part --------------
lookups used in `smcp' feature:
  7
  8
  9

resulting glyphs of `smcp' feature:
  106
  108
  242
  244
  1102
  1103
  1104
  1105
  1106
  1107
  1108
  1109
  1110
  1111
  1112
  1113
  1114
  1115
  1116
  1117
  1118
  1119
  1120
  1121
  1122
  1123
  1124
  1125
  1126
  1127
  1128
  1129
  1130
  1131
  1132
  1133
  1134
  1135
  1136
  1137
  1138
  1139
  1140
  1141
  1142
  1143
  1144
  1145
  1146
  1147
  1148
  1149
  1150
  1151
  1152
  1153
  1154
  1155
  1156
  1157
  1158
  1159
  1160
  1161
  1162
  1163
  1164
  1165
  1166
  1167
  1168
  1169
  1170
  1171
  1172
  1173
  1174
  1175
  1176
  1177
  1178
  1179
  1180
  1181
  1182
  1183
  1184
  1185
  1186
  1187
  1188
  1189
  1190
  1191
  1192
  1193
  1194
  1195
  1196
  1197
  1198
  1199
  1200
  1201
  1202
  1203
  1204
  1205
  1206
  1207
  1208
  1210
  1211
  1212
  1213
  1214
  1215
  1216
  1217
  1218
  1219
  1220
  1221
  1222
  1223
  1224
  1225
  1226
  1227
  1228
  1229
  1230
  1231
  1232
  1233
  1234
  1235
  1236
  1237
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pala-1.00.ttx.xz
Type: application/octet-stream
Size: 2612 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/harfbuzz/attachments/20130616/6608ba02/attachment.obj>


More information about the HarfBuzz mailing list