Exemplo n.º 1
0
    def __init__(self, target, test, incremental, emit_config, ignored_cp,
                 only_cp, enabled_tests):
        self.target = target
        self.test = test
        self.incremental = incremental  # target is different version of same file
        self.emit_config = emit_config  # generate config lines
        self.enabled_tests = enabled_tests or FontCompare.test_names

        self.target_cmap = font_data.get_cmap(target)
        self.test_cmap = font_data.get_cmap(test)

        target_chars = set(self.target_cmap.keys()) - _get_excluded_chars()
        if ignored_cp:
            target_chars -= ignored_cp
        if only_cp:
            target_chars &= only_cp
        self.target_chars = target_chars

        # Assume version has two decimal places, which MTI fonts do but Adobe's do not.
        target_version = font_data.printable_font_revision(target)
        test_version = font_data.printable_font_revision(test)

        target_names = font_data.get_name_records(target)
        test_names = font_data.get_name_records(test)
        self._log('target name: %s %s, version: %s' %
                  (target_names[1], target_names[2], target_version))
        self._log('test name: %s %s, version %s' %
                  (test_names[1], test_names[2], test_version))

        if emit_config:
            font_family = test_names[1]
            font_subfamily = test_names[2].replace(' ', '')
            self._config('name like %s; weight like %s; version == %s' %
                         (font_family, font_subfamily, test_version))
Exemplo n.º 2
0
  def __init__(self, target, test, incremental, emit_config, ignored_cp, only_cp,
               enabled_tests):
    self.target = target
    self.test = test
    self.incremental = incremental # target is different version of same file
    self.emit_config = emit_config # generate config lines
    self.enabled_tests = enabled_tests or FontCompare.test_names

    self.target_cmap = font_data.get_cmap(target)
    self.test_cmap = font_data.get_cmap(test)

    target_chars = set(self.target_cmap.keys()) - _get_excluded_chars()
    if ignored_cp:
      target_chars -= ignored_cp
    if only_cp:
      target_chars &= only_cp
    self.target_chars = target_chars

    # Assume version has two decimal places, which MTI fonts do but Adobe's do not.
    target_version = font_data.printable_font_revision(target)
    test_version = font_data.printable_font_revision(test)

    target_names = font_data.get_name_records(target)
    test_names = font_data.get_name_records(test)
    self._log('target name: %s %s, version: %s' % (target_names[1], target_names[2], target_version))
    self._log('test name: %s %s, version %s' % (test_names[1], test_names[2], test_version))

    if emit_config:
      font_family = test_names[1]
      font_subfamily = test_names[2].replace(' ', '')
      self._config('name like %s; weight like %s; version == %s' %
                   (font_family, font_subfamily, test_version))
Exemplo n.º 3
0
def fix_revision(font):
    """Fix the revision of the font to match its version."""
    version = font_data.font_version(font)
    match = re.match(r'Version (\d{1,5})\.(\d{1,5})', version)
    major_version = match.group(1)
    minor_version = match.group(2)

    accuracy = len(minor_version)
    font_revision = font_data.printable_font_revision(font, accuracy)
    expected_font_revision = major_version+'.'+minor_version
    if font_revision != expected_font_revision:
        font['head'].fontRevision = float(expected_font_revision)
        print 'Fixed fontRevision to %s' % expected_font_revision
        return True

    return False
def fix_revision(font):
    """Fix the revision of the font to match its version."""
    version = font_data.font_version(font)
    match = re.match(r'Version (\d{1,5})\.(\d{1,5})', version)
    major_version = match.group(1)
    minor_version = match.group(2)

    accuracy = len(minor_version)
    font_revision = font_data.printable_font_revision(font, accuracy)
    expected_font_revision = major_version + '.' + minor_version
    if font_revision != expected_font_revision:
        font['head'].fontRevision = float(expected_font_revision)
        print 'Fixed fontRevision to %s' % expected_font_revision
        return True

    return False