Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Remove forced fallback from FT2Font::load_char
The only thing that expected this to work is Type 3 fonts in the PDF
backend, but only to avoid an error when loading a range of characters
(not all of which would be used.) This would introduce an odd behaviour
in that `load_char` could never fail even if the glyph never existed.
You would instead end up with the `null` glyph from the last font.
  • Loading branch information
QuLogic committed Oct 23, 2025
commit a47bd3fcf232f9deebf86ab066f2af06e7eabe31
9 changes: 4 additions & 5 deletions src/ft2font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ void FT2Font::load_char(long charcode, FT_Int32 flags, FT2Font *&ft_object, bool
bool was_found = load_char_with_fallback(ft_object_with_glyph, final_glyph_index,
glyphs, char_to_font,
charcode, flags, charcode_error, glyph_error,
glyph_seen_fonts, true);
glyph_seen_fonts);
if (!was_found) {
ft_glyph_warn(charcode, glyph_seen_fonts);
if (charcode_error) {
Expand Down Expand Up @@ -613,15 +613,14 @@ bool FT2Font::load_char_with_fallback(FT2Font *&ft_object_with_glyph,
FT_Int32 flags,
FT_Error &charcode_error,
FT_Error &glyph_error,
std::set<FT_String*> &glyph_seen_fonts,
bool override = false)
std::set<FT_String*> &glyph_seen_fonts)
{
FT_UInt glyph_index = FT_Get_Char_Index(face, charcode);
if (!warn_if_used) {
glyph_seen_fonts.insert(face->family_name);
}

if (glyph_index || override) {
if (glyph_index) {
charcode_error = FT_Load_Glyph(face, glyph_index, flags);
if (charcode_error) {
return false;
Expand All @@ -647,7 +646,7 @@ bool FT2Font::load_char_with_fallback(FT2Font *&ft_object_with_glyph,
bool was_found = fallback->load_char_with_fallback(
ft_object_with_glyph, final_glyph_index, parent_glyphs,
parent_char_to_font, charcode, flags,
charcode_error, glyph_error, glyph_seen_fonts, override);
charcode_error, glyph_error, glyph_seen_fonts);
if (was_found) {
return true;
}
Expand Down
3 changes: 1 addition & 2 deletions src/ft2font.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ class FT2Font
FT_Int32 flags,
FT_Error &charcode_error,
FT_Error &glyph_error,
std::set<FT_String*> &glyph_seen_fonts,
bool override);
std::set<FT_String*> &glyph_seen_fonts);
void load_glyph(FT_UInt glyph_index, FT_Int32 flags);
std::tuple<long, long> get_width_height();
std::tuple<long, long> get_bitmap_offset();
Expand Down
Loading