summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGreg Ercolano <erco@seriss.com>2020-07-31 07:00:46 -0700
committerGreg Ercolano <erco@seriss.com>2020-07-31 07:00:46 -0700
commit7514a73ba759f7fc9965eeef3b92ece899bd7a69 (patch)
tree6c85c5620c4a63c40ebd1b477c0523bc4564da45
parent889acc7d74a8d5c79d4016900294246a9b04b9c2 (diff)
Solves issue #117, memcmp -> strncmp
Closes #117.
-rw-r--r--src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx
index c528f2721..e6352af2a 100644
--- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx
+++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx
@@ -618,15 +618,22 @@ void Fl_Quartz_Graphics_Driver::ADD_SUFFIX(draw, _CoreText)(const char *str, int
CFRelease(ctline);
}
+// Skip over bold/italic/oblique qualifiers part of PostScript font names
+// Example:
+// input: '-Regular_Light-Condensed'
+// return: '_Light-Condensed'
+//
static char *skip(char *p, int& derived)
{
- if (memcmp(p, "-BoldItalic", 11) == 0) { p += 11; derived = 3; }
- else if (memcmp(p, "-BoldOblique", 12) == 0) { p += 12; derived = 3; }
- else if (memcmp(p, "-Bold", 5) == 0) {p += 5; derived = 1; }
- else if (memcmp(p, "-Italic", 7) == 0) {p += 7; derived = 2; }
- else if (memcmp(p, "-Oblique", 8) == 0) {p += 8; derived = 2; }
- else if (memcmp(p, "-Regular", 8) == 0) {p += 8; }
- else if (memcmp(p, "-Roman", 6) == 0) {p += 6; }
+ // 0 5 10
+ // | | |
+ if (strncmp(p, "-BoldItalic", 11) == 0) { p += 11; derived = 3; }
+ else if (strncmp(p, "-BoldOblique", 12) == 0) { p += 12; derived = 3; }
+ else if (strncmp(p, "-Bold", 5) == 0) { p += 5; derived = 1; }
+ else if (strncmp(p, "-Italic", 7) == 0) { p += 7; derived = 2; }
+ else if (strncmp(p, "-Oblique", 8) == 0) { p += 8; derived = 2; }
+ else if (strncmp(p, "-Regular", 8) == 0) { p += 8; }
+ else if (strncmp(p, "-Roman", 6) == 0) { p += 6; }
return p;
}