Package org.eclipse.draw2d

# Class TextUtilities

java.lang.Object
org.eclipse.draw2d.TextUtilities

public class TextUtilities extends Object
Provides miscellaneous text operations. Clients may subclass this class if necessary.

Since:
  3.4

## Field Summary

Fields
Modifier and Type
Field
Description
`static TextUtilities`
`INSTANCE`
a singleton default instance

## Constructor Summary

Constructors
Constructor
Description
`TextUtilities()`

## Method Summary

Modifier and Type
Method
Description
`int`
`getAscent(Font font)`
Gets the font's ascent.
`int`
`getDescent(Font font)`
Gets the font's descent.
`int`
`getLargestSubstringConfinedTo(String s, Font f, int availableWidth)`
Returns the largest substring of s in Font f that can be confined to the number of pixels in availableWidth.
`Dimension`
`getStringExtents(String s, Font f)`
Returns the Dimensions of s in Font f.
`Dimension`
`getTextExtents(String s, Font f)`
Returns the Dimensions of the given text, converting newlines and tabs appropriately.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### INSTANCE

public static TextUtilities INSTANCE
a singleton default instance

## Constructor Details

### TextUtilities

public TextUtilities()

## Method Details

### getStringExtents

public Dimension getStringExtents(String s, Font f)
Returns the Dimensions of s in Font f.

Parameters:
  `s` - the string
  `f` - the font
Returns:
  the dimensions of the given string

### getTextExtents

public Dimension getTextExtents(String s, Font f)
Returns the Dimensions of the given text, converting newlines and tabs appropriately.

Parameters:
  `s` - the text
  `f` - the font
Returns:
  the dimensions of the given text

### getAscent

public int getAscent(Font font)
Gets the font's ascent.

Parameters:
  `font` -
Returns:
  the font's ascent

### getDescent

public int getDescent(Font font)
Gets the font's descent.

Parameters:
  `font` -
Returns:
  the font's descent

### getLargestSubstringConfinedTo

public int getLargestSubstringConfinedTo(String s, Font f, int availableWidth)
Returns the largest substring of s in Font f that can be confined to the number of pixels in availableWidth.

Parameters:
  `s` - the original string
  `f` - the font
  `availableWidth` - the available width
Returns:
  the largest substring that fits in the given width