calculate the string width in pixel