float (float x, float plainSpaceWidth, int tabSize) { if (tabSize <= 0) { return x + plainSpaceWidth; } float tabSizePixels = tabSize * plainSpaceWidth; int nTabs = (int)((x + plainSpaceWidth / 2) / tabSizePixels); return (nTabs + 1) * tabSizePixels; }