Subversion Repositories tpanel

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
7 andreas 1
/*
21 andreas 2
 * Copyright (C) 2020, 2021 by Andreas Theofilu <andreas@theosys.at>
7 andreas 3
 *
4
 * This program is free software; you can redistribute it and/or modify
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 3 of the License, or
7
 * (at your option) any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 * GNU General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU General Public License
15
 * along with this program; if not, write to the Free Software Foundation,
16
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
17
 */
18
 
19
#ifndef __TFONT_H__
20
#define __TFONT_H__
21
 
22
#include <string>
23
#include <map>
75 andreas 24
 
7 andreas 25
#include "tvalidatefile.h"
26
 
27
#include <include/core/SkTypeface.h>
40 andreas 28
#include <include/core/SkFontStyle.h>
7 andreas 29
 
30
typedef struct FONT_T
31
{
32
    int number;
33
    std::string file;
34
    int fileSize;
35
    int faceIndex;
36
    std::string name;
37
    std::string subfamilyName;
38
    std::string fullName;
39
    int size;
40
    int usageCount;
41
}FONT_T;
42
 
43
typedef enum FONT_STYLE
44
{
45
    FONT_NONE,
46
    FONT_NORMAL,
47
    FONT_ITALIC,
48
    FONT_BOLD,
49
    FONT_BOLD_ITALIC
50
}FONT_STYLE;
51
 
52
class TFont : public TValidateFile
53
{
54
    public:
55
        TFont();
56
        ~TFont();
57
 
58
        void initialize();
44 andreas 59
        bool systemFonts();
7 andreas 60
        FONT_T getFont(int number);
61
        FONT_STYLE getStyle(int number);
62
        FONT_STYLE getStyle(FONT_T& font);
40 andreas 63
        SkFontStyle getSkiaStyle(int number);
7 andreas 64
        sk_sp<SkTypeface> getTypeFace(int number);
67 andreas 65
 
51 andreas 66
        static std::vector<std::string> getFontPathList();
67 andreas 67
        static SkGlyphID *textToGlyphs(const std::string& str, sk_sp<SkTypeface>& typeFace, size_t *size);
68
        static bool isSymbol(sk_sp<SkTypeface>& typeFace);
69
        static size_t utf8ToUtf16(const std::string& str, uint16_t **uni, bool toSymbol = false);
7 andreas 70
 
71
    private:
67 andreas 72
        static void parseCmap(const unsigned char *cmaps);
73
        static uint16_t getGlyphIndex(SkUnichar);
74
        static void _freeCmap();
75
 
7 andreas 76
        std::map<int, FONT_T> mFonts;
77
};
78
 
79
#endif