In criminal court? I can't think of any jurisdiction that charges a fee for pleading not guilty, going to trial, and being convicted.
In civil court outside the US, the loser pays attorney's fees. I don't know about court fees, since those are usually relatively tiny compared to attorney's fees.
In the above case, I had to pay a $25 "court fee", even though the case against me was dismissed.