mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 23:06:13 +08:00
Fix for loading collection(.ttc) from font dialog --> HFONT
This commit is contained in:
parent
a8f0d4a9e1
commit
cfcf0dfcd2
@ -398,18 +398,22 @@ std::optional<Emboss::Font> Emboss::load_font(HFONT hfont)
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// To retrieve the data from the beginning of the file for TrueType
|
||||||
|
// Collection files specify 'ttcf' (0x66637474).
|
||||||
|
DWORD dwTable = 0x66637474;
|
||||||
|
DWORD dwOffset = 0;
|
||||||
|
|
||||||
::SelectObject(hdc, hfont);
|
::SelectObject(hdc, hfont);
|
||||||
size_t size = ::GetFontData(hdc, 0, 0, NULL, 0);
|
size_t size = ::GetFontData(hdc, dwTable, dwOffset, NULL, 0);
|
||||||
if (size == 0) {
|
if (size == 0 || size == GDI_ERROR) {
|
||||||
std::cerr << "HFONT doesn't have size.";
|
std::cerr << "HFONT doesn't have size.";
|
||||||
::DeleteDC(hdc);
|
::DeleteDC(hdc);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<unsigned char> buffer(size);
|
std::vector<unsigned char> buffer(size);
|
||||||
size_t loaded_size = ::GetFontData(hdc, 0, 0, buffer.data(), size);
|
size_t loaded_size = ::GetFontData(hdc, dwTable, dwOffset, buffer.data(), size);
|
||||||
::DeleteDC(hdc);
|
::DeleteDC(hdc);
|
||||||
|
|
||||||
if (size != loaded_size) {
|
if (size != loaded_size) {
|
||||||
std::cerr << "Different loaded(from HFONT) data size.";
|
std::cerr << "Different loaded(from HFONT) data size.";
|
||||||
return {};
|
return {};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user