Skip to content

Commit

Permalink
fix #1169 fix ClearFontFaces.
Browse files Browse the repository at this point in the history
  • Loading branch information
karlkleinpaste committed Aug 12, 2024
1 parent 195b90d commit 40dcf0d
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/main/display.cc
Original file line number Diff line number Diff line change
Expand Up @@ -289,26 +289,27 @@ ClearImages(gchar *text)
}

//
// utility function to blank `<font face="..." />' content from text.
// utility function to blank font names `<font face="..." />' in text.
//

#define CLEAR_FONT_NAME "<font face=\""
#define CLEAR_FONT_NAME_LENGTH 12

void
ClearFontFaces(gchar *text)
{
gchar *s;

// huge assumption: no nested <font> specs: <font face="">
// is never followed by another <font anything> before </font>.
for (s = strstr(text, "<font face=\"Galax"); s; s = strstr(s, "<font face=\"Galax")) {
for (s = strstr(text, CLEAR_FONT_NAME); s; s = strstr(s, CLEAR_FONT_NAME)) {
gchar *t;
if ((t = strchr(s + 15, '>'))) {
while (s <= t)
*(s++) = ' ';
s = strstr(s, "</font>");
t = s + 6;
while (s <= t)
*(s++) = ' ';
s += CLEAR_FONT_NAME_LENGTH;
if ((t = strchr(s, '"'))) {
while (s < t)
*(s++) = '.';
} else {
XI_message(("ClearFontFaces: no font end: %s\n", s));
XI_message(("ClearFontFaces: no closing double quote: %s\n", s));
return;
}
}
Expand Down Expand Up @@ -674,7 +675,7 @@ CleanupContent(GString *text,
if (ops->respect_font_faces == 0)
ClearFontFaces((gchar *)text->str);
else if ((ops->respect_font_faces == -1) && // "unknown"
(strcasestr(text->str, "<font face=\"Galax") != NULL)) {
(strcasestr(text->str, "<font face=\"") != NULL)) {
ops->respect_font_faces = 1; // now known.
main_save_module_options(name, "Respect Font Faces", 1);
}
Expand Down

0 comments on commit 40dcf0d

Please sign in to comment.