code: public float getEffectiveStringWidth(String text, boolean kerned) {
          BaseFont bf = state.fontDetails.getBaseFont();
  
          float w;
          if (kerned)
              w = bf.getWidthPointKerned(text, state.size);
          else
              w = bf.getWidthPoint(text, state.size);
  
          if (state.charSpace != 0.0f && text.length() > 1) {
              w += state.charSpace * (text.length() -1);
          }
  
          int ft = bf.getFontType();
          if (state.wordSpace != 0.0f && (ft == BaseFont.FONT_TYPE_T1 || ft == BaseFont.FONT_TYPE_TT || ft == BaseFont.FONT_TYPE_T3)) {
              for (int i = 0; i < (text.length() -1); i++) {
                  if (text.charAt(i) == ' ')
                      w += state.wordSpace;
              }
          }
          if (state.scale != 100.0)
              w = (w * state.scale) / 100.0f;
  
          //System.out.println("String width = " + Float.toString(w));
          return w;
      }
docs: Computes the width of the given string taking in account
  the current values of "Character spacing", "Word Spacing"
  and "Horizontal Scaling".
  The additional spacing is not computed for the last character
  of the string.
  @param text the string to get width of
  @param kerned the kerning option
  @return the width