cosmetic: split PhysicalFontFamily/Collection out of outdev3.cxx
Change-Id: Iae8eb15413c0c069c14edd92c94ecb0113d9d371
This commit is contained in:
parent
7154b092a7
commit
7260bcd687
@ -183,7 +183,9 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
|
||||
vcl/source/filter/wmf/winwmf \
|
||||
vcl/source/filter/wmf/wmf \
|
||||
vcl/source/filter/wmf/wmfwr \
|
||||
vcl/source/font/PhysicalFontCollection \
|
||||
vcl/source/font/PhysicalFontFace \
|
||||
vcl/source/font/PhysicalFontFamily \
|
||||
vcl/source/fontsubset/cff \
|
||||
vcl/source/fontsubset/fontsubset \
|
||||
vcl/source/fontsubset/gsub \
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "salbmp.hxx"
|
||||
#include "impfont.hxx"
|
||||
#include "outdev.h"
|
||||
#include "PhysicalFontCollection.hxx"
|
||||
#include "fontsubset.hxx"
|
||||
#include "salprn.hxx"
|
||||
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "osl/thread.hxx"
|
||||
|
||||
#include "langboost.hxx"
|
||||
#include "PhysicalFontCollection.hxx"
|
||||
#include "sft.hxx"
|
||||
|
||||
#include <ft2build.h>
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "impfont.hxx"
|
||||
#include "langboost.hxx"
|
||||
#include "outfont.hxx"
|
||||
#include "PhysicalFontCollection.hxx"
|
||||
#include "PhysicalFontFace.hxx"
|
||||
#include "salbmp.hxx"
|
||||
#include "salprn.hxx"
|
||||
|
@ -38,6 +38,8 @@
|
||||
#include "outfont.hxx"
|
||||
#include "PhysicalFontFace.hxx"
|
||||
|
||||
class PhysicalFontCollection;
|
||||
|
||||
using namespace basegfx;
|
||||
using namespace basebmp;
|
||||
|
||||
|
90
vcl/inc/PhysicalFontCollection.hxx
Normal file
90
vcl/inc/PhysicalFontCollection.hxx
Normal 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: */
|
84
vcl/inc/PhysicalFontFamily.hxx
Normal file
84
vcl/inc/PhysicalFontFamily.hxx
Normal 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
|
||||
};
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "vclpluginapi.h"
|
||||
|
||||
class PhysicalFontFace;
|
||||
class PhysicalFontCollection;
|
||||
|
||||
namespace psp { struct JobData; class PrinterGfx; }
|
||||
|
||||
|
@ -30,6 +30,7 @@ class GlyphCachePeer;
|
||||
class ServerFontLayoutEngine;
|
||||
class ServerFontLayout;
|
||||
class ImplFontOptions;
|
||||
class PhysicalFontCollection;
|
||||
|
||||
#include <tools/gen.hxx>
|
||||
#include <basebmp/bitmapdevice.hxx>
|
||||
|
23
vcl/inc/magic.h
Normal file
23
vcl/inc/magic.h
Normal 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: */
|
@ -24,6 +24,8 @@
|
||||
#include <set>
|
||||
#include <vector>
|
||||
|
||||
#include <tools/gen.hxx>
|
||||
|
||||
#include "outfont.hxx"
|
||||
#include "PhysicalFontFace.hxx"
|
||||
|
||||
@ -32,56 +34,7 @@ class Font;
|
||||
class VirtualDevice;
|
||||
class ImplGetDevFontList;
|
||||
class GetDevSizeList;
|
||||
|
||||
// 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
|
||||
};
|
||||
|
||||
class PhysicalFontCollection;
|
||||
// an ImplGetDevFontList is created by an PhysicalFontCollection
|
||||
// it becomes invalid when original PhysicalFontCollection is modified
|
||||
class ImplGetDevFontList
|
||||
@ -218,6 +171,9 @@ struct ImplOutDevData
|
||||
basegfx::B2DHomMatrix* mpInverseViewTransform;
|
||||
};
|
||||
|
||||
void ImplFontSubstitute( OUString& rFontName );
|
||||
|
||||
|
||||
#endif // INCLUDED_VCL_INC_OUTDEV_H
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
@ -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 -
|
||||
|
||||
|
||||
|
@ -21,28 +21,25 @@
|
||||
#define INCLUDED_VCL_INC_SALLAYOUT_HXX
|
||||
|
||||
#include <iostream>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
|
||||
#include <tools/gen.hxx>
|
||||
#include <basegfx/polygon/b2dpolypolygon.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
|
||||
typedef unsigned short LanguageType;
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <vcl/dllapi.h>
|
||||
|
||||
// for typedef sal_UCS4
|
||||
#include <vcl/vclenum.hxx>
|
||||
#include "magic.h"
|
||||
#include "salglyphid.hxx"
|
||||
|
||||
class SalGraphics;
|
||||
class PhysicalFontFace;
|
||||
|
||||
#define MAX_FALLBACK 16
|
||||
|
||||
// Layout options
|
||||
#define SAL_LAYOUT_BIDI_RTL 0x0001
|
||||
#define SAL_LAYOUT_BIDI_STRONG 0x0002
|
||||
|
@ -46,6 +46,7 @@ class PspSalInfoPrinter;
|
||||
class ServerFont;
|
||||
class ImplLayoutArgs;
|
||||
class ServerFontLayout;
|
||||
class PhysicalFontCollection;
|
||||
class PhysicalFontFace;
|
||||
|
||||
namespace basegfx {
|
||||
|
@ -39,6 +39,7 @@
|
||||
class FontSelectPattern;
|
||||
class ImplWinFontEntry;
|
||||
class ImplFontAttrCache;
|
||||
class PhysicalFontCollection;
|
||||
|
||||
#define RGB_TO_PALRGB(nRGB) ((nRGB)|0x02000000)
|
||||
#define PALRGB_TO_RGB(nPalRGB) ((nPalRGB)&0x00ffffff)
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "impfont.hxx"
|
||||
#include "outfont.hxx"
|
||||
#include "PhysicalFontCollection.hxx"
|
||||
#include "sallayout.hxx"
|
||||
|
||||
#ifdef MACOSX
|
||||
|
@ -58,6 +58,7 @@
|
||||
#include "idlemgr.hxx"
|
||||
#include "outdev.h"
|
||||
#include "outfont.hxx"
|
||||
#include "PhysicalFontCollection.hxx"
|
||||
#include "print.h"
|
||||
#include "salsys.hxx"
|
||||
#include "saltimer.hxx"
|
||||
|
1362
vcl/source/font/PhysicalFontCollection.cxx
Normal file
1362
vcl/source/font/PhysicalFontCollection.cxx
Normal file
File diff suppressed because it is too large
Load Diff
298
vcl/source/font/PhysicalFontFamily.cxx
Normal file
298
vcl/source/font/PhysicalFontFamily.cxx
Normal 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: */
|
@ -8,23 +8,23 @@
|
||||
*/
|
||||
|
||||
#include <config_folders.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 <config_eot.h>
|
||||
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <fontsubset.hxx>
|
||||
#include <outdev.h>
|
||||
#include <outfont.hxx>
|
||||
#include <salgdi.hxx>
|
||||
#include <osl/file.hxx>
|
||||
#include <rtl/bootstrap.hxx>
|
||||
#include <vcl/outdev.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
|
||||
extern "C"
|
||||
|
@ -43,6 +43,7 @@
|
||||
#include <window.h>
|
||||
#include <outdev.h>
|
||||
#include <outdata.hxx>
|
||||
#include "PhysicalFontCollection.hxx"
|
||||
|
||||
#include <basegfx/point/b2dpoint.hxx>
|
||||
#include <basegfx/vector/b2dvector.hxx>
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -43,6 +43,7 @@
|
||||
#include <svids.hrc>
|
||||
#include <jobset.h>
|
||||
#include <outdev.h>
|
||||
#include "PhysicalFontCollection.hxx"
|
||||
#include <print.h>
|
||||
|
||||
#include <comphelper/processfactory.hxx>
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include <salframe.hxx>
|
||||
#include <salvd.hxx>
|
||||
#include <outdev.h>
|
||||
#include "PhysicalFontCollection.hxx"
|
||||
#include <svdata.hxx>
|
||||
|
||||
using namespace ::com::sun::star::uno;
|
||||
|
@ -68,6 +68,7 @@
|
||||
#include "window.h"
|
||||
#include "toolbox.h"
|
||||
#include "outdev.h"
|
||||
#include "PhysicalFontCollection.hxx"
|
||||
#include "brdwin.hxx"
|
||||
#include "helpwin.hxx"
|
||||
#include "sallayout.hxx"
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "generic/printergfx.hxx"
|
||||
#include "impfont.hxx"
|
||||
#include "outdev.h"
|
||||
#include "PhysicalFontCollection.hxx"
|
||||
#include "PhysicalFontFace.hxx"
|
||||
#include "salframe.hxx"
|
||||
#include "unx/saldata.hxx"
|
||||
|
@ -43,6 +43,7 @@
|
||||
|
||||
#include "fontsubset.hxx"
|
||||
#include "outdev.h"
|
||||
#include "PhysicalFontCollection.hxx"
|
||||
#include "PhysicalFontFace.hxx"
|
||||
#include "sft.hxx"
|
||||
#include "win/saldata.hxx"
|
||||
|
Loading…
x
Reference in New Issue
Block a user