code: def _make_read_func(file_obj):
      
      @ffi.callback("cairo_read_func_t", error=constants.STATUS_READ_ERROR)
      def read_func(_closure, data, length):
          string = file_obj.read(length)
          if len(string) < length:  # EOF too early
              return constants.STATUS_READ_ERROR
          ffi.buffer(data, length)[:len(string)] = string
          return constants.STATUS_SUCCESS
      return read_func
docs: Return a CFFI callback that reads from a file-like object.