# class KFontChooser

###

Module | kdeui
Namespace |
Class | KFontChooser
Inherits | QWidget

A font selection widget.

While KFontChooser as an ordinary widget can be embedded in custom dialogs and therefore is very flexible, in most cases it is preferable to use the convenience functions in KFontDialog.

See also KFontRequester

Author Preston Brown <pbrown@kde.org>, Bernd Wuebben <wuebben@kde.org>

### enums

- DisplayFlag { NoDisplayFlags, FixedFontsOnly, DisplayFrame, ShowDifferences }
  typesafe object: DisplayFlags
- FontColumn { FamilyList, StyleList, SizeList }
- FontDiff { NoFontDiffFlags, FontDiffFamily, FontDiffStyle, FontDiffSize, AllFontDiffs }
  typesafe object: FontDiffFlags
- FontListCriteria { FixedWidthFonts, ScalableFonts, SmoothScalableFonts }

enum details

### methods

- KFontChooser (parent, flags, fontList, visibleListSize, sizeIsRelativeState)

  returns ctor
  KDE 4.1.0 and later only

  Argument | Type | Default
  --- | --- | ---
  parent | QWidget | 0
  flags | KFontChooser.DisplayFlags | KFontChooser.DisplayFrame
  fontList | QStringList | QStringList()
  visibleListSize | int | 8
  sizeIsRelativeState | Qt.CheckState | 0

  Constructs a font picker widget. It normally comes up with all font families present on the system; the getFont method below does allow some more fine-tuning of the selection of fonts that will be displayed in the dialog.

  Consider the following code snippet;

      QStringList list;
      KFontChooser.getFontList(list, KFontChooser.SmoothScalableFonts);
      KFontChooser *chooseFont = new KFontChooser(0, false, list);

  The above creates a font chooser dialog with only SmoothScaleble fonts.

  parent - The parent widget.

  flags - Defines how the font chooser is displayed.

  See also DisplayFlags

  fontList - A list of fonts to display, in XLFD format. If no list is formatted, the internal KDE font list is used. If that has not been created, X is queried, and all fonts available on the system are displayed.

  visibleListSize - The minimum number of visible entries in the fontlists.

  sizeIsRelativeState - If not zero the widget will show a checkbox where the user may choose whether the font size is to be interpreted as relative size. Initial state of this checkbox will be set according to *sizeIsRelativeState, user choice may be retrieved by calling sizeIsRelative().

- KFontChooser (a0)

  returns ctor
  Not implemented

  Argument | Type | Default
  --- | --- | ---
  a0 | KFontChooser |

- KFontChooser (a0, a1, a2, a3, a4)

  returns ctor
  before KDE 4.1.0 only

  Argument | Type | Default
  --- | --- | ---
  a0 | QWidget | 0
  a1 | KFontChooser.DisplayFlags | KFontChooser.DisplayFrame
  a2 | QStringList | QStringList()
  a3 | int | 8
  a4 | Qt.CheckState | Qt.Unchecked

- backgroundColor ( )

  returns QColor

  Returns The background color currently used in the preview (default: the base color of the active colorgroup)

- color ( )

  returns QColor

  Returns The color currently used in the preview (default: the text color of the active color group)

- enableColumn (column, state)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  column | int |
  state | bool |

  Enables or disable a font column in the chooser.

  Use this function if your application does not need or supports all font properties.

  column - Specify the columns. An or'ed combination of FamilyList, StyleList and SizeList is possible.

  state - If false the columns are disabled.

- font ( )

  returns QFont

  Returns The currently selected font in the chooser.

- fontDiffFlags ( )

  returns KFontChooser.FontDiffFlags

  Returns The bitmask corresponding to the attributes the user wishes to change.

- fontSelected (font)

  returns Nothing
  SIGNAL ("fontSelected (const QFont&)")

  Argument | Type | Default
  --- | --- | ---
  font | QFont |

  Emitted whenever the selected font changes.

- getFontList (list, fontListCriteria)

  returns Nothing
  static

  Argument | Type | Default
  --- | --- | ---
  list | QStringList |
  fontListCriteria | uint |

  Creates a list of font strings.

  list - The list is returned here.

  fontListCriteria - should contain all the restrictions for font selection as OR-ed values

  See also KFontChooser.FontListCriteria for the individual values

- sampleText ( )

  returns QString

  Returns The current text in the sample text input area.

- setBackgroundColor (col)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  col | QColor |

  Sets the background color to use in the preview.

- setColor (col)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  col | QColor |

  Sets the color to use in the preview.

- setFont (font, onlyFixed)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  font | QFont |
  onlyFixed | bool | 0

  Sets the currently selected font in the chooser.

  font - The font to select.

  onlyFixed - Readjust the font list to display only fixed width fonts if true, or vice-versa.

- setSampleBoxVisible (visible)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  visible | bool |

  Shows or hides the sample text box.

  visible - Set it to true to show the box, to false to hide it.

- setSampleText (text)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  text | QString |

  Sets the sample text.

  Normally you should not change this text, but it can be better to do this if the default text is too large for the edit area when using the default font of your application.

  text - The new sample text. The current will be removed.

- setSizeIsRelative (relative)

  returns Nothing

  Argument | Type | Default
  --- | --- | ---
  relative | Qt.CheckState |

  Sets the state of the checkbox indicating whether the font size is to be interpreted as relative size. NOTE: If parameter sizeIsRelative was not set in the constructor of the widget this setting will be ignored.

- sizeHint ( )

  returns QSize

  Reimplemented for internal reasons.

- sizeIsRelative ( )

  returns Qt.CheckState

  Returns Whether the font size is to be interpreted as relative size (default: QButton:Off)

### enums - detail

- DisplayFlag { NoDisplayFlags, FixedFontsOnly, DisplayFrame, ShowDifferences }

- FixedFontsOnly only show fixed fonts, excluding proportional fonts
- DisplayFrame show a visual frame around the chooser
- ShowDifferences display the font differences interfaces

typesafe object: DisplayFlags
| NoDisplayFlags | - 0 | - |
| FixedFontsOnly | - 1 | - |
| DisplayFrame | - 2 | - |
| ShowDifferences | - 4 | - |

- FontColumn { FamilyList, StyleList, SizeList }

- FamilyList - Identifies the family (leftmost) list.
- StyleList - Identifies the style (center) list.
- SizeList - Identifies the size (rightmost) list.

| FamilyList | - 0x01 | - |
| StyleList | - 0x02 | - |
| SizeList | - 0x04 | - |

- FontDiff { NoFontDiffFlags, FontDiffFamily, FontDiffStyle, FontDiffSize, AllFontDiffs }

- FontDiffFamily - Identifies a requested change in the font family.
- FontDiffStyle - Identifies a requested change in the font style.
- FontDiffSize - Identifies a requested change in the font size.

typesafe object: FontDiffFlags
| NoFontDiffFlags | - 0 | - |
| FontDiffFamily | - 1 | - |
| FontDiffStyle | - 2 | - |
| FontDiffSize | - 4 | - |
| AllFontDiffs | - FontDiffFamily|FontDiffStyle|FontDiffSize | - |

- FontListCriteria { FixedWidthFonts, ScalableFonts, SmoothScalableFonts }

  The selection criteria for the font families shown in the dialog.

- FixedWidthFont when included only fixed-width fonts are returned.
The fonts where the width of every character is equal.
- ScalableFont when included only scalable fonts are returned;
certain configurations allow bitmap fonts to remain unscaled and thus these fonts have limited number of sizes.
- SmoothScalableFont when included only return smooth scalable fonts.
this will return only non-bitmap fonts which are scalable to any size requested. Setting this option to true will mean the "scalable" flag is irrelavant.

| FixedWidthFonts | - 0x01 | - |
| ScalableFonts | - 0x02 | - |
| SmoothScalableFonts | - 0x04 | - |