void analyze_range (font fn, font_metric fnm, array<string>& r, string family) { bool ec= starts (family, "ec") && ends (family, "10"); string lfn= locase_all (family); if (starts (lfn, "lastresort") || starts (lfn, "tex ams blackboard bold") || (starts (lfn, "tex blackboard bold") && !starts (lfn, "tex blackboard bold variant")) || starts (lfn, "tex calligraphic capitals") || starts (lfn, "tex double stroke") || starts (lfn, "tex ralph smith")) return; if (range_exists (fnm, 0x21, 0x7e) || ec) r << string ("Ascii"); if (range_exists (fnm, 0xc0, 0xff) || ec) r << string ("Latin"); if (range_percentage (fnm, 0x391, 0x3ce) > 66.6 || ec) r << string ("Greek"); if (range_percentage (fnm, 0x410, 0x44f) > 66.6 || ec) r << string ("Cyrillic"); if (range_percentage (fnm, 0x4e00, 0x4eff) > 0.0) { double perc= range_percentage (fnm, 0x4e00, 0x9fcc); //cout << "percentage -> " << perc << "\n"; if (perc > 20.0) r << string ("CJK"); } if (range_percentage (fnm, 0xac00, 0xacff) > 0.0) { double perc= range_percentage (fnm, 0xac00, 0xd7af); //cout << "percentage -> " << perc << "\n"; if (perc > 20.0) r << string ("Hangul"); } if (range_percentage (fnm, 0x2100, 0x21ff) > 0.0) { double perc= range_percentage (fnm, 0x2000, 0x23ff); //cout << "percentage -> " << perc << "\n"; if (perc > 20.0) r << string ("MathSymbols"); } if (range_percentage (fnm, 0x2900, 0x29ff) > 0.0) { double perc= range_percentage (fnm, 0x2900, 0x2e7f); //cout << "percentage -> " << perc << "\n"; if (perc > 20.0) r << string ("MathExtra"); } if (range_percentage (fnm, 0x1d400, 0x1d4ff) > 0.0) { double perc= range_percentage (fnm, 0x1d400, 0x1d7ff); //cout << "percentage -> " << perc << "\n"; if (perc > 20.0) r << string ("MathLetters"); } if (!sane_font (r, fnm, family, "Greek", 0x391) && !ec) r= exclude (r, "Greek"); if (!sane_font (r, fnm, family, "Cyrillic", 0x430) && !ec) r= exclude (r, "Cyrillic"); }
void analyze_trace (font fn, font_metric fnm, array<string>& r) { if (range_exists (fnm, 0x41, 0x5a)) { array<int> wa; wa << build_range (0x41, 0x46); wa << 0x49 << 0x4a << 0x4d << 0x52 << 0x53 << 0x57; string wt= width_trace (fnm, wa); r << (string ("upw=") * wt); array<int> ha; ha << 0x41 << 0x42 << 0x43 << 0x44 << 0x47 << 0x48 << 0x4a << 0x4d << 0x4e << 0x51; string ht= height_trace (fnm, ha); r << (string ("uph=") * ht); array<int> ca; ca << 0x41 << 0x42 << 0x43 << 0x44 << 0x45 << 0x48 << 0x49 << 0x4a << 0x4d << 0x4e << 0x53 << 0x57; string ct= count_trace (fn, ca); if (ct != "") r << (string ("upc=") * ct); } if (range_exists (fnm, 0x61, 0x7a)) { array<int> wa; wa << build_range (0x61, 0x66); wa << 0x69 << 0x6a << 0x6c << 0x6d << 0x74 << 0x77; string wt= width_trace (fnm, wa); r << (string ("low=") * wt); array<int> ha; ha << 0x61 << 0x62 << 0x63 << 0x64 << 0x66 << 0x67 << 0x69 << 0x6a << 0x70 << 0x71 << 0x74 << 0x7a; string ht= height_trace (fnm, ha); r << (string ("loh=") * ht); array<int> ca; ca << 0x61 << 0x62 << 0x63 << 0x64 << 0x65 << 0x66 << 0x68 << 0x69 << 0x6d << 0x72 << 0x79 << 0x7a; string ct= count_trace (fn, ca); if (ct != "") r << (string ("loc=") * ct); } }
void analyze_special (font fn, font_metric fnm, array<string>& r) { if (range_exists (fnm, 0x41, 0x5a) && range_exists (fnm, 0x61, 0x7a)) { bool mono= true; metric_struct* x= fnm->get (0x41); for (int i= 0x42; i<=0x7a; i++) if (i <= 0x5a || i >= 0x61) { metric_struct* y= fnm->get (i); if (y->x2 != x->x2) { mono= false; break; } } if (mono) r << string ("mono=yes"); else r << string ("mono=no"); } if (range_exists (fnm, 0x41, 0x5a)) { glyph glL= fn->get_glyph ("L"); if (!is_nil (glL)) { bool sans= is_sans_serif (glL); if (sans) r << string ("sans=yes"); else r << string ("sans=no"); } } if (range_exists (fnm, 0x5b, 0x5b)) { glyph gl= fn->get_glyph ("["); if (!is_nil (gl)) { int sl= (int) floor (100.0 * get_slant (gl) + 0.5); r << (string ("slant=") * as_string (sl)); } } if (range_exists (fnm, 0x61, 0x7a)) { bool italic= true; glyph ga= fn->get_glyph ("a"); if (is_nil (ga)) italic= false; else { int status= italic_a_status (ga); //r << (string ("italic-a=") * as_string (status)); italic= (status == 0); } metric_struct* f= fnm->get (0x66); metric_struct* x= fnm->get (0x78); italic= italic && (f->y3 < -(x->y2/5)); if (italic) r << string ("italic=yes"); else r << string ("italic=no"); } if (range_exists (fnm, 0x41, 0x5a) && range_exists (fnm, 0x61, 0x7a)) { array<int> upr= build_range (0x41, 0x5a); array<int> lor= build_range (0x61, 0x7a); array<int> uph= decode_trace (height_trace (fnm, upr)); array<int> loh= decode_trace (height_trace (fnm, lor)); if (l1_distance (loh, uph) <= N(upr)) { metric_struct* A= fnm->get (0x41); metric_struct* a= fnm->get (0x61); int Ah= A->y4 - A->y3; int ah= a->y4 - a->y3; if (ah < ((95 * Ah) / 100)) r << string ("case=smallcaps"); else r << string ("case=caps"); } else r << string ("case=mixed"); } if (range_exists (fnm, 0x61, 0x7a)) { bool regular= (irregularity (fnm) <= 6); if (regular) r << string ("regular=yes"); else r << string ("regular=no"); } }
void analyze_major (font fn, font_metric fnm, array<string>& r) { if (range_exists (fnm, 0x41, 0x5a) && range_exists (fnm, 0x61, 0x7a)) { metric_struct* x= fnm->get (0x78); int ex= max (x->y2 / 256, 1); r << (string ("ex=") * as_string (ex)); metric_struct* M= fnm->get (0x4d); int em_rat= (100 * (M->x2 / 256)) / ex; r << (string ("em=") * as_string (em_rat)); glyph glo= fn->get_glyph ("o"); if (!is_nil (glo)) { int lvw= (100 * vertical_stroke_width (glo)) / ex; int lhw= (100 * horizontal_stroke_width (glo)) / ex; r << (string ("lvw=") * as_string (lvw)); r << (string ("lhw=") * as_string (lhw)); } glyph glO= fn->get_glyph ("O"); if (!is_nil (glO)) { int uvw= (100 * vertical_stroke_width (glO)) / ex; int uhw= (100 * horizontal_stroke_width (glO)) / ex; r << (string ("uvw=") * as_string (uvw)); r << (string ("uhw=") * as_string (uhw)); } int cnt= 0; int totlw= 0; double fill= 0.0; for (int i= 0x41; i<=0x7a; i++) if (i <= 0x5a || i >= 0x61) { string s; s << ((char) i); glyph g= fn->get_glyph (s); if (!is_nil (g)) { cnt += pixel_count (g); totlw += g->lwidth; fill += fill_rate (g); } } int fillp= (int) (100.0 * (fill / 52.0)); int vcnt= cnt / max (totlw, 1); r << (string ("fillp=") * as_string (fillp)); r << (string ("vcnt=") * as_string (vcnt)); int lo_lw= 0; int lo_pw= 0; for (int i= 0x61; i<=0x7a; i++) { metric_struct* c= fnm->get (i); lo_lw += (c->x2 / 256); string s; s << ((char) i); glyph g= fn->get_glyph (s); if (!is_nil (g)) lo_pw += g->width; } int lasprat= (100 * lo_lw) / (26 * ex); int pasprat= (100 * lo_pw) / (26 * ex); r << (string ("lasprat=") * as_string (lasprat)); r << (string ("pasprat=") * as_string (pasprat)); //int irreg= irregularity (fnm); //r << (string ("irreg=") * as_string (irreg)); int loasc= (100 * max_ascent (fnm, 0x61, 0x7a)) / ex; int lodes= (100 * (ex + max_descent (fnm, 0x61, 0x7a))) / ex; r << (string ("loasc=") * as_string (loasc)); r << (string ("lodes=") * as_string (lodes)); if (range_exists (fnm, 0x30, 0x39)) { int dides= (100 * (ex + max_descent (fnm, 0x30, 0x39))) / ex; r << (string ("dides=") * as_string (dides)); } } }
bool sub_gid_assigned(const char *owner) { return range_exists (&subordinate_gid_db, owner); }