Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
FontsDB Class Reference

The font database – the in-game character set and the text codec. More...

#include <fontsdb.h>

Inheritance diagram for FontsDB:
Collaboration diagram for FontsDB:

Public Member Functions

const QVector< FontDBEntry * > getStore () const
 All glyphs.
const QHash< QString, FontDBEntry * > getInd () const
 Name->glyph index.
int getStoreSize () const
 Glyph count.
FontDBEntrygetStoreAt (const int ind) const
 Glyph by store index (for QML).
FontDBEntrygetIndAt (const QString val) const
 Glyph by name key (for QML).
const FontDBEntrygetStoreByVal (int ind) const
 Glyph by its font-code value.
FontDBEntryfontAt (int ind) const
 Alias for getStoreAt (1-based-friendly UI accessor).
int fontCount () const
 Alias for getStoreSize.
FontSearchsearchRaw () const
 Raw finder for QML (caller must delete; see note).
QScopedPointer< FontSearch, QScopedPointerDeleteLater > search () const
 C++-owned finder (smart pointer).
const QVector< int > convertToCode (QString str, int maxLen=11, const bool autoEnd=true) const
 String -> font codes (see note; expensive).
const QString convertFromCode (const QVector< int > codes, const int maxLen=11) const
 Font codes -> string (fast).
const QString expandStr (const QString msg, const int maxLen, const QString rival, const QString player) const
 Expand English text to in-game form (substitutes rival/player).
int countSizeOf (const QString val) const
 Rendered length of val (expensive).
int countSizeOfExpanded (const QString val) const
 Rendered length after expandStr (expensive).
void load ()
 Load glyphs from JSON.
void index ()
 Build the name->glyph index.
void qmlProtect (const QQmlEngine *const engine) const
 Pin to C++ ownership.

Static Public Member Functions

static FontsDBinst ()
 < Number of font glyphs.

Detailed Description

The font database – the in-game character set and the text codec.

More than a lookup table: FontsDB owns the glyph entries (keyed by name) AND the conversion between human-readable strings and the game's font-code bytes. This is what powers the name editors and the on-screen keyboard. Beyond the standard DB-singleton accessors it exposes:

Note
Many of these are expensive per call (noted inline). The two search* accessors differ only in ownership (see the inline note) – one for QML, one C++-owned via a smart pointer.
See also
FontDBEntry (a glyph), FontSearch (the filter), FontFilter helpers.

Definition at line 49 of file fontsdb.h.

Member Function Documentation

◆ convertFromCode()

const QString FontsDB::convertFromCode ( const QVector< int > codes,
const int maxLen = 11 ) const

Font codes -> string (fast).

Definition at line 174 of file fontsdb.cpp.

Referenced by expandStr(), and SaveFileToolset::getStr().

◆ convertToCode()

const QVector< int > FontsDB::convertToCode ( QString str,
int maxLen = 11,
const bool autoEnd = true ) const

String -> font codes (see note; expensive).

Definition at line 109 of file fontsdb.cpp.

References FontDBEntry::ind, and FontDBEntry::name.

Referenced by countSizeOf(), countSizeOfExpanded(), expandStr(), FontPreviewInstance::getResultingText(), and SaveFileToolset::setStr().

◆ countSizeOf()

int FontsDB::countSizeOf ( const QString val) const

Rendered length of val (expensive).

Definition at line 423 of file fontsdb.cpp.

References convertToCode().

◆ countSizeOfExpanded()

int FontsDB::countSizeOfExpanded ( const QString val) const

Rendered length after expandStr (expensive).

Definition at line 429 of file fontsdb.cpp.

References convertToCode(), and expandStr().

◆ expandStr()

const QString FontsDB::expandStr ( const QString msg,
const int maxLen,
const QString rival,
const QString player ) const

Expand English text to in-game form (substitutes rival/player).

Definition at line 205 of file fontsdb.cpp.

References convertFromCode(), and convertToCode().

Referenced by countSizeOfExpanded(), and FontPreviewInstance::getResultingText().

◆ fontAt()

FontDBEntry * FontsDB::fontAt ( int ind) const

Alias for getStoreAt (1-based-friendly UI accessor).

Definition at line 413 of file fontsdb.cpp.

References getStoreByVal().

◆ fontCount()

int FontsDB::fontCount ( ) const

Alias for getStoreSize.

Definition at line 418 of file fontsdb.cpp.

References getStoreSize().

◆ getInd()

const QHash< QString, FontDBEntry * > FontsDB::getInd ( ) const

Name->glyph index.

Definition at line 378 of file fontsdb.cpp.

◆ getIndAt()

FontDBEntry * FontsDB::getIndAt ( const QString val) const

Glyph by name key (for QML).

Definition at line 396 of file fontsdb.cpp.

◆ getStore()

const QVector< FontDBEntry * > FontsDB::getStore ( ) const

All glyphs.

Definition at line 373 of file fontsdb.cpp.

◆ getStoreAt()

FontDBEntry * FontsDB::getStoreAt ( const int ind) const

Glyph by store index (for QML).

Definition at line 388 of file fontsdb.cpp.

◆ getStoreByVal()

const FontDBEntry * FontsDB::getStoreByVal ( int ind) const

Glyph by its font-code value.

Definition at line 401 of file fontsdb.cpp.

Referenced by fontAt().

◆ getStoreSize()

int FontsDB::getStoreSize ( ) const

Glyph count.

Definition at line 383 of file fontsdb.cpp.

Referenced by fontCount().

◆ index()

void FontsDB::index ( )

Build the name->glyph index.

Definition at line 54 of file fontsdb.cpp.

◆ inst()

FontsDB * FontsDB::inst ( )
static

< Number of font glyphs.

A fresh glyph finder (QML-owned; see note). The process-wide FontsDB singleton.

Definition at line 367 of file fontsdb.cpp.

Referenced by DB::fonts(), FontPreviewInstance::getResultingText(), SaveFileToolset::getStr(), FontSearch::keepAnyOf(), DB::qmlProtect(), SaveFileToolset::setStr(), and FontSearch::startOver().

◆ load()

void FontsDB::load ( )

Load glyphs from JSON.

Definition at line 32 of file fontsdb.cpp.

References GameData::inst(), and GameData::json().

◆ qmlProtect()

void FontsDB::qmlProtect ( const QQmlEngine *const engine) const

Pin to C++ ownership.

Definition at line 70 of file fontsdb.cpp.

References Utility::qmlProtectUtil().

Referenced by DB::qmlProtect().

◆ search()

QScopedPointer< FontSearch, QScopedPointerDeleteLater > FontsDB::search ( ) const

C++-owned finder (smart pointer).

Definition at line 98 of file fontsdb.cpp.

◆ searchRaw()

FontSearch * FontsDB::searchRaw ( ) const

Raw finder for QML (caller must delete; see note).

Definition at line 93 of file fontsdb.cpp.


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