code: def convertLength(self, svgAttr, percentOf=100, em_base=12):
          "Convert length to points."
  
          text = svgAttr
          if not text:
              return 0.0
          if ' ' in text.replace(',', ' ').strip():
              logger.debug("Only getting first value of %s" % text)
              text = text.replace(',', ' ').split()[0]
  
          if text.endswith('%'):
              logger.debug("Fiddling length unit: %")
              return float(text[:-1]) / 100 * percentOf
          elif text.endswith("pc"):
              return float(text[:-2]) * pica
          elif text.endswith("pt"):
              return float(text[:-2]) * 1.25
          elif text.endswith("em"):
              return float(text[:-2]) * em_base
          elif text.endswith("px"):
              return float(text[:-2])
  
          if "ex" in text:
              logger.warning("Ignoring unit ex")
              text = text.replace("ex", '')
  
          text = text.strip()
          length = toLength(text)  # this does the default measurements such as mm and cm
  
          return lengtf convertLength(self, svgAttr, percentOf=100, em_base=12):
          "Convert length to points."
  
          text = svgAttr
          if not text:
              return 0.0
          if ' ' in text.replace(',', ' ').strip():
              logger.debug("Only getting first value of %s" % text)
              text = text.replace(',', ' ').split()[0]
  
          if text.endswith('%'):
              logger.debug("Fiddling length unit: %")
              return float(text[:-1]) / 100 * percentOf
          elif text.endswith("pc"):
              return float(text[:-2]) * pica
          elif text.endswith("pt"):
              return float(text[:-2]) * 1.25
          elif text.endswith("em"):
              return float(text[:-2]) * em_base
          elif text.endswith("px"):
              return float(text[:-2])
  
          if "ex" in text:
              logger.warning("Ignoring unit ex")
              text = text.replace("ex", '')
  
          text = text.strip()
          length = toLength(text)  # this does the default measurements such as mm and cm
  
          return length
docs: Convert length to points.