Example #1
0
 def test_render(self):
     self.assertTrue(
         check_render_size("sans", get_font_weight("normal"), 12, 0, "ahoj", 100, 1)
     )
     self.assertFalse(
         check_render_size("sans", get_font_weight("normal"), 12, 0, "ahoj", 10, 1)
     )
Example #2
0
 def check_target_params(self, sources, targets, unit, value):
     if isinstance(value, tuple):
         width, lines = value
     else:
         width = value
         lines = 1
     font_group, weight, size, spacing = self.get_params(unit)
     font = self.last_font = self.load_font(
         unit.translation.component.project, unit.translation.language, font_group
     )
     return any(
         (
             not check_render_size(
                 font,
                 weight,
                 size,
                 spacing,
                 target,
                 width,
                 lines,
                 "check:render:{}:{}".format(unit.pk, i),
             )
             for i, target in enumerate(targets)
         )
     )
Example #3
0
 def check_target_params(self, sources, targets, unit, value):
     if len(value) == 2:
         width, lines = value
     else:
         width = value[0]
         lines = 1
     font_group, weight, size, spacing = self.get_params(unit)
     font = self.last_font = self.load_font(
         unit.translation.component.project, unit.translation.language, font_group
     )
     replace = self.get_replacement_function(unit)
     return any(
         (
             not check_render_size(
                 font,
                 weight,
                 size,
                 spacing,
                 replace(target),
                 width,
                 lines,
                 self.get_cache_key(unit, i),
             )
             for i, target in enumerate(targets)
         )
     )