summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2013-10-30 13:36:16 +0000
committerManolo Gouy <Manolo>2013-10-30 13:36:16 +0000
commit2fd7086605e46f93525abc3ffbcc18489d9ba7d8 (patch)
tree4d700c99a68ca3c71ca80a4f92ae0538250f6875 /src
parent830f9eec89a7e02574d405a037d8fd0357a79943 (diff)
Improved the ordering of font names consistently grouping them by family (cont'd).
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10014 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/fl_set_fonts_mac.cxx29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/fl_set_fonts_mac.cxx b/src/fl_set_fonts_mac.cxx
index 07756090b..e6f11e144 100644
--- a/src/fl_set_fonts_mac.cxx
+++ b/src/fl_set_fonts_mac.cxx
@@ -56,6 +56,19 @@ const char* Fl::get_font_name(Fl_Font fnum, int* ap) {
}
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
+
+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; }
+ return p;
+}
+
static int name_compare(const void *a, const void *b)
{
/* Compare PostScript font names.
@@ -67,20 +80,8 @@ static int name_compare(const void *a, const void *b)
int derived1 = 0;
int derived2 = 0;
while (true) {
- if (*n1 == '-') {
- if (memcmp(n1, "-BoldItalic", 11) == 0) { n1 += 11; derived1 = 3; }
- else if (memcmp(n1, "-BoldOblique", 12) == 0) { n1 += 12; derived1 = 3; }
- else if (memcmp(n1, "-Bold", 5) == 0) {n1 += 5; derived1 = 1; }
- else if (memcmp(n1, "-Italic", 7) == 0) {n1 += 7; derived1 = 2; }
- else if (memcmp(n1, "-Oblique", 8) == 0) {n1 += 8; derived1 = 2; }
- }
- if (*n2 == '-') {
- if (memcmp(n2, "-BoldItalic", 11) == 0) {n2 += 11; derived2 = 3; }
- else if (memcmp(n2, "-BoldOblique", 12) == 0) {n2 += 12; derived2 = 3; }
- else if (memcmp(n2, "-Bold", 5) == 0) {n2 += 5; derived2 = 1; }
- else if (memcmp(n2, "-Italic", 7) == 0) {n2 += 7; derived2 = 2; }
- else if (memcmp(n2, "-Oblique", 8) == 0) {n2 += 8; derived2 = 2; }
- }
+ if (*n1 == '-') n1 = skip(n1, derived1);
+ if (*n2 == '-') n2 = skip(n2, derived2);
if (*n1 < *n2) return -1;
if (*n1 > *n2) return +1;
if (*n1 == 0) {