Increase/Decrease Font Size with distance

I have a script that manages all enemies that are in the world basically i need some function that be able to increase or decrease font size when the player is near or farest from they.
here is what im trying to make:

float distance = Vector3.Distance(camera.transform.position, enemy.transform.position);  

_text.fontSize = // Do something with distance so the size can increase if near or decrease if farest, basically inversely proportional

,What type of text object are you using? Asuming you can get the font size varibale from the text object why can’t you just do something like this:

_text.fontSize = distance;

and with some aditional typecasting / conversion if necessary

what CodesCove is suggesting is probably the path you want.
project your 3D entity positions into the 2D UI layer, and render fonts in UI.