cosmetic: split PhysicalFontFamily/Collection out of outdev3.cxx

Change-Id: Iae8eb15413c0c069c14edd92c94ecb0113d9d371
This commit is contained in:
Norbert Thiebaud 2014-03-20 00:22:26 -05:00
parent 7154b092a7
commit 7260bcd687
27 changed files with 1909 additions and 1601 deletions

View File

@ -183,7 +183,9 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/filter/wmf/winwmf \ vcl/source/filter/wmf/winwmf \
vcl/source/filter/wmf/wmf \ vcl/source/filter/wmf/wmf \
vcl/source/filter/wmf/wmfwr \ vcl/source/filter/wmf/wmfwr \
vcl/source/font/PhysicalFontCollection \
vcl/source/font/PhysicalFontFace \ vcl/source/font/PhysicalFontFace \
vcl/source/font/PhysicalFontFamily \
vcl/source/fontsubset/cff \ vcl/source/fontsubset/cff \
vcl/source/fontsubset/fontsubset \ vcl/source/fontsubset/fontsubset \
vcl/source/fontsubset/gsub \ vcl/source/fontsubset/gsub \

View File

@ -28,6 +28,7 @@
#include "salbmp.hxx" #include "salbmp.hxx"
#include "impfont.hxx" #include "impfont.hxx"
#include "outdev.h" #include "outdev.h"
#include "PhysicalFontCollection.hxx"
#include "fontsubset.hxx" #include "fontsubset.hxx"
#include "salprn.hxx" #include "salprn.hxx"

View File

@ -41,6 +41,7 @@
#include "osl/thread.hxx" #include "osl/thread.hxx"
#include "langboost.hxx" #include "langboost.hxx"
#include "PhysicalFontCollection.hxx"
#include "sft.hxx" #include "sft.hxx"
#include <ft2build.h> #include <ft2build.h>

View File

@ -45,6 +45,7 @@
#include "impfont.hxx" #include "impfont.hxx"
#include "langboost.hxx" #include "langboost.hxx"
#include "outfont.hxx" #include "outfont.hxx"
#include "PhysicalFontCollection.hxx"
#include "PhysicalFontFace.hxx" #include "PhysicalFontFace.hxx"
#include "salbmp.hxx" #include "salbmp.hxx"
#include "salprn.hxx" #include "salprn.hxx"

View File

@ -38,6 +38,8 @@
#include "outfont.hxx" #include "outfont.hxx"
#include "PhysicalFontFace.hxx" #include "PhysicalFontFace.hxx"
class PhysicalFontCollection;
using namespace basegfx; using namespace basegfx;
using namespace basebmp; using namespace basebmp;

View File

@ -0,0 +1,90 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#pragma once
#include <vcl/dllapi.h>
#include "outfont.hxx"
#include "PhysicalFontFamily.hxx"
// - PhysicalFontCollection -
// TODO: merge with ImplFontCache
// TODO: rename to LogicalFontManager
class VCL_PLUGIN_PUBLIC PhysicalFontCollection
{
private:
friend class WinGlyphFallbackSubstititution;
mutable bool mbMatchData; // true if matching attributes are initialized
bool mbMapNames; // true if MapNames are available
typedef boost::unordered_map<const OUString, PhysicalFontFamily*,FontNameHash> PhysicalFontFamilies;
PhysicalFontFamilies maPhysicalFontFamilies;
ImplPreMatchFontSubstitution* mpPreMatchHook; // device specific prematch substitution
ImplGlyphFallbackFontSubstitution* mpFallbackHook; // device specific glyh fallback substitution
public:
explicit PhysicalFontCollection();
virtual ~PhysicalFontCollection();
// fill the list with device fonts
void Add( PhysicalFontFace* );
void Clear();
int Count() const { return maPhysicalFontFamilies.size(); }
// find the device font
PhysicalFontFamily* FindFontFamily( const OUString& rFontName ) const;
PhysicalFontFamily* ImplFindByFont( FontSelectPattern& ) const;
PhysicalFontFamily* ImplFindBySearchName( const OUString& ) const;
// suggest fonts for glyph fallback
PhysicalFontFamily* GetGlyphFallbackFont( FontSelectPattern&,
OUString& rMissingCodes, int nFallbackLevel ) const;
// prepare platform specific font substitutions
void SetPreMatchHook( ImplPreMatchFontSubstitution* );
void SetFallbackHook( ImplGlyphFallbackFontSubstitution* );
// misc utilities
PhysicalFontCollection* Clone( bool bScalable, bool bEmbeddable ) const;
ImplGetDevFontList* GetDevFontList() const;
ImplGetDevSizeList* GetDevSizeList( const OUString& rFontName ) const;
PhysicalFontFamily* ImplFindByTokenNames(const OUString& rTokenStr) const;
protected:
void InitMatchData() const;
bool AreMapNamesAvailable() const { return mbMapNames; }
PhysicalFontFamily* ImplFindByAliasName(const OUString& rSearchName,
const OUString& rShortName) const;
PhysicalFontFamily* ImplFindBySubstFontAttr( const utl::FontNameAttr& ) const;
PhysicalFontFamily* ImplFindByAttributes(sal_uLong nSearchType, FontWeight, FontWidth,
FontItalic, const OUString& rSearchFamily) const;
PhysicalFontFamily* FindDefaultFont() const;
private:
void InitGenericGlyphFallback() const;
mutable PhysicalFontFamily** mpFallbackList;
mutable int mnFallbackCount;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -0,0 +1,84 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#pragma once
#include <set>
#include <unotools/fontcfg.hxx>
#include "PhysicalFontFace.hxx"
#include "PhysicalFontFamily.hxx"
class PhysicalFontFace;
class PhysicalFontCollection;
// flags for mnMatchType 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)
class PhysicalFontFamily
{
public:
PhysicalFontFamily( const OUString& rSearchName );
~PhysicalFontFamily();
const OUString& GetFamilyName() const { return maName; }
const OUString& GetSearchName() const { return maSearchName; }
const OUString& GetAliasNames() const { return maMapNames; }
const OUString& GetMatchFamilyName() const { return maMatchFamilyName; }
sal_uLong GetMatchType() const { return mnMatchType ; }
FontWeight GetMatchWeight() const { return meMatchWeight ; }
FontWidth GetMatchWidth() const { return meMatchWidth ; }
bool IsScalable() const { return mpFirst->IsScalable(); }
int GetMinQuality() const { return mnMinQuality; }
int GetTypeFaces() const { return mnTypeFaces; }
bool AddFontFace( PhysicalFontFace* );
void InitMatchData( const utl::FontSubstConfiguration&,
const OUString& rSearchName );
PhysicalFontFace* FindBestFontFace( const FontSelectPattern& rFSD ) const;
void GetFontHeights( std::set<int>& rHeights ) const;
void UpdateDevFontList( ImplGetDevFontList& ) const;
void UpdateCloneFontList( PhysicalFontCollection&,
bool bScalable, bool bEmbeddable ) const;
static void CalcType( sal_uLong& rType, FontWeight& rWeight, FontWidth& rWidth,
FontFamily eFamily, const utl::FontNameAttr* pFontAttr );
private:
PhysicalFontFace* mpFirst; // linked list of physical font faces
OUString maName; // Fontname (original font family name)
OUString maSearchName; // normalized font family name
OUString maMapNames; // fontname aliases
int mnTypeFaces; // Typeface Flags
sal_uLong mnMatchType; // MATCH - Type
OUString maMatchFamilyName; // MATCH - FamilyName
FontWeight meMatchWeight; // MATCH - Weight
FontWidth meMatchWidth; // MATCH - Width
FontFamily meFamily;
FontPitch mePitch;
int mnMinQuality; // quality of the worst font face
};

View File

@ -29,6 +29,7 @@
#include "vclpluginapi.h" #include "vclpluginapi.h"
class PhysicalFontFace; class PhysicalFontFace;
class PhysicalFontCollection;
namespace psp { struct JobData; class PrinterGfx; } namespace psp { struct JobData; class PrinterGfx; }

View File

@ -30,6 +30,7 @@ class GlyphCachePeer;
class ServerFontLayoutEngine; class ServerFontLayoutEngine;
class ServerFontLayout; class ServerFontLayout;
class ImplFontOptions; class ImplFontOptions;
class PhysicalFontCollection;
#include <tools/gen.hxx> #include <tools/gen.hxx>
#include <basebmp/bitmapdevice.hxx> #include <basebmp/bitmapdevice.hxx>

23
vcl/inc/magic.h Normal file
View File

@ -0,0 +1,23 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#pragma once
#define MAX_FALLBACK 16
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -24,6 +24,8 @@
#include <set> #include <set>
#include <vector> #include <vector>
#include <tools/gen.hxx>
#include "outfont.hxx" #include "outfont.hxx"
#include "PhysicalFontFace.hxx" #include "PhysicalFontFace.hxx"
@ -32,56 +34,7 @@ class Font;
class VirtualDevice; class VirtualDevice;
class ImplGetDevFontList; class ImplGetDevFontList;
class GetDevSizeList; class GetDevSizeList;
class PhysicalFontCollection;
// flags for mnMatchType member
#define IMPL_DEVFONT_SCALABLE ((sal_uIntPtr)0x00000001)
#define IMPL_DEVFONT_SYMBOL ((sal_uIntPtr)0x00000002)
#define IMPL_DEVFONT_NONESYMBOL ((sal_uIntPtr)0x00000004)
#define IMPL_DEVFONT_LIGHT ((sal_uIntPtr)0x00000010)
#define IMPL_DEVFONT_BOLD ((sal_uIntPtr)0x00000020)
#define IMPL_DEVFONT_NORMAL ((sal_uIntPtr)0x00000040)
#define IMPL_DEVFONT_NONEITALIC ((sal_uIntPtr)0x00000100)
#define IMPL_DEVFONT_ITALIC ((sal_uIntPtr)0x00000200)
class PhysicalFontFamily
{
public:
PhysicalFontFamily( const OUString& rSearchName );
~PhysicalFontFamily();
const OUString& GetFamilyName() const { return maName; }
const OUString& GetSearchName() const { return maSearchName; }
const OUString& GetAliasNames() const { return maMapNames; }
bool IsScalable() const { return mpFirst->IsScalable(); }
int GetMinQuality() const { return mnMinQuality; }
bool AddFontFace( PhysicalFontFace* );
void InitMatchData( const utl::FontSubstConfiguration&,
const OUString& rSearchName );
PhysicalFontFace* FindBestFontFace( const FontSelectPattern& rFSD ) const;
void GetFontHeights( std::set<int>& rHeights ) const;
void UpdateDevFontList( ImplGetDevFontList& ) const;
void UpdateCloneFontList( PhysicalFontCollection&,
bool bScalable, bool bEmbeddable ) const;
private:
friend class PhysicalFontCollection; // TODO: remove soon
PhysicalFontFace* mpFirst; // linked list of physical font faces
OUString maName; // Fontname (original font family name)
OUString maSearchName; // normalized font family name
OUString maMapNames; // fontname aliases
sal_uIntPtr mnTypeFaces; // Typeface Flags
sal_uIntPtr mnMatchType; // MATCH - Type
OUString maMatchFamilyName; // MATCH - FamilyName
FontWeight meMatchWeight; // MATCH - Weight
FontWidth meMatchWidth; // MATCH - Width
FontFamily meFamily;
FontPitch mePitch;
int mnMinQuality; // quality of the worst font face
};
// an ImplGetDevFontList is created by an PhysicalFontCollection // an ImplGetDevFontList is created by an PhysicalFontCollection
// it becomes invalid when original PhysicalFontCollection is modified // it becomes invalid when original PhysicalFontCollection is modified
class ImplGetDevFontList class ImplGetDevFontList
@ -218,6 +171,9 @@ struct ImplOutDevData
basegfx::B2DHomMatrix* mpInverseViewTransform; basegfx::B2DHomMatrix* mpInverseViewTransform;
}; };
void ImplFontSubstitute( OUString& rFontName );
#endif // INCLUDED_VCL_INC_OUTDEV_H #endif // INCLUDED_VCL_INC_OUTDEV_H
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -161,71 +161,6 @@ public: // TODO: change to private
}; };
// - PhysicalFontCollection -
// TODO: merge with ImplFontCache
// TODO: rename to LogicalFontManager
class VCL_PLUGIN_PUBLIC PhysicalFontCollection
{
private:
friend class WinGlyphFallbackSubstititution;
mutable bool mbMatchData; // true if matching attributes are initialized
bool mbMapNames; // true if MapNames are available
typedef boost::unordered_map<const OUString, PhysicalFontFamily*,FontNameHash> PhysicalFontFamilies;
PhysicalFontFamilies maPhysicalFontFamilies;
ImplPreMatchFontSubstitution* mpPreMatchHook; // device specific prematch substitution
ImplGlyphFallbackFontSubstitution* mpFallbackHook; // device specific glyh fallback substitution
public:
explicit PhysicalFontCollection();
virtual ~PhysicalFontCollection();
// fill the list with device fonts
void Add( PhysicalFontFace* );
void Clear();
int Count() const { return maPhysicalFontFamilies.size(); }
// find the device font
PhysicalFontFamily* FindFontFamily( const OUString& rFontName ) const;
PhysicalFontFamily* ImplFindByFont( FontSelectPattern& ) const;
PhysicalFontFamily* ImplFindBySearchName( const OUString& ) const;
// suggest fonts for glyph fallback
PhysicalFontFamily* GetGlyphFallbackFont( FontSelectPattern&,
OUString& rMissingCodes, int nFallbackLevel ) const;
// prepare platform specific font substitutions
void SetPreMatchHook( ImplPreMatchFontSubstitution* );
void SetFallbackHook( ImplGlyphFallbackFontSubstitution* );
// misc utilities
PhysicalFontCollection* Clone( bool bScalable, bool bEmbeddable ) const;
ImplGetDevFontList* GetDevFontList() const;
ImplGetDevSizeList* GetDevSizeList( const OUString& rFontName ) const;
PhysicalFontFamily* ImplFindByTokenNames(const OUString& rTokenStr) const;
protected:
void InitMatchData() const;
bool AreMapNamesAvailable() const { return mbMapNames; }
PhysicalFontFamily* ImplFindByAliasName(const OUString& rSearchName,
const OUString& rShortName) const;
PhysicalFontFamily* ImplFindBySubstFontAttr( const utl::FontNameAttr& ) const;
PhysicalFontFamily* ImplFindByAttributes(sal_uLong nSearchType, FontWeight, FontWidth,
FontItalic, const OUString& rSearchFamily) const;
PhysicalFontFamily* FindDefaultFont() const;
private:
void InitGenericGlyphFallback() const;
mutable PhysicalFontFamily** mpFallbackList;
mutable int mnFallbackCount;
};
// - ImplFontMetricData - // - ImplFontMetricData -

View File

@ -21,28 +21,25 @@
#define INCLUDED_VCL_INC_SALLAYOUT_HXX #define INCLUDED_VCL_INC_SALLAYOUT_HXX
#include <iostream> #include <iostream>
#include <list>
#include <vector>
#include <tools/gen.hxx>
#include <basegfx/polygon/b2dpolypolygon.hxx> #include <basegfx/polygon/b2dpolypolygon.hxx>
#include <i18nlangtag/languagetag.hxx> #include <i18nlangtag/languagetag.hxx>
#include <tools/gen.hxx>
#include <vcl/dllapi.h>
#include <vcl/vclenum.hxx> // for typedef sal_UCS4
#ifndef _TOOLS_LANG_HXX #ifndef _TOOLS_LANG_HXX
typedef unsigned short LanguageType; typedef unsigned short LanguageType;
#endif #endif
#include <vector> #include "magic.h"
#include <list>
#include <vcl/dllapi.h>
// for typedef sal_UCS4
#include <vcl/vclenum.hxx>
#include "salglyphid.hxx" #include "salglyphid.hxx"
class SalGraphics; class SalGraphics;
class PhysicalFontFace; class PhysicalFontFace;
#define MAX_FALLBACK 16
// Layout options // Layout options
#define SAL_LAYOUT_BIDI_RTL 0x0001 #define SAL_LAYOUT_BIDI_RTL 0x0001
#define SAL_LAYOUT_BIDI_STRONG 0x0002 #define SAL_LAYOUT_BIDI_STRONG 0x0002

View File

@ -46,6 +46,7 @@ class PspSalInfoPrinter;
class ServerFont; class ServerFont;
class ImplLayoutArgs; class ImplLayoutArgs;
class ServerFontLayout; class ServerFontLayout;
class PhysicalFontCollection;
class PhysicalFontFace; class PhysicalFontFace;
namespace basegfx { namespace basegfx {

View File

@ -39,6 +39,7 @@
class FontSelectPattern; class FontSelectPattern;
class ImplWinFontEntry; class ImplWinFontEntry;
class ImplFontAttrCache; class ImplFontAttrCache;
class PhysicalFontCollection;
#define RGB_TO_PALRGB(nRGB) ((nRGB)|0x02000000) #define RGB_TO_PALRGB(nRGB) ((nRGB)|0x02000000)
#define PALRGB_TO_RGB(nPalRGB) ((nPalRGB)&0x00ffffff) #define PALRGB_TO_RGB(nPalRGB) ((nPalRGB)&0x00ffffff)

View File

@ -21,6 +21,7 @@
#include "impfont.hxx" #include "impfont.hxx"
#include "outfont.hxx" #include "outfont.hxx"
#include "PhysicalFontCollection.hxx"
#include "sallayout.hxx" #include "sallayout.hxx"
#ifdef MACOSX #ifdef MACOSX

View File

@ -58,6 +58,7 @@
#include "idlemgr.hxx" #include "idlemgr.hxx"
#include "outdev.h" #include "outdev.h"
#include "outfont.hxx" #include "outfont.hxx"
#include "PhysicalFontCollection.hxx"
#include "print.h" #include "print.h"
#include "salsys.hxx" #include "salsys.hxx"
#include "saltimer.hxx" #include "saltimer.hxx"

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,298 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <sal/types.h>
#include <rtl/ustring.hxx>
#include "outdev.h"
#include "PhysicalFontFace.hxx"
#include "PhysicalFontCollection.hxx"
#include "PhysicalFontFamily.hxx"
void PhysicalFontFamily::CalcType( sal_uLong& rType, FontWeight& rWeight, FontWidth& rWidth,
FontFamily eFamily, const utl::FontNameAttr* pFontAttr )
{
if ( eFamily != FAMILY_DONTKNOW )
{
if ( eFamily == FAMILY_SWISS )
rType |= IMPL_FONT_ATTR_SANSSERIF;
else if ( eFamily == FAMILY_ROMAN )
rType |= IMPL_FONT_ATTR_SERIF;
else if ( eFamily == FAMILY_SCRIPT )
rType |= IMPL_FONT_ATTR_SCRIPT;
else if ( eFamily == FAMILY_MODERN )
rType |= IMPL_FONT_ATTR_FIXED;
else if ( eFamily == FAMILY_DECORATIVE )
rType |= IMPL_FONT_ATTR_DECORATIVE;
}
if ( pFontAttr )
{
rType |= pFontAttr->Type;
if ( ((rWeight == WEIGHT_DONTKNOW) || (rWeight == WEIGHT_NORMAL)) &&
(pFontAttr->Weight != WEIGHT_DONTKNOW) )
rWeight = pFontAttr->Weight;
if ( ((rWidth == WIDTH_DONTKNOW) || (rWidth == WIDTH_NORMAL)) &&
(pFontAttr->Width != WIDTH_DONTKNOW) )
rWidth = pFontAttr->Width;
}
}
static unsigned lcl_IsCJKFont( const OUString& rFontName )
{
// Test, if Fontname includes CJK characters --> In this case we
// mention that it is a CJK font
for(int i = 0; i < rFontName.getLength(); i++)
{
const sal_Unicode ch = rFontName[i];
// japanese
if ( ((ch >= 0x3040) && (ch <= 0x30FF)) ||
((ch >= 0x3190) && (ch <= 0x319F)) )
return IMPL_FONT_ATTR_CJK|IMPL_FONT_ATTR_CJK_JP;
// korean
if ( ((ch >= 0xAC00) && (ch <= 0xD7AF)) ||
((ch >= 0x3130) && (ch <= 0x318F)) ||
((ch >= 0x1100) && (ch <= 0x11FF)) )
return IMPL_FONT_ATTR_CJK|IMPL_FONT_ATTR_CJK_KR;
// chinese
if ( ((ch >= 0x3400) && (ch <= 0x9FFF)) )
return IMPL_FONT_ATTR_CJK|IMPL_FONT_ATTR_CJK_TC|IMPL_FONT_ATTR_CJK_SC;
// cjk
if ( ((ch >= 0x3000) && (ch <= 0xD7AF)) ||
((ch >= 0xFF00) && (ch <= 0xFFEE)) )
return IMPL_FONT_ATTR_CJK;
}
return 0;
}
PhysicalFontFamily::PhysicalFontFamily( const OUString& rSearchName )
: mpFirst( NULL ),
maSearchName( rSearchName ),
mnTypeFaces( 0 ),
mnMatchType( 0 ),
meMatchWeight( WEIGHT_DONTKNOW ),
meMatchWidth( WIDTH_DONTKNOW ),
meFamily( FAMILY_DONTKNOW ),
mePitch( PITCH_DONTKNOW ),
mnMinQuality( -1 )
{}
PhysicalFontFamily::~PhysicalFontFamily()
{
// release all physical font faces
while( mpFirst )
{
PhysicalFontFace* pFace = mpFirst;
mpFirst = pFace->GetNextFace();
delete pFace;
}
}
bool PhysicalFontFamily::AddFontFace( PhysicalFontFace* pNewData )
{
pNewData->mpNext = NULL;
if( !mpFirst )
{
maName = pNewData->GetFamilyName();
maMapNames = pNewData->maMapNames;
meFamily = pNewData->GetFamilyType();
mePitch = pNewData->GetPitch();
mnMinQuality = pNewData->mnQuality;
}
else
{
if( meFamily == FAMILY_DONTKNOW )
meFamily = pNewData->GetFamilyType();
if( mePitch == PITCH_DONTKNOW )
mePitch = pNewData->GetPitch();
if( mnMinQuality > pNewData->mnQuality )
mnMinQuality = pNewData->mnQuality;
}
// set attributes for attribute based font matching
if( pNewData->IsScalable() )
mnTypeFaces |= FONT_FAMILY_SCALABLE;
if( pNewData->IsSymbolFont() )
mnTypeFaces |= FONT_FAMILY_SYMBOL;
else
mnTypeFaces |= FONT_FAMILY_NONESYMBOL;
if( pNewData->GetWeight() != WEIGHT_DONTKNOW )
{
if( pNewData->GetWeight() >= WEIGHT_SEMIBOLD )
mnTypeFaces |= FONT_FAMILY_BOLD;
else if( pNewData->GetWeight() <= WEIGHT_SEMILIGHT )
mnTypeFaces |= FONT_FAMILY_LIGHT;
else
mnTypeFaces |= FONT_FAMILY_NORMAL;
}
if( pNewData->GetSlant() == ITALIC_NONE )
mnTypeFaces |= FONT_FAMILY_NONEITALIC;
else if( (pNewData->GetSlant() == ITALIC_NORMAL)
|| (pNewData->GetSlant() == ITALIC_OBLIQUE) )
mnTypeFaces |= FONT_FAMILY_ITALIC;
if( (meMatchWeight == WEIGHT_DONTKNOW)
|| (meMatchWidth == WIDTH_DONTKNOW)
|| (mnMatchType == 0) )
{
// TODO: is it cheaper to calc matching attributes now or on demand?
// calc matching attributes if other entries are already initialized
// Do lazy, quite expensive, not needed in start-up!
// const FontSubstConfiguration& rFontSubst = *FontSubstConfiguration::get();
// InitMatchData( rFontSubst, maSearchName );
// mbMatchData=true; // Somewhere else???
}
// reassign name (sharing saves memory)
if( pNewData->GetFamilyName() == GetFamilyName() )
pNewData->SetFamilyName( GetFamilyName() );
// insert new physical font face into linked list
// TODO: get rid of linear search?
PhysicalFontFace* pData;
PhysicalFontFace** ppHere = &mpFirst;
for(; (pData=*ppHere) != NULL; ppHere=&pData->mpNext )
{
sal_Int32 eComp = pNewData->CompareWithSize( *pData );
if( eComp > 0 )
continue;
if( eComp < 0 )
break;
// ignore duplicate if its quality is worse
if( pNewData->mnQuality < pData->mnQuality )
return false;
// keep the device font if its quality is good enough
if( (pNewData->mnQuality == pData->mnQuality)
&& (pData->mbDevice || !pNewData->mbDevice) )
return false;
// replace existing font face with a better one
pNewData->mpNext = pData->mpNext;
*ppHere = pNewData;
delete pData;
return true;
}
// insert into or append to list of physical font faces
pNewData->mpNext = pData;
*ppHere = pNewData;
return true;
}
// get font attributes using the normalized font family name
void PhysicalFontFamily::InitMatchData( const utl::FontSubstConfiguration& rFontSubst,
const OUString& rSearchName )
{
OUString aShortName;
OUString aMatchFamilyName(maMatchFamilyName);
// get font attributes from the decorated font name
rFontSubst.getMapName( rSearchName, aShortName, aMatchFamilyName,
meMatchWeight, meMatchWidth, mnMatchType );
maMatchFamilyName = aMatchFamilyName;
const utl::FontNameAttr* pFontAttr = rFontSubst.getSubstInfo( rSearchName );
// eventually use the stripped name
if( !pFontAttr )
if( aShortName != rSearchName )
pFontAttr = rFontSubst.getSubstInfo( aShortName );
CalcType( mnMatchType, meMatchWeight, meMatchWidth, meFamily, pFontAttr );
mnMatchType |= lcl_IsCJKFont( maName );
}
PhysicalFontFace* PhysicalFontFamily::FindBestFontFace( const FontSelectPattern& rFSD ) const
{
if( !mpFirst )
return NULL;
if( !mpFirst->GetNextFace() )
return mpFirst;
// FontName+StyleName should map to FamilyName+StyleName
const OUString& rSearchName = rFSD.maTargetName;
OUString aTargetStyleName;
const OUString* pTargetStyleName = NULL;
if( (rSearchName.getLength() > maSearchName.getLength())
&& rSearchName.startsWith( maSearchName ) )
{
aTargetStyleName = rSearchName.copy(maSearchName.getLength() + 1);
pTargetStyleName = &aTargetStyleName;
}
// TODO: linear search improve!
PhysicalFontFace* pFontFace = mpFirst;
PhysicalFontFace* pBestFontFace = pFontFace;
FontMatchStatus aFontMatchStatus = {0,0,0, pTargetStyleName};
for(; pFontFace; pFontFace = pFontFace->GetNextFace() )
if( pFontFace->IsBetterMatch( rFSD, aFontMatchStatus ) )
pBestFontFace = pFontFace;
return pBestFontFace;
}
// update device font list with unique font faces, with uniqueness
// meaning different font attributes, but not different fonts sizes
void PhysicalFontFamily::UpdateDevFontList( ImplGetDevFontList& rDevFontList ) const
{
PhysicalFontFace* pPrevFace = NULL;
for( PhysicalFontFace* pFace = mpFirst; pFace; pFace = pFace->GetNextFace() )
{
if( !pPrevFace || pFace->CompareIgnoreSize( *pPrevFace ) )
rDevFontList.Add( pFace );
pPrevFace = pFace;
}
}
void PhysicalFontFamily::GetFontHeights( std::set<int>& rHeights ) const
{
// add all available font heights
for( const PhysicalFontFace* pFace = mpFirst; pFace; pFace = pFace->GetNextFace() )
rHeights.insert( pFace->GetHeight() );
}
void PhysicalFontFamily::UpdateCloneFontList( PhysicalFontCollection& rFontCollection,
bool bScalable, bool bEmbeddable ) const
{
for( PhysicalFontFace* pFace = mpFirst; pFace; pFace = pFace->GetNextFace() )
{
if( bScalable && !pFace->IsScalable() )
continue;
if( bEmbeddable && !pFace->IsEmbeddable() && !pFace->IsSubsettable() )
continue;
PhysicalFontFace* pClonedFace = pFace->Clone();
rFontCollection.Add( pClonedFace );
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -8,23 +8,23 @@
*/ */
#include <config_folders.h> #include <config_folders.h>
#include <config_eot.h>
#include <vcl/embeddedfontshelper.hxx>
#include <osl/file.hxx>
#include <rtl/bootstrap.hxx>
#include <sft.hxx>
#include <vcl/outdev.hxx>
#include <vcl/svapp.hxx>
#include <boost/scoped_ptr.hpp> #include <boost/scoped_ptr.hpp>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <fontsubset.hxx> #include <osl/file.hxx>
#include <outdev.h> #include <rtl/bootstrap.hxx>
#include <outfont.hxx> #include <vcl/outdev.hxx>
#include <salgdi.hxx> #include <vcl/svapp.hxx>
#include <config_eot.h> #include "fontsubset.hxx"
#include "outdev.h"
#include "outfont.hxx"
#include "PhysicalFontCollection.hxx"
#include "salgdi.hxx"
#include "sft.hxx"
#include <vcl/embeddedfontshelper.hxx>
#if ENABLE_EOT #if ENABLE_EOT
extern "C" extern "C"

View File

@ -43,6 +43,7 @@
#include <window.h> #include <window.h>
#include <outdev.h> #include <outdev.h>
#include <outdata.hxx> #include <outdata.hxx>
#include "PhysicalFontCollection.hxx"
#include <basegfx/point/b2dpoint.hxx> #include <basegfx/point/b2dpoint.hxx>
#include <basegfx/vector/b2dvector.hxx> #include <basegfx/vector/b2dvector.hxx>

File diff suppressed because it is too large Load Diff

View File

@ -43,6 +43,7 @@
#include <svids.hrc> #include <svids.hrc>
#include <jobset.h> #include <jobset.h>
#include <outdev.h> #include <outdev.h>
#include "PhysicalFontCollection.hxx"
#include <print.h> #include <print.h>
#include <comphelper/processfactory.hxx> #include <comphelper/processfactory.hxx>

View File

@ -30,6 +30,7 @@
#include <salframe.hxx> #include <salframe.hxx>
#include <salvd.hxx> #include <salvd.hxx>
#include <outdev.h> #include <outdev.h>
#include "PhysicalFontCollection.hxx"
#include <svdata.hxx> #include <svdata.hxx>
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;

View File

@ -68,6 +68,7 @@
#include "window.h" #include "window.h"
#include "toolbox.h" #include "toolbox.h"
#include "outdev.h" #include "outdev.h"
#include "PhysicalFontCollection.hxx"
#include "brdwin.hxx" #include "brdwin.hxx"
#include "helpwin.hxx" #include "helpwin.hxx"
#include "sallayout.hxx" #include "sallayout.hxx"

View File

@ -50,6 +50,7 @@
#include "generic/printergfx.hxx" #include "generic/printergfx.hxx"
#include "impfont.hxx" #include "impfont.hxx"
#include "outdev.h" #include "outdev.h"
#include "PhysicalFontCollection.hxx"
#include "PhysicalFontFace.hxx" #include "PhysicalFontFace.hxx"
#include "salframe.hxx" #include "salframe.hxx"
#include "unx/saldata.hxx" #include "unx/saldata.hxx"

View File

@ -43,6 +43,7 @@
#include "fontsubset.hxx" #include "fontsubset.hxx"
#include "outdev.h" #include "outdev.h"
#include "PhysicalFontCollection.hxx"
#include "PhysicalFontFace.hxx" #include "PhysicalFontFace.hxx"
#include "sft.hxx" #include "sft.hxx"
#include "win/saldata.hxx" #include "win/saldata.hxx"