Example #1
0
def test_check_family_win_ascent_and_descent(mada_ttFonts):
    """ Checking OS/2 usWinAscent & usWinDescent. """
    from fontbakery.profiles.universal import com_google_fonts_check_family_win_ascent_and_descent as check
    from fontbakery.profiles.shared_conditions import vmetrics

    # Our reference Mada Regular is know to be bad here.
    vm = vmetrics(mada_ttFonts)
    ttFont = TTFont(TEST_FILE("mada/Mada-Regular.ttf"))

    # But we fix it first to test the PASS code-path:
    print('Test PASS with a good font...')
    ttFont['OS/2'].usWinAscent = vm['ymax']
    ttFont['OS/2'].usWinDescent = abs(vm['ymin'])
    status, message = list(check(ttFont, vm))[-1]
    assert status == PASS

    # Then we break it:
    print('Test FAIL with a bad OS/2.usWinAscent...')
    ttFont['OS/2'].usWinAscent = vm['ymax'] - 1
    ttFont['OS/2'].usWinDescent = abs(vm['ymin'])
    status, message = list(check(ttFont, vm))[-1]
    assert status == FAIL and message.code == "ascent"

    print('Test FAIL with a bad OS/2.usWinDescent...')
    ttFont['OS/2'].usWinAscent = vm['ymax']
    ttFont['OS/2'].usWinDescent = abs(vm['ymin']) - 1
    status, message = list(check(ttFont, vm))[-1]
    assert status == FAIL and message.code == "descent"
Example #2
0
def test_check_family_win_ascent_and_descent(mada_ttFonts):
    """ Checking OS/2 usWinAscent & usWinDescent. """
    check = CheckTester(
        universal_profile,
        "com.google.fonts/check/family/win_ascent_and_descent")
    from fontbakery.profiles.shared_conditions import vmetrics

    # Our reference Mada Regular is know to be bad here.
    ttFont = TTFont(TEST_FILE("mada/Mada-Regular.ttf"))

    # But we fix it first to test the PASS code-path:
    vm = vmetrics(mada_ttFonts)
    ttFont['OS/2'].usWinAscent = vm['ymax']
    ttFont['OS/2'].usWinDescent = abs(vm['ymin'])
    assert_PASS(check(ttFont), 'with a good font...')

    # Then we break it:
    ttFont[
        'OS/2'].usWinAscent = 0  # FIXME: this should be bad as well: vm['ymax'] - 1
    ttFont['OS/2'].usWinDescent = abs(vm['ymin'])
    assert_results_contain(check(ttFont), FAIL, 'ascent',
                           'with a bad OS/2.usWinAscent...')

    # and also this other way of breaking it:
    ttFont['OS/2'].usWinAscent = vm['ymax']
    ttFont[
        'OS/2'].usWinDescent = 0  # FIXME: this should be bad as well: abs(vm['ymin']) - 1
    assert_results_contain(check(ttFont), FAIL, 'descent',
                           'with a bad OS/2.usWinDescent...')
Example #3
0
def test_check_family_win_ascent_and_descent(mada_ttFonts):
  """ Checking OS/2 usWinAscent & usWinDescent. """
  from fontbakery.profiles.universal import com_google_fonts_check_family_win_ascent_and_descent as check
  from fontbakery.profiles.shared_conditions import vmetrics

  # Our reference Mada Regular is know to be bad here.
  vm = vmetrics(mada_ttFonts)
  ttFont = TTFont(TEST_FILE("mada/Mada-Regular.ttf"))

  # But we fix it first to test the PASS code-path:
  print('Test PASS with a good font...')
  ttFont['OS/2'].usWinAscent = vm['ymax']
  ttFont['OS/2'].usWinDescent = abs(vm['ymin'])
  status, message = list(check(ttFont, vm))[-1]
  assert status == PASS

  # Then we break it:
  print('Test FAIL with a bad OS/2.usWinAscent...')
  ttFont['OS/2'].usWinAscent = vm['ymax'] - 1
  ttFont['OS/2'].usWinDescent = abs(vm['ymin'])
  status, message = list(check(ttFont, vm))[-1]
  assert status == FAIL and message.code == "ascent"

  print('Test FAIL with a bad OS/2.usWinDescent...')
  ttFont['OS/2'].usWinAscent = vm['ymax']
  ttFont['OS/2'].usWinDescent = abs(vm['ymin']) - 1
  status, message = list(check(ttFont, vm))[-1]
  assert status == FAIL and message.code == "descent"
Example #4
0
def test_check_family_win_ascent_and_descent(mada_ttFonts):
    """ Checking OS/2 usWinAscent & usWinDescent. """
    from fontbakery.profiles.universal import com_google_fonts_check_family_win_ascent_and_descent as check
    from fontbakery.profiles.shared_conditions import vmetrics

    # Our reference Mada Regular is know to be bad here.
    vm = vmetrics(mada_ttFonts)
    ttFont = TTFont(TEST_FILE("mada/Mada-Regular.ttf"))

    # But we fix it first to test the PASS code-path:
    ttFont['OS/2'].usWinAscent = vm['ymax']
    ttFont['OS/2'].usWinDescent = abs(vm['ymin'])
    assert_PASS(check(ttFont, vm), 'with a good font...')

    # Then we break it:
    ttFont['OS/2'].usWinAscent = vm['ymax'] - 1
    ttFont['OS/2'].usWinDescent = abs(vm['ymin'])
    assert_results_contain(check(ttFont, vm), FAIL, 'ascent',
                           'with a bad OS/2.usWinAscent...')

    ttFont['OS/2'].usWinAscent = vm['ymax']
    ttFont['OS/2'].usWinDescent = abs(vm['ymin']) - 1
    assert_results_contain(check(ttFont, vm), FAIL, 'descent',
                           'with a bad OS/2.usWinDescent...')