Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenfont')
-rw-r--r--source/blender/blenfont/BLF_api.h8
-rw-r--r--source/blender/blenfont/CMakeLists.txt2
-rw-r--r--source/blender/blenfont/intern/blf_font_default.c59
-rw-r--r--source/blender/blenfont/intern/blf_font_i18n.c113
4 files changed, 63 insertions, 119 deletions
diff --git a/source/blender/blenfont/BLF_api.h b/source/blender/blenfont/BLF_api.h
index fd6411f7c69..9aee8c9b78b 100644
--- a/source/blender/blenfont/BLF_api.h
+++ b/source/blender/blenfont/BLF_api.h
@@ -238,11 +238,9 @@ void BLF_thumb_preview(const char *filename,
int h,
int channels) ATTR_NONNULL();
-/* blf_font_i18.c */
-unsigned char *BLF_get_unifont(int *unifont_size);
-void BLF_free_unifont(void);
-unsigned char *BLF_get_unifont_mono(int *unifont_size);
-void BLF_free_unifont_mono(void);
+/* blf_font_default.c */
+int BLF_load_default(const bool unique);
+int BLF_load_mono_default(const bool unique);
#ifdef DEBUG
void BLF_state_print(int fontid);
diff --git a/source/blender/blenfont/CMakeLists.txt b/source/blender/blenfont/CMakeLists.txt
index fa02d6d21c9..ac927dd388d 100644
--- a/source/blender/blenfont/CMakeLists.txt
+++ b/source/blender/blenfont/CMakeLists.txt
@@ -41,7 +41,7 @@ set(SRC
intern/blf.c
intern/blf_dir.c
intern/blf_font.c
- intern/blf_font_i18n.c
+ intern/blf_font_default.c
intern/blf_glyph.c
intern/blf_thumbs.c
intern/blf_util.c
diff --git a/source/blender/blenfont/intern/blf_font_default.c b/source/blender/blenfont/intern/blf_font_default.c
new file mode 100644
index 00000000000..f33d7cd4203
--- /dev/null
+++ b/source/blender/blenfont/intern/blf_font_default.c
@@ -0,0 +1,59 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2011 Blender Foundation.
+ * All rights reserved.
+ */
+
+/** \file
+ * \ingroup blf
+ *
+ * API for loading default font files.
+ */
+
+#include <stdio.h>
+
+#include "BLF_api.h"
+
+#include "BLI_path_util.h"
+
+#include "BKE_appdir.h"
+
+static int blf_load_font_default(const char *filename, const bool unique)
+{
+ const char *dir = BKE_appdir_folder_id(BLENDER_DATAFILES, "fonts");
+ if (dir == NULL) {
+ fprintf(stderr,
+ "%s: 'fonts' data path not found for '%s', will not be able to display text\n",
+ __func__,
+ filename);
+ return -1;
+ }
+
+ char filepath[FILE_MAX];
+ BLI_join_dirfile(filepath, sizeof(filepath), dir, filename);
+
+ return (unique) ? BLF_load_unique(filepath) : BLF_load(filepath);
+}
+
+int BLF_load_default(const bool unique)
+{
+ return blf_load_font_default("droidsans.ttf", unique);
+}
+
+int BLF_load_mono_default(const bool unique)
+{
+ return blf_load_font_default("bmonofont-i18n.ttf", unique);
+}
diff --git a/source/blender/blenfont/intern/blf_font_i18n.c b/source/blender/blenfont/intern/blf_font_i18n.c
deleted file mode 100644
index caacd6a28db..00000000000
--- a/source/blender/blenfont/intern/blf_font_i18n.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2011 Blender Foundation.
- * All rights reserved.
- */
-
-/** \file
- * \ingroup blf
- *
- * API for accessing font files.
- */
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "BLF_api.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "BLI_utildefines.h"
-
-#include "BKE_appdir.h"
-
-#ifdef WITH_INTERNATIONAL
-
-# include "BLI_fileops.h"
-# include "BLI_string.h"
-
-struct FontBuf {
- const char *filename;
- uchar *data;
- int data_len;
-};
-
-static struct FontBuf unifont_ttf = {"droidsans.ttf"};
-static struct FontBuf unifont_mono_ttf = {"bmonofont-i18n.ttf"};
-
-static void fontbuf_load(struct FontBuf *fb)
-{
- const char *fontpath = BKE_appdir_folder_id(BLENDER_DATAFILES, "fonts");
- if (fontpath) {
- char unifont_path[1024];
- BLI_snprintf(unifont_path, sizeof(unifont_path), "%s/%s", fontpath, fb->filename);
- fb->data = (uchar *)BLI_file_ungzip_to_mem(unifont_path, &fb->data_len);
- }
- else {
- printf("%s: 'fonts' data path not found for '%s', continuing\n", __func__, fb->filename);
- }
-}
-
-static void fontbuf_free(struct FontBuf *fb)
-{
- MEM_SAFE_FREE(fb->data);
- fb->data_len = 0;
-}
-
-static uchar *fontbuf_get_mem(struct FontBuf *fb, int *r_size)
-{
- if (fb->data == NULL) {
- fontbuf_load(fb);
- }
- *r_size = fb->data_len;
- return fb->data;
-}
-
-#endif /* WITH_INTERNATIONAL */
-
-uchar *BLF_get_unifont(int *r_unifont_size)
-{
-#ifdef WITH_INTERNATIONAL
- return fontbuf_get_mem(&unifont_ttf, r_unifont_size);
-#else
- UNUSED_VARS(r_unifont_size);
- return NULL;
-#endif
-}
-
-uchar *BLF_get_unifont_mono(int *r_unifont_size)
-{
-#ifdef WITH_INTERNATIONAL
- return fontbuf_get_mem(&unifont_mono_ttf, r_unifont_size);
-#else
- UNUSED_VARS(r_unifont_size);
- return NULL;
-#endif
-}
-
-void BLF_free_unifont(void)
-{
-#ifdef WITH_INTERNATIONAL
- fontbuf_free(&unifont_ttf);
-#endif
-}
-
-void BLF_free_unifont_mono(void)
-{
-#ifdef WITH_INTERNATIONAL
- fontbuf_free(&unifont_mono_ttf);
-#endif
-}