It's actually even more complicated than that. Modern printers include a raster image processor (RIP) [1]. This specialized software converts vector graphics, text, and pixel-based images into a raster dot pattern that controls the print head. The individual dots that get printed can't be varied in size or brightness, so the variations in image tone are controlled by the density of the dots in the raster pattern. This is called halftone [2].
[1] https://en.wikipedia.org/wiki/Raster_image_processor
[2] https://en.wikipedia.org/wiki/Halftone