mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-11 05:11:49 +08:00
Add log for not openable font file
This commit is contained in:
parent
bf55f63c39
commit
aa00da1b7e
@ -778,20 +778,20 @@ std::unique_ptr<Emboss::FontFile> Emboss::create_font_file(const char *file_path
|
|||||||
FILE *file = fopen(file_path, "rb");
|
FILE *file = fopen(file_path, "rb");
|
||||||
if (file == nullptr) {
|
if (file == nullptr) {
|
||||||
assert(false);
|
assert(false);
|
||||||
// BOOST_LOG_TRIVIAL(error) << "Couldn't open " << file_path << " for reading." << std::endl;
|
BOOST_LOG_TRIVIAL(error) << "Couldn't open " << file_path << " for reading.";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// find size of file
|
// find size of file
|
||||||
if (fseek(file, 0L, SEEK_END) != 0) {
|
if (fseek(file, 0L, SEEK_END) != 0) {
|
||||||
assert(false);
|
assert(false);
|
||||||
// BOOST_LOG_TRIVIAL(error) << "Couldn't fseek file " << file_path << " for size measure." << std::endl;
|
BOOST_LOG_TRIVIAL(error) << "Couldn't fseek file " << file_path << " for size measure.";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
size_t size = ftell(file);
|
size_t size = ftell(file);
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
assert(false);
|
assert(false);
|
||||||
// BOOST_LOG_TRIVIAL(error) << "Size of font file is zero. Can't read." << std::endl;
|
BOOST_LOG_TRIVIAL(error) << "Size of font file is zero. Can't read.";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
rewind(file);
|
rewind(file);
|
||||||
@ -799,7 +799,7 @@ std::unique_ptr<Emboss::FontFile> Emboss::create_font_file(const char *file_path
|
|||||||
size_t count_loaded_bytes = fread((void *) &buffer->front(), 1, size, file);
|
size_t count_loaded_bytes = fread((void *) &buffer->front(), 1, size, file);
|
||||||
if (count_loaded_bytes != size) {
|
if (count_loaded_bytes != size) {
|
||||||
assert(false);
|
assert(false);
|
||||||
// BOOST_LOG_TRIVIAL(error) << "Different loaded(from file) data size." << std::endl;
|
BOOST_LOG_TRIVIAL(error) << "Different loaded(from file) data size.";
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return create_font_file(std::move(buffer));
|
return create_font_file(std::move(buffer));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user