I removed it in 79fadc1fa5. Thanks for the hint.
Now the code is better, but looking at it again I've noticed something.
When Font.IsDefault is true, DCIndex will always be zero. This makes the line "if DCIndex <> 0 then exit;" useless at the nested SaveState.
A similar situation can be found at TCanvas.TextRect and TWin32ThemeServices.DrawText. Like function TCanvas.TextExtent, those two routines have nested SaveState and RestoreState procedures with the identical content. I think that after removing "if DCIndex <> 0 then exit;" from these three SaveState nested procedures, lcl developers should verify again to see if the code does what they expect it to do.
As a comparison, I've noticed the usage of TLazCanvas.SaveState in customdrawnproc.pas(RenderWinControl and DrawFormBackground) and also in cusomdrawnwinapi.inc(TCDWidgetSet.DrawFocusRect). No matter what, TLazCanvas.SaveState is always followed by a TLazCanvas.RestoreState. In the three routines that use the nested SaveState and RestoreState procedures, "RestoreDC(DC,DCIndex);" is called only if DCIndex<>0. This means that if the list of saved states was empty at the time of calling SaveDC in SaveState, InxedDC will be zero and the state won't be restored in RestoreState. LCL developers might want to check if that is what they really wanted.