- bool const font_changed =
- font != i.font() ||
- italic != i.italic() ||
- bold != i.bold() ||
- underline != i.underline() ||
- colour != i.colour() ||
- size != i.size() ||
- fabs (aspect_adjust - i.aspect_adjust()) > ASPECT_ADJUST_EPSILON ||
- effect != i.effect() ||
- effect_colour != i.effect_colour();
-
- if (font_changed) {
- font = i.font ();
- italic = i.italic ();
- bold = i.bold ();
- underline = i.underline ();
- colour = i.colour ();
- size = i.size ();
- aspect_adjust = i.aspect_adjust ();
- effect = i.effect ();
- effect_colour = i.effect_colour ();
- }
-
- if (!font_element || font_changed) {
- font_element = root->add_child ("Font", xmlns);
- if (font) {
- if (standard == SMPTE) {
- font_element->set_attribute ("ID", font.get ());
- } else {
- font_element->set_attribute ("Id", font.get ());
- }
- }
- font_element->set_attribute ("Italic", italic ? "yes" : "no");
- font_element->set_attribute ("Color", colour.to_argb_string());
- font_element->set_attribute ("Size", raw_convert<string> (size));
- if (fabs (aspect_adjust - 1.0) > ASPECT_ADJUST_EPSILON) {
- font_element->set_attribute ("AspectAdjust", raw_convert<string> (aspect_adjust));
- }
- font_element->set_attribute ("Effect", effect_to_string (effect));
- font_element->set_attribute ("EffectColor", effect_colour.to_argb_string());
- font_element->set_attribute ("Script", "normal");
- if (standard == SMPTE) {
- font_element->set_attribute ("Underline", underline ? "yes" : "no");
- } else {
- font_element->set_attribute ("Underlined", underline ? "yes" : "no");
- }
- font_element->set_attribute ("Weight", bold ? "bold" : "normal");
- }
-
- if (!subtitle_element || font_changed ||
- (last_in != i.in() ||
- last_out != i.out() ||
- last_fade_up_time != i.fade_up_time() ||
- last_fade_down_time != i.fade_down_time()
- )) {
-
- subtitle_element = font_element->add_child ("Subtitle", xmlns);
- subtitle_element->set_attribute ("SpotNumber", raw_convert<string> (spot_number++));
- subtitle_element->set_attribute ("TimeIn", i.in().rebase(time_code_rate).as_string(standard));
- subtitle_element->set_attribute ("TimeOut", i.out().rebase(time_code_rate).as_string(standard));
- if (standard == SMPTE) {
- subtitle_element->set_attribute ("FadeUpTime", i.fade_up_time().rebase(time_code_rate).as_string(standard));
- subtitle_element->set_attribute ("FadeDownTime", i.fade_down_time().rebase(time_code_rate).as_string(standard));
- } else {
- subtitle_element->set_attribute ("FadeUpTime", raw_convert<string> (i.fade_up_time().as_editable_units(time_code_rate)));
- subtitle_element->set_attribute ("FadeDownTime", raw_convert<string> (i.fade_down_time().as_editable_units(time_code_rate)));
- }
-
- last_in = i.in ();
- last_out = i.out ();
- last_fade_up_time = i.fade_up_time ();
- last_fade_down_time = i.fade_down_time ();