Find appropriate font size when monitor DPI changes

 

Hi developers

If I set a button/label height and width according to screen DPI like below

double screen_dpi = (double)TerminalInfoInteger(TERMINAL_SCREEN_DPI);
m_DPIScale = screen_dpi / 96.0;
height = (int)MathRound(170 * m_DPIScale);

then how can I find appropriate font size for that button/label (font size that fits the object)?

And when I switch from a 96-dpi monitor to a 200dpi monitor then the font become smaller while the object remains the same size, so I need a new font size again to look the same 96-dpi monitor. How should I handle font size?

 

edition: I meant Button or Edit (not Labels)

additionally for Labels, is there a way to keep them same size in different monitors because with dpi method our background RectangleLabel (dashboard) remain same size.