[Libreoffice-commits] core.git: vcl/inc vcl/source
Noel Grandin
noel at peralex.com
Wed May 11 06:54:38 UTC 2016
vcl/inc/PhysicalFontFamily.hxx | 26 ++++++++++++++++----------
vcl/source/font/PhysicalFontCollection.cxx | 22 +++++++++++-----------
vcl/source/font/PhysicalFontFamily.cxx | 18 +++++++++---------
3 files changed, 36 insertions(+), 30 deletions(-)
New commits:
commit 9e0335d1db22bd3ad3f4bb249b30a00fd55558f4
Author: Noel Grandin <noel at peralex.com>
Date: Tue May 10 13:34:46 2016 +0200
Convert FONT_FAMILY to scoped enum
Change-Id: Id7cc5c76ba45cdd6a06a981ad14e83713cfe5c1a
Reviewed-on: https://gerrit.libreoffice.org/24840
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noelgrandin at gmail.com>
diff --git a/vcl/inc/PhysicalFontFamily.hxx b/vcl/inc/PhysicalFontFamily.hxx
index 0363de3..07d329c 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 10c992e..9bef807 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 a1382a9..e56935c 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() )
More information about the Libreoffice-commits
mailing list