metrics.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. reqMetricNames = [ "unitsPerEm"
  2. , "lowestRecPPEM"
  3. , "width"
  4. , "height"
  5. , "xMin"
  6. , "xMax"
  7. , "yMin"
  8. , "yMax"
  9. , "horiAscent"
  10. , "horiDescent"
  11. , "vertAscent"
  12. , "vertDescent"
  13. , "spaceHLength"
  14. , "spaceVLength"
  15. , "normalWidth"
  16. , "normalLSB"
  17. , "normalHeight"
  18. , "normalTSB"
  19. , "OS2ySubscriptXSize"
  20. , "OS2ySubscriptYSize"
  21. , "OS2ySubscriptXOffset"
  22. , "OS2ySubscriptYOffset"
  23. , "OS2ySuperscriptXSize"
  24. , "OS2ySuperscriptYSize"
  25. , "OS2ySuperscriptXOffset"
  26. , "OS2ySuperscriptYOffset"
  27. , "OS2yStrikeoutSize"
  28. , "OS2yStrikeoutPosition"
  29. ]
  30. def checkTransformMetrics(metrics):
  31. # METRICS
  32. # --------------------------------------------------
  33. # --------------------------------------------------
  34. # --------------------------------------------------
  35. # make sure there are no excess unchecked values.
  36. if not len(metrics) == len(reqMetricNames):
  37. raise ValueError(f"You have more values than the required values than your metrics. {checkDocMsg}")
  38. # check for appropriate names.
  39. for reqName in reqMetricNames:
  40. if not reqName in metrics:
  41. raise ValueError(f"metric.{reqName} is missing from your manifest. {checkDocMsg}")
  42. # make sure all the values are ints.
  43. for name, value in metrics.items():
  44. if type(value) is not int:
  45. raise ValueError(f"metric.{name} is not an int (it's '{value}'). All of your metrics need to be formatted as ints.")