Пример #1
0
 def format_section(self):
     lines = [
         u'Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding'
     ]
     lines.extend(u'Style: {0},{1}'.format(style.name, style.definition)
                  for style in itervalues(self.styles))
     return lines
Пример #2
0
    def append_styles(self, other_script, clean, resample, forced_resolution=None):
        if clean:
            self._styles.clear()

        if resample:
            other_script_resampled = copy.deepcopy(other_script)
            other_script_resampled.scale_to_reference(self, forced_resolution)
            if forced_resolution:
                self.scale_to_reference(self, forced_resolution)
        else:
            other_script_resampled = other_script
        for style in itervalues(other_script_resampled._styles):
            self._styles[style.name] = copy.deepcopy(style)
Пример #3
0
 def scale_to_reference(self, reference, forced_resolution=None):
     src_width, src_height = self._find_section(SCRIPT_INFO_SECTION).get_resolution()
     scale_border_and_shadow = self._find_section(SCRIPT_INFO_SECTION).get_scaled_border_property()
     if forced_resolution:
         dst_width, dst_height = forced_resolution
     else:
         dst_width, dst_height = reference._find_section(SCRIPT_INFO_SECTION).get_resolution()
     if all((src_width, src_height, dst_width, dst_height)):
         for style in itervalues(self._styles):
             style.resample(src_width, src_height, dst_width, dst_height, scale_border_and_shadow)
         self._find_section(SCRIPT_INFO_SECTION).set_resolution(dst_width, dst_height)
     else:
         logging.info("Couldn't determine resolution, resampling disabled")
Пример #4
0
    def append_styles(self,
                      other_script,
                      clean,
                      resample,
                      forced_resolution=None):
        if clean:
            self._styles.clear()

        if resample:
            other_script_resampled = copy.deepcopy(other_script)
            other_script_resampled.scale_to_reference(self, forced_resolution)
            if forced_resolution:
                self.scale_to_reference(self, forced_resolution)
        else:
            other_script_resampled = other_script
        for style in itervalues(other_script_resampled._styles):
            self._styles[style.name] = copy.deepcopy(style)
Пример #5
0
 def scale_to_reference(self, reference, forced_resolution=None):
     src_width, src_height = self._find_section(
         SCRIPT_INFO_SECTION).get_resolution()
     scale_border_and_shadow = self._find_section(
         SCRIPT_INFO_SECTION).get_scaled_border_property()
     if forced_resolution:
         dst_width, dst_height = forced_resolution
     else:
         dst_width, dst_height = reference._find_section(
             SCRIPT_INFO_SECTION).get_resolution()
     if all((src_width, src_height, dst_width, dst_height)):
         for style in itervalues(self._styles):
             style.resample(src_width, src_height, dst_width, dst_height,
                            scale_border_and_shadow)
         self._find_section(SCRIPT_INFO_SECTION).set_resolution(
             dst_width, dst_height)
     else:
         logging.info("Couldn't determine resolution, resampling disabled")
Пример #6
0
 def format_section(self):
     return [x.to_string() for x in itervalues(self._lines_dict)]
Пример #7
0
 def format_section(self):
     lines = [u'Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding']
     lines.extend(u'Style: {0},{1}'.format(style.name, style.definition) for style in itervalues(self.styles))
     return lines
Пример #8
0
 def format_section(self):
     return [x.to_string() for x in itervalues(self._lines_dict)]