mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
use vfs
This commit is contained in:
parent
fdf22f5da7
commit
01a15a9523
@ -22,6 +22,8 @@
|
|||||||
|
|
||||||
#include "config_text.h"
|
#include "config_text.h"
|
||||||
#include "config_util.h"
|
#include "config_util.h"
|
||||||
|
#include "config_express.h"
|
||||||
|
#include "virtualFileSystem.h"
|
||||||
|
|
||||||
bool DynamicTextFont::_update_cleared_glyphs = text_update_cleared_glyphs;
|
bool DynamicTextFont::_update_cleared_glyphs = text_update_cleared_glyphs;
|
||||||
|
|
||||||
@ -84,18 +86,33 @@ DynamicTextFont(const Filename &font_filename, int face_index) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool exists = false;
|
||||||
|
int error;
|
||||||
Filename path(font_filename);
|
Filename path(font_filename);
|
||||||
path.resolve_filename(get_model_path());
|
if (use_vfs) {
|
||||||
if (!path.exists()) {
|
VirtualFileSystem *vfs = VirtualFileSystem::get_global_ptr();
|
||||||
|
vfs->resolve_filename(path, get_model_path());
|
||||||
|
exists = vfs->read_file(path, _raw_font_data);
|
||||||
|
if (exists) {
|
||||||
|
error = FT_New_Memory_Face(_ft_library,
|
||||||
|
(const FT_Byte *)_raw_font_data.data(),
|
||||||
|
_raw_font_data.length(),
|
||||||
|
face_index, &_face);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
path.resolve_filename(get_model_path());
|
||||||
|
exists = path.exists();
|
||||||
|
if (exists) {
|
||||||
|
string os_specific = path.to_os_specific();
|
||||||
|
error = FT_New_Face(_ft_library, os_specific.c_str(),
|
||||||
|
face_index, &_face);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!exists) {
|
||||||
text_cat.error()
|
text_cat.error()
|
||||||
<< "Unable to find font file " << font_filename << "\n";
|
<< "Unable to find font file " << font_filename << "\n";
|
||||||
} else {
|
} else {
|
||||||
string os_specific = path.to_os_specific();
|
|
||||||
|
|
||||||
int error = FT_New_Face(_ft_library,
|
|
||||||
os_specific.c_str(),
|
|
||||||
face_index,
|
|
||||||
&_face);
|
|
||||||
if (error == FT_Err_Unknown_File_Format) {
|
if (error == FT_Err_Unknown_File_Format) {
|
||||||
text_cat.error()
|
text_cat.error()
|
||||||
<< "Unable to read font " << font_filename << ": unknown file format.\n";
|
<< "Unable to read font " << font_filename << ": unknown file format.\n";
|
||||||
|
@ -137,6 +137,11 @@ private:
|
|||||||
|
|
||||||
FT_Face _face;
|
FT_Face _face;
|
||||||
|
|
||||||
|
// This string is used to hold the data read from the font file in
|
||||||
|
// vfs mode. Since the FreeType library keeps pointers into this
|
||||||
|
// data, we have to keep it around.
|
||||||
|
string _raw_font_data;
|
||||||
|
|
||||||
static FT_Library _ft_library;
|
static FT_Library _ft_library;
|
||||||
static bool _ft_initialized;
|
static bool _ft_initialized;
|
||||||
static bool _ft_ok;
|
static bool _ft_ok;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user