The Medipix4 chip is the latest member of the family of Medipix pixel detector readout chips aimed at high rate spectroscopic X-ray imaging. Unlike its predecessors, it will be possible to tile the chip on all 4 sides permitting seamless large area coverage. This paper focuses on the development of the new Medipix4 front-end architecture capable of event-by-event data processing allowing accurate photon energy reconstruction, with charge sharing correction at an increased rate compared to Medipix3. The architecture is particularly well adapted for readout of pixelated high-Z detector materials allowing accurate energy binning of incoming hits at a fine pixel pitch. The new front-end architecture has a linear response up to 150 keV (CdTe), a count-rate capability up to 5.1x10(8) photons.mm(-2)s(-1) for 10% dead time loss at 10 keV (CdTe), and an energy resolution aiming for 2.2 keV FWHM (Full Width Half Maximum) at 60 keV (CdTe). The layout accommodates sensors with either 70 mu m or 140 mu m pitch of contacts.