1 /* font-manager-font.c
2  *
3  * Copyright (C) 2009 - 2021 Jerry Casiano
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.
17  *
18  * If not, see <http://www.gnu.org/licenses/gpl-3.0.txt>.
19 */
20 
21 #include "font-manager-font.h"
22 
23 /**
24  * SECTION: font-manager-font
25  * @short_description: Font style information
26  * @title: Font
27  * @include: font-manager-font.h
28  * @see_also: #FontManagerJsonProxy
29  *
30  * #FontManagerFont holds basic style information for a single font.
31  *
32  * The #JsonObject backing this class should have the following structure:
33  *
34  *|[
35  * {
36  *   "filepath" : string,
37  *   "findex" : int,
38  *   "family" : string,
39  *   "style" : string,
40  *   "spacing" : int,
41  *   "slant" : int,
42  *   "weight" : int,
43  *   "width" : int,
44  *   "description" : string,
45  * }
46  *]|
47  */
48 
49 struct _FontManagerFont
50 {
51     GObject parent_instance;
52 };
53 
54 G_DEFINE_TYPE(FontManagerFont, font_manager_font, FONT_MANAGER_TYPE_JSON_PROXY)
55 
56 #define PROPERTIES FontProperties
57 #define N_PROPERTIES G_N_ELEMENTS(PROPERTIES)
58 static GParamSpec *obj_properties[N_PROPERTIES] = {0};
59 
60 static void
font_manager_font_class_init(FontManagerFontClass * klass)61 font_manager_font_class_init (FontManagerFontClass *klass)
62 {
63     GObjectClass *object_class = G_OBJECT_CLASS(klass);
64     GObjectClass *parent_class = G_OBJECT_CLASS(font_manager_font_parent_class);
65     object_class->get_property = parent_class->get_property;
66     object_class->set_property = parent_class->set_property;
67     font_manager_json_proxy_generate_properties(obj_properties, PROPERTIES, N_PROPERTIES);
68     g_object_class_install_properties(object_class, N_PROPERTIES, obj_properties);
69     return;
70 }
71 
72 static void
font_manager_font_init(FontManagerFont * self)73 font_manager_font_init (FontManagerFont *self)
74 {
75     g_return_if_fail(self != NULL);
76 }
77 
78 /**
79  * font_manager_font_new:
80  *
81  * Returns: (transfer full): A newly created #FontManagerFont.
82  * Free the returned object using #g_object_unref().
83  */
84 FontManagerFont *
font_manager_font_new(void)85 font_manager_font_new (void)
86 {
87     return g_object_new(FONT_MANAGER_TYPE_FONT, NULL);
88 }
89 
90