Horrid hack to assign new gids. Use DEBUG_MSG over fprintf

pull/743/merge
Rod Sheeter 7 years ago committed by Behdad Esfahbod
parent 8b80cbb1dd
commit eb485bb9e9
  1. 27
      src/hb-subset-plan.cc
  2. 5
      src/hb-subset-plan.hh
  3. 9
      src/hb-subset.cc

@ -27,7 +27,24 @@
#include "hb-subset-plan.hh"
#include "hb-subset-private.hh"
// TODO(Q1) map from old:new gid
hb_bool_t
hb_subset_plan_new_gid_for_old_id(hb_subset_plan_t *plan,
hb_codepoint_t old_gid,
hb_codepoint_t *new_gid) {
// TODO(Q1) lookup in map from old:new gid
// TEMPORARY: just loop over ids to retain and count up
hb_codepoint_t current = -1;
hb_codepoint_t count = 0;
while (hb_set_next(plan->glyphs_to_retain, &current)) {
if (old_gid == current) {
*new_gid = count;
return true;
}
count++;
}
return false;
}
hb_set_t *
glyph_ids_to_retain (hb_subset_face_t *face,
hb_set_t *codepoints)
@ -37,13 +54,15 @@ glyph_ids_to_retain (hb_subset_face_t *face,
while (hb_set_next(codepoints, &cp)) {
hb_codepoint_t gid;
if (face->cmap.get_nominal_glyph(cp, &gid)) {
// TODO(Q1) a nice way to turn on/off logs
fprintf(stderr, "gid for U+%04X is %d\n", cp, gid);
DEBUG_MSG(SUBSET, nullptr, "gid for U+%04X is %d\n", cp, gid);
hb_set_add(gids, cp);
} else {
fprintf(stderr, "Unable to resolve gid for U+%04X\n", cp);
DEBUG_MSG(SUBSET, nullptr, "Unable to resolve gid for U+%04X\n", cp);
}
}
// TODO(Q1) expand with glyphs that make up complex glyphs
// TODO expand with glyphs reached by G*
return gids;
}

@ -44,6 +44,11 @@ hb_subset_plan_create (hb_subset_face_t *face,
hb_subset_profile_t *profile,
hb_subset_input_t *input);
hb_bool_t
hb_subset_plan_new_gid_for_old_id(hb_subset_plan_t *plan,
hb_codepoint_t old_gid,
hb_codepoint_t *new_gid /* OUT */);
hb_subset_plan_t *
hb_subset_plan_get_empty ();

@ -151,6 +151,15 @@ hb_subset (hb_subset_profile_t *profile,
hb_subset_plan_t *plan = hb_subset_plan_create (face, profile, input);
hb_codepoint_t old_gid = -1;
while (hb_set_next(plan->glyphs_to_retain, &old_gid)) {
hb_codepoint_t new_gid;
if (hb_subset_plan_new_gid_for_old_id(plan, old_gid, &new_gid)) {
DEBUG_MSG(SUBSET, nullptr, "Remap %d : %d\n", old_gid, new_gid);
} else {
DEBUG_MSG(SUBSET, nullptr, "Remap %d : DOOM! No new ID\n", old_gid);
}
}
// TODO:
// - Create initial header + table directory
// - Loop through the set of tables to be kept:

Loading…
Cancel
Save