Using a classical linear stabilizer circuit won't help you. The 7805 voltage regulator dissipates a lot heat. Try to use a DC-DC step-down convertor instead.
See for example LM2575, LM2576, LM2596, LM2678, LM2679.
Some details here
**broken link removed**
But what about efficiency of the circuit?
If You need 5V at 0.3A this is 1.5W and the circuit need to dissipate the extra 19V at 0.3A , for a total of 5.7W. :roll:
Lot of heat to produce = big heat sinking is required.
It’s so simple to use a step down converter. See as example in the link attached…