That Terminal
A terminal emulator designed for video making purposes.
read_font.hh File Reference

Contains low-level functions for parsing font files. Used by ReadFontsList and FontPlan. More...

#include <filesystem>
#include <vector>
#include <map>
#include <unordered_map>
Include dependency graph for read_font.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  GlyphList
 

Functions

std::multimap< std::size_t, char32_t > Read_PSFgzEncoding (std::string_view filename)
 
std::vector< char32_t > BDFtranslateToUnicode (int index, std::string_view reg, std::string_view enc)
 
GlyphList Read_PSFgz (std::string_view filename, unsigned width, unsigned height, std::string_view guess_encoding)
 
GlyphList Read_BDF (std::string_view filename, unsigned width, unsigned height, std::string_view guess_encoding)
 
GlyphList Read_Inc (std::string_view filename, unsigned width, unsigned height, std::string_view guess_encoding)
 
GlyphList Read_ASM (std::string_view filename, unsigned width, unsigned height, std::string_view guess_encoding)
 
GlyphList Read_Font (std::filesystem::path filename, unsigned width, unsigned height, bool find=false, std::string_view guess_encoding="")
 
std::string ReadGZ (std::string_view filename)
 

Detailed Description

Contains low-level functions for parsing font files. Used by ReadFontsList and FontPlan.

Function Documentation

◆ BDFtranslateToUnicode()

std::vector<char32_t> BDFtranslateToUnicode ( int  index,
std::string_view  reg,
std::string_view  enc 
)

Attempts to convert a character index into unicode using the given encoding.

Parameters
indexCharacter index to convert
regFirst part of encoding name (registry)
encSecond part of encoding name (encoding)

If both reg and enc are supplied, they are joined with a dash. The following encodings are supported by built-in code: iso10646-1 and iso-8859-1: Index is returned verbatim jisx0201.1976-0: Conversion is done using built-in code

For any other encoding, a conversion table file is searched in share/encodings/. If the file is found, and the table contains information about this index, that table is used for the translation.

Additionally, indexes 00-1F and 7F are converted as in CP437; indexes 81-9F follow the CP/M plus character set with a shift. The result is an array that contains multiple choices for the encoding.

◆ Read_ASM()

GlyphList Read_ASM ( std::string_view  filename,
unsigned  width,
unsigned  height,
std::string_view  guess_encoding 
)

Reads an .asm format font file.

◆ Read_BDF()

GlyphList Read_BDF ( std::string_view  filename,
unsigned  width,
unsigned  height,
std::string_view  guess_encoding 
)

Reads a BDF format font file.

◆ Read_Font()

GlyphList Read_Font ( std::filesystem::path  filename,
unsigned  width,
unsigned  height,
bool  find = false,
std::string_view  guess_encoding = "" 
)

Locates a font file by the given name (

See also
FindShareFile), and attempts to detect its format and parses it using one of the Read functions listed above.
Parameters
filenameFile to read
widthWidth of glyphs in the font
heightHeight of glyphs in the font
findIf true, uses FindShareFile to locate the file. If false, just reads the given path.
guess_encodingGuessed encoding for the font.
See also
BDFtranslateToUnicode
Returns
List of glyphs found in the font.

◆ Read_Inc()

GlyphList Read_Inc ( std::string_view  filename,
unsigned  width,
unsigned  height,
std::string_view  guess_encoding 
)

Reads an .inc format font file.

◆ Read_PSFgz()

GlyphList Read_PSFgz ( std::string_view  filename,
unsigned  width,
unsigned  height,
std::string_view  guess_encoding 
)

Reads a PDF.gz format font file.

◆ Read_PSFgzEncoding()

std::multimap<std::size_t, char32_t> Read_PSFgzEncoding ( std::string_view  filename)

Reads a character encoding table from a PSF.GZ file.

◆ ReadGZ()

std::string ReadGZ ( std::string_view  filename)

Reads a GZIP-compressed or deflated file and decompresses it using TinyDeflate.

Returns
Decompressed contents.