code: def test_Type1Font():
      filename = os.path.join(os.path.dirname(__file__), "cmr10.pfb")
      font = t1f.Type1Font(filename)
      slanted = font.transform({"slant": 1})
      condensed = font.transform({"extend": 0.5})
      with open(filename, "rb") as fd:
          rawdata = fd.read()
      assert font.parts[0] == rawdata[0x0006:0x10C5]
      assert font.parts[1] == rawdata[0x10CB:0x897F]
      assert font.parts[2] == rawdata[0x8985:0x8BA6]
      assert font.decrypted.startswith(
          b"dup\n/Private 18 dict dup begin"
      )
      assert font.decrypted.endswith(b"mark currentfile closefile\n")
      assert slanted.decrypted.startswith(
          b"dup\n/Private 18 dict dup begin"
      )
      assert slanted.decrypted.endswith(b"mark currentfile closefile\n")
      assert b"UniqueID 5000793" in font.parts[0]
      assert b"UniqueID 5000793" in font.decrypted
      assert font._pos["UniqueID"] == [(797, 818), (4483, 4504)]
  
      len0 = len(font.parts[0])
      for key in font._pos.keys():
          for pos0, pos1 in font._pos[key]:
              if pos0 < len0:
                  data = font.parts[0][pos0:pos1]
              else:
                  data = font.decrypted[pos0 - len0 : pos1 - len0]
              assert data.startswith(f"/{key}".encode("ascii"))
      assert {
          "FontType",
          "FontMatrix",
          "PaintType",
          "ItalicAngle",
          "RD",
      } < set(font._pos.keys())
  
      assert b"UniqueID 5000793" not in slanted.parts[0]
      assert b"UniqueID 5000793" not in slanted.decrypted
      assert "UniqueID" not in slanted._pos
      assert font.prop["Weight"] == "Medium"
      assert not font.prop["isFixedPitch"]
      assert font.prop["ItalicAngle"] == 0
      assert slanted.prop["ItalicAngle"] == -45
      assert font.prop["Encoding"][5] == "Pi"
      assert isinstance(font.prop["CharStrings"]["Pi"], bytes)
      assert font._abbr["ND"] == "ND"
  
      differ = difflib.Differ()
      diff = list(
          differ.compare(
              font.parts[0].decode("latin-1").splitlines(),
              slanted.parts[0].decode("latin-1").splitlines(),
          )
      )
      for line in (
          # Removes UniqueID
          "- /UniqueID 5000793 def",
          # Changes the font name
          "- /FontName /CMR10 def",
          "+ /FontName/CMR10_Slant_1000 def",
          # Alters FontMatrix
          "- /FontMatrix [0.001 0 0 0.001 0 0 ]readonly def",
          "+ /FontMatrix [0.001 0 0.001 0.001 0 0] readonly def",
          # Alters ItalicAngle
          "-  /ItalicAngle 0 def",
          "+  /ItalicAngle -45.0 def",
      ):
          assert line in diff, (
              "diff to slanted font must contain %s" % line
          )
  
      diff = list(
          differ.compare(
              font.parts[0].decode("latin-1").splitlines(),
              condensed.parts[0].decode("latin-1").splitlines(),
          )
      )
      for line in (
          # Removes UniqueID
          "- /UniqueID 5000793 def",
          # Changes the font name
          "- /FontName /CMR10 def",
          "+ /FontName/CMR10_Extend_500 def",
          # Alters FontMatrix
          "- /FontMatrix [0.001 0 0 0.001 0 0 ]readonly def",
          "+ /FontMatrix [0.0005 0 0 0.001 0 0] readonly def",
      ):
          assert line in diff, (
              "diff to condensed font must contain %s" % line
          )
  
file_path: matplotlib/lib/matplotlib/tests/test_type1font.py
imports: import matplotlib._type1font
  import os.path
  import difflib
  import pytest
label_desc: Use image node_id 1 for calling a global function with example usage: test_Type1Font() without return types