char* create_xlfd(font_family* family, font_style* style, uint32 flag) { char buf[100]; sprintf(buf, "-TTFont-%s-%s-%c-normal--0-0-0-0-%c-0-%s", *family, get_weight(style), get_slant(style), get_spacing(flag), get_encoding(family)); char* xlfd = (char*) calloc(strlen(buf) + 1, sizeof(char)); strcpy(xlfd, buf); return xlfd; }
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"); } }