KiCad PCB EDA Suite
Loading...
Searching...
No Matches
fontconfig.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2021 Ola Rinta-Koski
5 * Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef KICAD_FONTCONFIG_H
22#define KICAD_FONTCONFIG_H
23
24#include <fontconfig/fontconfig.h>
25
26#include <kicommon.h>
27#include <wx/string.h>
28#include <vector>
29#include <map>
30#include <unordered_map>
31#include <font/fontinfo.h>
32
33class REPORTER;
34namespace fontconfig
35{
36
37struct FONTCONFIG_PAT;
38
40{
41public:
42 FONTCONFIG();
43
44 static wxString Version();
45
46 enum class FF_RESULT
47 {
48 FF_OK,
49 FF_ERROR,
50 FF_SUBSTITUTE,
51 FF_MISSING_BOLD,
52 FF_MISSING_ITAL,
53 FF_MISSING_BOLD_ITAL
54 };
55
62 FF_RESULT FindFont( const wxString& aFontName, wxString& aFontFile, int& aFaceIndex, bool aBold,
63 bool aItalic, const std::vector<wxString>* aEmbeddedFiles = nullptr );
64
72 void ListFonts( std::vector<std::string>& aFonts, const std::string& aDesiredLang,
73 const std::vector<wxString>* aEmbeddedFiles = nullptr, bool aForce = false );
74
80 static void SetReporter( REPORTER* aReporter );
81
82private:
83 std::map<std::string, FONTINFO> m_fontInfoCache;
86
98 bool isLanguageMatch( const wxString& aSearchLang, const wxString& aSupportedLang );
99
106 void getAllFamilyStrings( FONTCONFIG_PAT& aPat,
107 std::unordered_map<std::string, std::string>& aFamStringMap );
108
116 std::string getFamilyStringByLang( FONTCONFIG_PAT& APat, const wxString& aDesiredLang );
117
125 std::string getFcString( FONTCONFIG_PAT& aPat, const char* aObj, int aIdx );
126};
127
128} // namespace fontconfig
129
130
132
133
134#endif //KICAD_FONTCONFIG_H
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:72
static REPORTER * s_reporter
Definition: fontconfig.h:85
std::map< std::string, FONTINFO > m_fontInfoCache
Definition: fontconfig.h:83
wxString m_fontCacheLastLang
Definition: fontconfig.h:84
KICOMMON_API fontconfig::FONTCONFIG * Fontconfig()
Definition: fontconfig.cpp:100
#define KICOMMON_API
Definition: kicommon.h:28
A simple wrapper to avoid exporing fontconfig in the header.
Definition: fontconfig.cpp:48