tornavis/source/blender/blenfont/intern/blf_dir.cc

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

62 lines
983 B
C++
Raw Normal View History

/* SPDX-FileCopyrightText: 2009 Blender Authors
*
* SPDX-License-Identifier: GPL-2.0-or-later */
/** \file
* \ingroup blf
*
* Manage search paths for font files.
2011-02-27 21:42:42 +01:00
*/
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_GLYPH_H
#include "MEM_guardedalloc.h"
#include "DNA_vec_types.h"
#include "BLI_fileops.h"
#include "BLI_string.h"
2024-01-31 20:04:56 +01:00
#include "BLF_api.hh"
#include "blf_internal.hh"
char *blf_dir_metrics_search(const char *filepath)
{
char *mfile;
char *s;
mfile = BLI_strdup(filepath);
s = strrchr(mfile, '.');
if (s) {
if (BLI_strnlen(s, 4) < 4) {
MEM_freeN(mfile);
return nullptr;
}
s++;
s[0] = 'a';
s[1] = 'f';
s[2] = 'm';
2021-08-26 04:27:14 +02:00
/* First check `.afm`. */
if (BLI_exists(mfile)) {
return mfile;
}
2021-08-26 04:27:14 +02:00
/* And now check `.pfm`. */
s[0] = 'p';
if (BLI_exists(mfile)) {
return mfile;
}
}
MEM_freeN(mfile);
return nullptr;
}