static int font_with_same_UID_and_another_metrics(const gs_font *pfont0, const gs_font *pfont1) { const gs_font_base *pbfont0 = (const gs_font_base *)pfont0; const gs_font_base *pbfont1 = (const gs_font_base *)pfont1; if (uid_equal(&pbfont0->UID, &pbfont1->UID)) { const ref *pfdict0 = &pfont_data(gs_font_parent(pbfont0))->dict; const ref *pfdict1 = &pfont_data(gs_font_parent(pbfont1))->dict; ref *pmdict0, *pmdict1; if (pbfont0->WMode || dict_find_string(pfdict0, "Metrics", &pmdict0) <= 0) pmdict0 = NULL; if (pbfont1->WMode || dict_find_string(pfdict1, "Metrics", &pmdict1) <= 0) pmdict1 = NULL; if (!pmdict0 != !pmdict1) return 1; if (pmdict0 != NULL && !obj_eq(pfont0->memory, pmdict0, pmdict1)) return 1; if (!pbfont0->WMode || dict_find_string(pfdict0, "Metrics2", &pmdict0) <= 0) pmdict0 = NULL; if (!pbfont0->WMode || dict_find_string(pfdict1, "Metrics2", &pmdict1) <= 0) pmdict1 = NULL; if (!pmdict0 != !pmdict1) return 1; if (pmdict0 != NULL && !obj_eq(pfont0->memory, pmdict0, pmdict1)) return 1; } return 0; }
/* (This is a single-use procedure, for clearer code.) */ static bool fid_eq(const gs_memory_t *mem, const gs_font *pfont1, const gs_font *pfont2) { while (pfont1->base != pfont1) pfont1 = pfont1->base; while (pfont2->base != pfont2) pfont2 = pfont2->base; if (pfont1 == pfont2) return true; switch (pfont1->FontType) { case 1: case 3: if (pfont1->FontType == pfont2->FontType) break; default: return false; } /* The following, while peculiar, appears to match CPSI. */ { const gs_uid *puid1 = &((const gs_font_base *)pfont1)->UID; const gs_uid *puid2 = &((const gs_font_base *)pfont2)->UID; if (uid_is_UniqueID(puid1) || uid_is_UniqueID(puid2) || ((uid_is_XUID(puid1) || uid_is_XUID(puid2)) && !uid_equal(puid1, puid2))) return false; } { const font_data *pfd1 = (const font_data *)pfont1->client_data; const font_data *pfd2 = (const font_data *)pfont2->client_data; if (!(obj_eq(mem, &pfd1->BuildChar, &pfd2->BuildChar) && obj_eq(mem, &pfd1->BuildGlyph, &pfd2->BuildGlyph) && obj_eq(mem, &pfd1->Encoding, &pfd2->Encoding) && obj_eq(mem, &pfd1->CharStrings, &pfd2->CharStrings))) return false; if (pfont1->FontType == 1) { ref *ppd1, *ppd2; if (dict_find_string(&pfd1->dict, "Private", &ppd1) > 0 && dict_find_string(&pfd2->dict, "Private", &ppd2) > 0 && !obj_eq(mem, ppd1, ppd2)) return false; } } return true; }