File: FontUtils.h

package info (click to toggle)
kodi 2%3A20.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 143,820 kB
  • sloc: cpp: 664,925; xml: 68,398; ansic: 37,223; python: 6,903; sh: 4,209; javascript: 2,325; makefile: 1,754; perl: 969; java: 513; cs: 390; objc: 340
file content (70 lines) | stat: -rw-r--r-- 2,072 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 *  Copyright (C) 2022 Team Kodi
 *  This file is part of Kodi - https://kodi.tv
 *
 *  SPDX-License-Identifier: GPL-2.0-or-later
 *  See LICENSES/README.md for more information.
 */

#pragma once

#include <stdint.h>
#include <string>
#include <vector>

namespace UTILS
{
namespace FONT
{
constexpr const char* SUPPORTED_EXTENSIONS_MASK = ".ttf|.otf";

// The default application font
constexpr const char* FONT_DEFAULT_FILENAME = "arial.ttf";

namespace FONTPATH
{
// Directory where Kodi bundled fonts files are located
constexpr const char* SYSTEM = "special://xbmc/media/Fonts/";
// Directory where user defined fonts are located
constexpr const char* USER = "special://home/media/Fonts/";
// Temporary font path (where MKV fonts are extracted and temporarily stored)
constexpr const char* TEMP = "special://temp/fonts/";

/*!
 *  \brief Provided a font filename returns the complete path for the font in
 *  the system font folder (if it exists) or an empty string otherwise
 *  \param filename The font file name
 *  \return The path for the font or an empty string if the path does not exist
 */
std::string GetSystemFontPath(const std::string& filename);
}; // namespace FONTPATH

/*!
 *  \brief Get the font family name from a font file
 *  \param buffer The font data
 *  \return The font family name, otherwise empty if fails
 */
std::string GetFontFamily(std::vector<uint8_t>& buffer);

/*!
 *  \brief Get the font family name from a font file
 *  \param filepath The path where read the font data
 *  \return The font family name, otherwise empty if fails
 */
std::string GetFontFamily(const std::string& filepath);

/*!
 *  \brief Check if a filename have a supported font extension.
 *  \param filepath The font file path
 *  \return True if it has a supported extension, otherwise false
 */
bool IsSupportedFontExtension(const std::string& filepath);

/*!
 *  \brief Removes all temporary fonts, e.g.those extract from MKV containers
 *  that are only available during playback
 */
void ClearTemporaryFonts();

} // namespace FONT
} // namespace UTILS