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
|