Skip to content

Commit

Permalink
audqt: Parse font family names containing digits correctly. Closes: #…
Browse files Browse the repository at this point in the history
…1483

"PxPlus ToshibaSat 9x16 Bold 8" from the Oldschool PC Font Pack
is such an example. To parse the font family correctly, we need
to check if all characters for the font size are digits.

Both str_to_int() and atoi() do not support this.
Use strtol() instead and check "endptr" accordingly.
  • Loading branch information
radioactiveman authored and jlindgren90 committed Oct 7, 2024
1 parent d75d5e7 commit dff5092
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/libaudqt/font-entry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#include "libaudqt.h"

#include <stdlib.h>

#include <QAction>
#include <QFontDialog>
#include <QLineEdit>
Expand Down Expand Up @@ -72,11 +74,13 @@ EXPORT QFont qfont_from_string(const char * name)
if (space)
{
const char * attr = space + 1;
int num = str_to_int(attr);

char * endptr;
long num = strtol(attr, &endptr, 10);

attr_found = true;

if (num > 0)
if (num > 0 && *endptr == '\0')
size = num;
else if (!strcmp(attr, "Light"))
weight = QFont::Light;
Expand Down

0 comments on commit dff5092

Please sign in to comment.