Blender  V2.93
blf_font_default.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2011 Blender Foundation.
17  * All rights reserved.
18  */
19 
26 #include <stdio.h>
27 
28 #include "BLF_api.h"
29 
30 #include "BLI_path_util.h"
31 
32 #include "BKE_appdir.h"
33 
34 static int blf_load_font_default(const char *filename, const bool unique)
35 {
36  const char *dir = BKE_appdir_folder_id(BLENDER_DATAFILES, "fonts");
37  if (dir == NULL) {
38  fprintf(stderr,
39  "%s: 'fonts' data path not found for '%s', will not be able to display text\n",
40  __func__,
41  filename);
42  return -1;
43  }
44 
45  char filepath[FILE_MAX];
46  BLI_join_dirfile(filepath, sizeof(filepath), dir, filename);
47 
48  return (unique) ? BLF_load_unique(filepath) : BLF_load(filepath);
49 }
50 
51 int BLF_load_default(const bool unique)
52 {
53  return blf_load_font_default("droidsans.ttf", unique);
54 }
55 
56 int BLF_load_mono_default(const bool unique)
57 {
58  return blf_load_font_default("bmonofont-i18n.ttf", unique);
59 }
@ BLENDER_DATAFILES
Definition: BKE_appdir.h:78
const char * BKE_appdir_folder_id(const int folder_id, const char *subfolder)
Definition: appdir.c:674
int BLF_load_unique(const char *name) ATTR_NONNULL()
Definition: blf.c:166
int BLF_load(const char *name) ATTR_NONNULL()
Definition: blf.c:153
#define FILE_MAX
void BLI_join_dirfile(char *__restrict dst, const size_t maxlen, const char *__restrict dir, const char *__restrict file) ATTR_NONNULL()
Definition: path_util.c:1737
static int blf_load_font_default(const char *filename, const bool unique)
int BLF_load_mono_default(const bool unique)
int BLF_load_default(const bool unique)