Every font has different widths for characters. You can't do this mathematically. You can adjust the font size in the Character Panel or adjust the scale of the text layer until it fits. Holding down the shift key while dragging the corners of a layer will maintain the proper aspect ratio.
okok, got it, and what about other layers? they can be adjusted with math?
It can't be done easily.
You have to take horizontal & vertical resolution, pixel aspect ratio and scal all into account. With the exception of video, the pixel aspect ratio is typically 1.0... but not always.