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
33namespace fontconfig
34{
35
36struct FONTCONFIG_PAT;
37
39{
40public:
41 FONTCONFIG();
42
43 static wxString Version();
44
45 enum class FF_RESULT
46 {
47 FF_OK,
48 FF_ERROR,
49 FF_SUBSTITUTE,
50 FF_MISSING_BOLD,
51 FF_MISSING_ITAL,
52 FF_MISSING_BOLD_ITAL
53 };
54
61 FF_RESULT FindFont( const wxString& aFontName, wxString& aFontFile, int& aFaceIndex, bool aBold, bool aItalic );
62
68 void ListFonts( std::vector<std::string>& aFonts, const std::string& aDesiredLang );
69
70private:
71 std::map<std::string, FONTINFO> m_fontInfoCache;
73
85 bool isLanguageMatch( const wxString& aSearchLang, const wxString& aSupportedLang );
86
93 void getAllFamilyStrings( FONTCONFIG_PAT& aPat,
94 std::unordered_map<std::string, std::string>& aFamStringMap );
95
103 std::string getFamilyStringByLang( FONTCONFIG_PAT& APat, const wxString& aDesiredLang );
104
112 std::string getFcString( FONTCONFIG_PAT& aPat, const char* aObj, int aIdx );
113};
114
115} // namespace fontconfig
116
117
119
120
121#endif //KICAD_FONTCONFIG_H
std::map< std::string, FONTINFO > m_fontInfoCache
Definition: fontconfig.h:71
wxString m_fontCacheLastLang
Definition: fontconfig.h:72
KICOMMON_API fontconfig::FONTCONFIG * Fontconfig()
Definition: fontconfig.cpp:90
#define KICOMMON_API
Definition: kicommon.h:28
A simple wrapper to avoid exporing fontconfig in the header.
Definition: fontconfig.cpp:44