How does a gyro compass indicate true heading?
The directional gyro (DG) does not know about heading. Its gyroscope will hold its position (e.g. the heading you set from the magnetic compass) in space. The plane is turning "around it", but DG is holding its position, so you can read the heading from the scale fixed to the airplane while the gyroscope holds its position in space. Only friction and other forces (acceleration forced upon the aircraft) force the gyroscope to wander from its position.
E.g. the gyro shows a magnetic heading if set using a magnetic compass and it shows a true heading if set using a GPS (or some map feature like a road with a heading visible on a map).