+ for (auto const & opt : allopts) {
+ if (opt == "osf") {
+ h_font_roman_osf = "true";
+ continue;
+ }
+ if (!xopts.empty())
+ xopts += ", ";
+ xopts += opt;
+ }
+ if (!xopts.empty())
+ h_font_roman_opts = xopts;
+ options.clear();
+ }
+
+ if (name == "plex-serif") {
+ h_font_roman[0] = "IBMPlexSerif";
+ for (auto const & opt : allopts) {
+ if (opt == "thin") {
+ h_font_roman[0] = "IBMPlexSerifThin";
+ continue;
+ }
+ if (opt == "extralight") {
+ h_font_roman[0] = "IBMPlexSerifExtraLight";
+ continue;
+ }
+ if (opt == "light") {
+ h_font_roman[0] = "IBMPlexSerifLight";
+ continue;
+ }
+ if (!xopts.empty())
+ xopts += ", ";
+ xopts += opt;
+ }
+ if (!xopts.empty())
+ h_font_roman_opts = xopts;
+ options.clear();
+ }
+
+ if (name == "noto-serif" || name == "noto") {
+ bool rm = false;
+ bool rmx = false;
+ bool sf = false;
+ bool sfx = false;
+ bool tt = false;
+ bool thin = false;
+ bool extralight = false;
+ bool light = false;
+ bool medium = false;
+ bool osf = false;
+ string scl;
+ if (name == "noto") {
+ rm = true;
+ sf = true;
+ tt = true;
+ }
+ // Since the options might apply to different shapes,
+ // we need to parse all options first and then handle them.
+ for (auto const & opt : allopts) {
+ if (opt == "regular")
+ // skip
+ continue;
+ if (opt == "rm") {
+ rm = true;
+ rmx = true;
+ sf = sfx;
+ tt = false;
+ continue;
+ }
+ if (opt == "thin") {
+ thin = true;
+ continue;
+ }
+ if (opt == "extralight") {
+ extralight = true;
+ continue;
+ }
+ if (opt == "light") {
+ light = true;
+ continue;
+ }
+ if (opt == "medium") {
+ medium = true;
+ continue;
+ }
+ if (opt == "sf") {
+ sfx = true;
+ sf = true;
+ rm = rmx;
+ tt = false;
+ continue;
+ }
+ if (opt == "nott") {
+ tt = false;
+ continue;
+ }
+ if (opt == "osf") {
+ osf = true;
+ continue;
+ }
+ if (prefixIs(opt, "scaled=")) {
+ scl = opt;
+ continue;
+ }
+ if (!xopts.empty())
+ xopts += ", ";
+ xopts += opt;
+ }
+ options.clear();
+ // handle options that might affect different shapes
+ if (name == "noto-serif" || rm) {
+ if (thin)
+ h_font_roman[0] = "NotoSerifThin";
+ else if (extralight)
+ h_font_roman[0] = "NotoSerifExtralight";
+ else if (light)
+ h_font_roman[0] = "NotoSerifLight";
+ else if (medium)
+ h_font_roman[0] = "NotoSerifMedium";
+ else
+ h_font_roman[0] = "NotoSerifRegular";
+ if (osf)
+ h_font_roman_osf = "true";
+ if (!xopts.empty())
+ h_font_roman_opts = xopts;
+ }
+ if (name == "noto" && sf) {
+ if (thin)
+ h_font_sans[0] = "NotoSansThin";
+ else if (extralight)
+ h_font_sans[0] = "NotoSansExtralight";
+ else if (light)
+ h_font_sans[0] = "NotoSansLight";
+ else if (medium)
+ h_font_sans[0] = "NotoSansMedium";
+ else
+ h_font_sans[0] = "NotoSansRegular";
+ if (osf)
+ h_font_sans_osf = "true";
+ if (!scl.empty())
+ scale_as_percentage(scl, h_font_sf_scale[0]);
+ if (!xopts.empty())
+ h_font_sans_opts = xopts;
+ }
+ if (name == "noto" && tt) {
+ h_font_typewriter[0] = "NotoMonoRegular";
+ if (osf)
+ h_font_typewriter_osf = "true";
+ if (!scl.empty())
+ scale_as_percentage(scl, h_font_tt_scale[0]);
+ if (!xopts.empty())
+ h_font_typewriter_opts = xopts;
+ }