Tulip  5.2.0
Large graphs analysis and drawing
TulipFontAwesome.h
1 /*
2  *
3  * This file is part of Tulip (http://tulip.labri.fr)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 
20 #ifndef TULIPFONTAWESOME_H
21 #define TULIPFONTAWESOME_H
22 
23 #include <tulip/tulipconf.h>
24 
25 #include <vector>
26 
27 namespace tlp {
28 
29 /**
30  * @brief Helper class for the configuration of a Font Awesome glyph.
31  *
32  * Font Awesome is a free iconic font by Dave Gandy (see https://fontawesome.com)
33  * offering more than 500 customizable scalable vector icons.
34  *
35  * A glyph has been added to Tulip enabling to use these great icons
36  * as nodes and edges extremities shapes.
37  *
38  * That class offers utility functions and supported icons names constants.
39  *
40  * To set a node glyph as a Font Awesome icon, the Icon glyph must be associated
41  * to the node through the modification of the "viewShape" integer property attached to the graph.
42  * The name of the icon to use must then be set in the "viewIcon" string property.
43  * As an example, the following code snippet activates the Font Awesome glyph for all nodes
44  * and sets the "user" icon.
45  *
46  * @code
47  * // graph is a pointer to a tlp::Graph object
48  * tlp::IntegerProperty *viewShape = graph->getProperty<tlp::IntegerProperty>("viewShape");
49  * tlp::StringProperty *viewIcon = graph->getProperty<tlp::StringProperty>("viewIcon");
50  *
51  * // sets the Icon glyph on all nodes
52  * viewShape->setAllNodeValue(tlp::NodeShape::Icon);
53  * // sets the "user" glyph for all nodes
54  * viewIcon->setAllNodeValue("fa-user");
55  * @endcode
56  **/
57 
58 class TLP_GL_SCOPE TulipFontAwesome {
59 
60 public:
61  /**
62  * Returns the version of the Font Awesome icons bundled with Tulip
63  */
64  static std::string getVersion();
65 
66  /**
67  * Returns the location of the Font Awesome .ttf file bundled with Tulip
68  */
69  static std::string getTTFLocation(const std::string &iconName);
70 
71  /**
72  * Returns the location of the Font Awesome .woff file bundled with Tulip
73  */
74  static std::string getWOFFLocation(const std::string &iconName);
75 
76  /**
77  * Returns the location of the Font Awesome .woff2 file bundled with Tulip
78  */
79  static std::string getWOFF2Location(const std::string &iconName);
80 
81  /**
82  * Returns the list of supported Font Awesome icons names
83  */
84  static const std::vector<std::string> &getSupportedIcons();
85 
86  /**
87  * Checks if the provided Font Awesome icon name is supported
88  * @param iconName the name of the icon to check support
89  */
90  static bool isIconSupported(const std::string &iconName);
91 
92  /**
93  * Returns the Unicode code point associated to an icon name
94  * @param iconName the name of the icon to get the codepoint
95  */
96  static unsigned int getIconCodePoint(const std::string &iconName);
97 
98  /**
99  * Returns the font family name associated to an icon name
100  * @param iconName the name of the icon
101  */
102  static std::string getIconFamily(const std::string &iconName);
103 
104  /**
105  * Returns an UTF-8 encoded string of a Font Awesome icon
106  * @param iconName a Font Awesome icon name
107  * @return
108  */
109  static std::string getIconUtf8String(const std::string &iconName);
110 };
111 }
112 
113 #endif // TULIPFONTAWESOME_H
Helper class for the configuration of a Font Awesome glyph.