| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
Public Types | Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
FontManager Class Reference

`#include <font_manager.h>`

Inheritance diagram for FontManager:

## Public Types
enum class | ZoomScope { AppWide , ContentOnly }

## Signals
void | applicationFontChanged (QFont font)
void | monospaceFontChanged (QFont font)
void | zoomChanged ()

## Public Member Functions
void | setRegularFont (const QString &fontName)
void | setMonospaceFont (const QString &fontName)
void | zoomIn ()
void | zoomOut ()
void | resetZoom ()
void | setZoomLevel (int level)
int | zoomLevel () const

## Static Public Member Functions
static FontManager * | instance ()
static QFont | font ()
static QFont | monospaceFont ()
static QFont | zoomedFont ()
static QFont | zoomedMonospaceFont ()
static qreal | zoomFactor ()

## Protected Member Functions
| FontManager (QObject *parent=nullptr)
bool | eventFilter (QObject *watched, QEvent *event) override

## Detailed Description

Single authority for the application's fonts.

A singleton (like ThemeManager): access via FontManager::instance(). Its lifecycle is initiated by ThemeManager at startup — ThemeManager forces the instance into existence and feeds it the configured font names — but every font decision lives here: resolution/validation, the systemwide regular-font push, zoom, catching external (OS) font changes, and notification.

ThemeManager's entire font role is to read a configured font name and hand it to setRegularFont()/setMonospaceFont(). It performs no validation, fixed-pitch checking, or fallback — that is exclusively this class.

Three independent sources can change the font, and all converge here:

- a theme switch (ThemeManager applies the theme fully, then calls the setters, so this class emits its normal font signals once the theme is in place — no separate silent path);
- a zoom action (zoomIn/zoomOut/resetZoom);
- the OS changing the system font (caught via QEvent::ApplicationFontChange).

Consumer contract: a font-using widget owns its own font handling. In its constructor it seeds the current font from the static accessors (e.g. zoomedMonospaceFont()) and connects to the signal it needs (applicationFontChanged and/or monospaceFontChanged) for later theme, zoom, and OS changes. No external party wires a widget's fonts for it, so a widget created at any time is correct immediately and stays in sync on its own.

## Member Enumeration Documentation

## ◆ ZoomScope

enum class FontManager::ZoomScope
| strong

Whether a zoom step scales the whole application or only content views.

AppWide — zoom changes the app-default font via QApplication, so chrome (menus/toolbars/dialogs) scales too. ContentOnly — the app-default font stays at the base size; only widgets that explicitly pull the zoomed fonts scale.

v1 fixes this in the constructor. v2 will drive it from a preference on the "Font & Themes" page.

## Member Function Documentation

## ◆ applicationFontChanged

void FontManager::applicationFontChanged | ( | QFont | font | ) |
| signal

The regular font changed (theme load excepted — see class docs).

## ◆ font()

QFont FontManager::font | ( |  | ) |
| static

Base (unzoomed) regular/proportional font.

## ◆ instance()

FontManager * FontManager::instance | ( |  | ) |
| static

Returns the process-wide singleton, constructing it on first use.

## ◆ monospaceFont()

QFont FontManager::monospaceFont | ( |  | ) |
| static

Base (unzoomed) monospace font.

## ◆ monospaceFontChanged

void FontManager::monospaceFontChanged | ( | QFont | font | ) |
| signal

The monospace font changed (theme load excepted).

## ◆ setMonospaceFont()

void FontManager::setMonospaceFont | ( | const QString & | fontName | ) |

Sets the monospace font. The user preference gui.font_name always wins when set; otherwise `fontName`; otherwise the system fixed font. The result is guaranteed to be fixed-pitch. Emits monospaceFontChanged when the resolved font actually changes.

Parameters

  fontName | font descriptor, or empty.

## ◆ setRegularFont()

void FontManager::setRegularFont | ( | const QString & | fontName | ) |

Sets the regular (proportional) font from a font descriptor string (QFont::toString() form, or a bare family name). An empty string means "no preference" and falls back to the system general font.

Emits applicationFontChanged when the resolved font actually changes, and always reconciles the QApplication font.

Parameters

  fontName | font descriptor, or empty for the system default.

## ◆ zoomChanged

void FontManager::zoomChanged | ( |  | ) |
| signal

The zoom level changed. ThemeManager turns this into a themeChanged so stylesheet-driven widgets reload their zoom-scaled stylesheets.

## ◆ zoomedFont()

QFont FontManager::zoomedFont | ( |  | ) |
| static

Regular font with the current zoom level applied.

## ◆ zoomedMonospaceFont()

QFont FontManager::zoomedMonospaceFont | ( |  | ) |
| static

Monospace font with the current zoom level applied.

## ◆ zoomFactor()

qreal FontManager::zoomFactor | ( |  | ) |
| static

Current zoom multiplier relative to the base regular font (1.0 at zoom level 0). Use to scale sizes that are not expressed as a QFont — e.g. absolute font sizes baked into a stylesheet.

The documentation for this class was generated from the following files:

- /builds/wireshark/wireshark/ui/qt/utils/font_manager.h
- /builds/wireshark/wireshark/ui/qt/utils/font_manager.cpp