summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2016-05-10 13:34:46 +0200
committerNoel Grandin <noelgrandin@gmail.com>2016-05-11 06:54:05 +0000
commit9e0335d1db22bd3ad3f4bb249b30a00fd55558f4 (patch)
treef5a48783b8b0558b267c018b8856167bdcf7b09f
parenteff219140f5dc81424b3281438dc5ed0a9dd6a9a (diff)
Convert FONT_FAMILY to scoped enum
Change-Id: Id7cc5c76ba45cdd6a06a981ad14e83713cfe5c1a Reviewed-on: https://gerrit.libreoffice.org/24840 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noelgrandin@gmail.com>
-rw-r--r--vcl/inc/PhysicalFontFamily.hxx26
-rw-r--r--vcl/source/font/PhysicalFontCollection.cxx22
-rw-r--r--vcl/source/font/PhysicalFontFamily.cxx18
3 files changed, 36 insertions, 30 deletions
diff --git a/vcl/inc/PhysicalFontFamily.hxx b/vcl/inc/PhysicalFontFamily.hxx
index 0363de3bea6e..07d329c711d9 100644
--- a/vcl/inc/PhysicalFontFamily.hxx
+++ b/vcl/inc/PhysicalFontFamily.hxx
@@ -30,14 +30,20 @@ class PhysicalFontFace;
class PhysicalFontCollection;
// flags for mnTypeFaces member
-#define FONT_FAMILY_SCALABLE (1<<0)
-#define FONT_FAMILY_SYMBOL (1<<1)
-#define FONT_FAMILY_NONESYMBOL (1<<2)
-#define FONT_FAMILY_LIGHT (1<<4)
-#define FONT_FAMILY_BOLD (1<<5)
-#define FONT_FAMILY_NORMAL (1<<6)
-#define FONT_FAMILY_NONEITALIC (1<<8)
-#define FONT_FAMILY_ITALIC (1<<9)
+enum class FontTypeFaces {
+ NONE = 0x00,
+ Scalable = 0x01,
+ Symbol = 0x02,
+ NoneSymbol = 0x04,
+ Light = 0x08,
+ Bold = 0x10,
+ Normal = 0x20,
+ NoneItalic = 0x40,
+ Italic = 0x80
+};
+namespace o3tl {
+ template<> struct typed_flags<FontTypeFaces> : is_typed_flags<FontTypeFaces, 0xff> {};
+};
class PhysicalFontFamily
{
@@ -50,7 +56,7 @@ public:
const OUString& GetAliasNames() const { return maMapNames; }
bool IsScalable() const { return maFontFaces[0]->IsScalable(); }
int GetMinQuality() const { return mnMinQuality; }
- int GetTypeFaces() const { return mnTypeFaces; }
+ FontTypeFaces GetTypeFaces() const { return mnTypeFaces; }
void GetFontHeights( std::set<int>& rHeights ) const;
const OUString& GetMatchFamilyName() const { return maMatchFamilyName; }
@@ -77,7 +83,7 @@ private:
OUString maFamilyName; // original font family name
OUString maSearchName; // normalized font family name
OUString maMapNames; // fontname aliases
- int mnTypeFaces; // Typeface Flags
+ FontTypeFaces mnTypeFaces; // Typeface Flags
FontFamily meFamily;
FontPitch mePitch;
int mnMinQuality; // quality of the worst font face
diff --git a/vcl/source/font/PhysicalFontCollection.cxx b/vcl/source/font/PhysicalFontCollection.cxx
index 10c992ebd680..9bef807eea5e 100644
--- a/vcl/source/font/PhysicalFontCollection.cxx
+++ b/vcl/source/font/PhysicalFontCollection.cxx
@@ -549,7 +549,7 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamilyByAttributes( ImplFont
{
nTestMatch += 10000000*5;
}
- else if ( pData->GetTypeFaces() & FONT_FAMILY_SYMBOL )
+ else if ( pData->GetTypeFaces() & FontTypeFaces::Symbol )
{
nTestMatch += 10000000*4;
}
@@ -561,7 +561,7 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamilyByAttributes( ImplFont
nTestMatch += 10000000;
}
}
- else if ( (pData->GetTypeFaces() & (FONT_FAMILY_SYMBOL | FONT_FAMILY_NONESYMBOL)) == FONT_FAMILY_SYMBOL )
+ else if ( (pData->GetTypeFaces() & (FontTypeFaces::Symbol | FontTypeFaces::NoneSymbol)) == FontTypeFaces::Symbol )
{
nTestMatch -= 10000000;
}
@@ -728,14 +728,14 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamilyByAttributes( ImplFont
// test ITALIC attribute
if( nSearchType & ImplFontAttrs::Italic )
{
- if( pData->GetTypeFaces() & FONT_FAMILY_ITALIC )
+ if( pData->GetTypeFaces() & FontTypeFaces::Italic )
nTestMatch += 1000000*3;
if( nMatchType & ImplFontAttrs::Italic )
nTestMatch += 1000000;
}
else if( !(nSearchType & ImplFontAttrs::AllScript) &&
((nMatchType & ImplFontAttrs::Italic) ||
- !(pData->GetTypeFaces() & FONT_FAMILY_NONEITALIC)) )
+ !(pData->GetTypeFaces() & FontTypeFaces::NoneItalic)) )
{
nTestMatch -= 1000000*2;
}
@@ -770,14 +770,14 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamilyByAttributes( ImplFont
{
if( eSearchWeight < WEIGHT_NORMAL )
{
- if( pData->GetTypeFaces() & FONT_FAMILY_LIGHT )
+ if( pData->GetTypeFaces() & FontTypeFaces::Light )
nTestMatch += 1000000;
if( (eMatchWeight < WEIGHT_NORMAL) && (eMatchWeight != WEIGHT_DONTKNOW) )
nTestMatch += 1000000;
}
else
{
- if( pData->GetTypeFaces() & FONT_FAMILY_BOLD )
+ if( pData->GetTypeFaces() & FontTypeFaces::Bold )
nTestMatch += 1000000;
if( eMatchWeight > WEIGHT_BOLD )
nTestMatch += 1000000;
@@ -786,13 +786,13 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamilyByAttributes( ImplFont
else if( ((eMatchWeight != WEIGHT_DONTKNOW) &&
(eMatchWeight != WEIGHT_NORMAL) &&
(eMatchWeight != WEIGHT_MEDIUM)) ||
- !(pData->GetTypeFaces() & FONT_FAMILY_NORMAL) )
+ !(pData->GetTypeFaces() & FontTypeFaces::Normal) )
{
nTestMatch -= 1000000;
}
// prefer scalable fonts
- if( pData->GetTypeFaces() & FONT_FAMILY_SCALABLE )
+ if( pData->GetTypeFaces() & FontTypeFaces::Scalable )
nTestMatch += 10000*4;
else
nTestMatch -= 10000*4;
@@ -1269,14 +1269,14 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamily( FontSelectPattern& r
// overwrite font selection attributes using info from the typeface flags
if( (eSearchWeight >= WEIGHT_BOLD) &&
(eSearchWeight > rFSD.GetWeight()) &&
- (pFoundData->GetTypeFaces() & FONT_FAMILY_BOLD) )
+ (pFoundData->GetTypeFaces() & FontTypeFaces::Bold) )
{
rFSD.SetWeight( eSearchWeight );
}
else if( (eSearchWeight < WEIGHT_NORMAL) &&
(eSearchWeight < rFSD.GetWeight()) &&
(eSearchWeight != WEIGHT_DONTKNOW) &&
- (pFoundData->GetTypeFaces() & FONT_FAMILY_LIGHT) )
+ (pFoundData->GetTypeFaces() & FontTypeFaces::Light) )
{
rFSD.SetWeight( eSearchWeight );
}
@@ -1284,7 +1284,7 @@ PhysicalFontFamily* PhysicalFontCollection::FindFontFamily( FontSelectPattern& r
if( (nSearchType & ImplFontAttrs::Italic) &&
((rFSD.GetItalic() == ITALIC_DONTKNOW) ||
(rFSD.GetItalic() == ITALIC_NONE)) &&
- (pFoundData->GetTypeFaces() & FONT_FAMILY_ITALIC) )
+ (pFoundData->GetTypeFaces() & FontTypeFaces::Italic) )
{
rFSD.SetItalic( ITALIC_NORMAL );
}
diff --git a/vcl/source/font/PhysicalFontFamily.cxx b/vcl/source/font/PhysicalFontFamily.cxx
index a1382a999d02..e56935c99707 100644
--- a/vcl/source/font/PhysicalFontFamily.cxx
+++ b/vcl/source/font/PhysicalFontFamily.cxx
@@ -87,7 +87,7 @@ static ImplFontAttrs lcl_IsCJKFont( const OUString& rFontName )
PhysicalFontFamily::PhysicalFontFamily( const OUString& rSearchName )
: maSearchName( rSearchName ),
- mnTypeFaces( 0 ),
+ mnTypeFaces( FontTypeFaces::NONE ),
meFamily( FAMILY_DONTKNOW ),
mePitch( PITCH_DONTKNOW ),
mnMinQuality( -1 ),
@@ -129,28 +129,28 @@ bool PhysicalFontFamily::AddFontFace( PhysicalFontFace* pNewFontFace )
// set attributes for attribute based font matching
if( pNewFontFace->IsScalable() )
- mnTypeFaces |= FONT_FAMILY_SCALABLE;
+ mnTypeFaces |= FontTypeFaces::Scalable;
if( pNewFontFace->IsSymbolFont() )
- mnTypeFaces |= FONT_FAMILY_SYMBOL;
+ mnTypeFaces |= FontTypeFaces::Symbol;
else
- mnTypeFaces |= FONT_FAMILY_NONESYMBOL;
+ mnTypeFaces |= FontTypeFaces::NoneSymbol;
if( pNewFontFace->GetWeight() != WEIGHT_DONTKNOW )
{
if( pNewFontFace->GetWeight() >= WEIGHT_SEMIBOLD )
- mnTypeFaces |= FONT_FAMILY_BOLD;
+ mnTypeFaces |= FontTypeFaces::Bold;
else if( pNewFontFace->GetWeight() <= WEIGHT_SEMILIGHT )
- mnTypeFaces |= FONT_FAMILY_LIGHT;
+ mnTypeFaces |= FontTypeFaces::Light;
else
- mnTypeFaces |= FONT_FAMILY_NORMAL;
+ mnTypeFaces |= FontTypeFaces::Normal;
}
if( pNewFontFace->GetItalic() == ITALIC_NONE )
- mnTypeFaces |= FONT_FAMILY_NONEITALIC;
+ mnTypeFaces |= FontTypeFaces::NoneItalic;
else if( (pNewFontFace->GetItalic() == ITALIC_NORMAL)
|| (pNewFontFace->GetItalic() == ITALIC_OBLIQUE) )
- mnTypeFaces |= FONT_FAMILY_ITALIC;
+ mnTypeFaces |= FontTypeFaces::Italic;
// reassign name (sharing saves memory)
if( pNewFontFace->GetFamilyName() == GetFamilyName() )