summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2012-05-09 16:33:58 +0100
committerCaolán McNamara <caolanm@redhat.com>2012-05-09 16:37:16 +0100
commitc7a9318f08e08a35f2784bf8d06f62031649b24e (patch)
tree51923a9416b5607ab4eb7d20139251ff2100a3a3 /svtools
parente78b716035c42e4397524c04ff4db83944576bbb (diff)
sort fonts so that upright faces are shown in the font dropdown list
Change font sort so that font faces like those of URW Palladio L whose italic variant is lighter than its upright variant are sorted with the upright fonts first so we don't see italic variants in the font widget. Also sort "normal" weight faces below all other weights Change-Id: I9c81b475d95b9dd17a873fd791b942512ff039c7
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/control/ctrltool.cxx24
1 files changed, 19 insertions, 5 deletions
diff --git a/svtools/source/control/ctrltool.cxx b/svtools/source/control/ctrltool.cxx
index 3fdd51529ece..ffa4fbb92d56 100644
--- a/svtools/source/control/ctrltool.cxx
+++ b/svtools/source/control/ctrltool.cxx
@@ -123,19 +123,33 @@ private:
{}
};
-// =======================================================================
+//sort normal to the start
+static int sortWeightValue(FontWeight eWeight)
+{
+ if (eWeight == WEIGHT_NORMAL)
+ return 0;
+ if (eWeight < WEIGHT_NORMAL)
+ return eWeight + 1;
+ if (eWeight > WEIGHT_NORMAL)
+ return eWeight - 1;
+}
static StringCompare ImplCompareFontInfo( ImplFontListFontInfo* pInfo1,
ImplFontListFontInfo* pInfo2 )
{
- if ( pInfo1->GetWeight() < pInfo2->GetWeight() )
+ //Sort non italic before italics
+ if ( pInfo1->GetItalic() < pInfo2->GetItalic() )
return COMPARE_LESS;
- else if ( pInfo1->GetWeight() > pInfo2->GetWeight() )
+ else if ( pInfo1->GetItalic() > pInfo2->GetItalic() )
return COMPARE_GREATER;
- if ( pInfo1->GetItalic() < pInfo2->GetItalic() )
+ //Sort normal weight to the start, followed by lightest to heaviest weights
+ int nWeight1 = sortWeightValue(pInfo1->GetWeight());
+ int nWeight2 = sortWeightValue(pInfo2->GetWeight());
+
+ if ( nWeight1 < nWeight2 )
return COMPARE_LESS;
- else if ( pInfo1->GetItalic() > pInfo2->GetItalic() )
+ else if ( nWeight1 > nWeight2 )
return COMPARE_GREATER;
return pInfo1->GetStyleName().CompareTo( pInfo2->GetStyleName() );