Yes, many, many times. It has always been ruled legal by the higher courts. Even for pre-trial detainees who never even go to trial and who have been falsely accused.
"A defendant in a criminal prosecution who is acquitted or discharged is not liable for any costs or fees of the court or any ministerial office, or for any charge of subsistence while detained in custody."
Edit: You can search scholar.google.com for "939.06" and find cases such as:
Starkes v. State, 292 So.3d 826 (2020) wherein the 1st DCA issued a writ of mandamus commanding the trial court to certify the defendant's costs (so that they may be reimbursed).
And in the rare cases when someone wins they court will do an 'as applied' ruling, meaning only for this specific case and unable to be used as precedent in any other cases.