1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #include <config_options.h>
23 #include <svtools/svtdllapi.h>
24 #include <rtl/ustring.hxx>
25 #include <sal/types.h>
26 #include <vcl/metric.hxx>
27 #include <vcl/vclptr.hxx>
33 class ImplFontListNameInfo
;
43 This class manages all fonts which can be display on one or two output devices.
44 Additionally, this class offers methods for generating the StyleName from
45 bold and italics or the missing attributes from a StyleName.
46 Furthermore, this class can handle synthetically reproduced fonts.
47 It also works with several standard controls and standard menus.
51 class FontNameBox, class FontStyleBox, class FontSizeBox,
52 class FontNameMenu, class FontSizeMenu
54 --------------------------------------------------------------------------
56 FontList::FontList( OutputDevice* pDevice, OutputDevice* pDevice2 = NULL,
59 Constructor of the FontList class. The relevant fonts will be queried from
60 the OutputDevice. The OutputDevice needs to exist as long as the FontList
61 class exists. Optionally, a second output device can be given in order to,
62 e.g., manage the fonts from both, a printer and a screen in a single FontList
63 and thus also give FontMenus the fonts if both OutputDevices.
64 The pDevice2 needs to exist as long as the FontList class exists.
66 The OutputDevice given first should be the preferred one. This is usually
67 the printer. Because if two different device fonts (one for the printer and
68 one for the screen) exist, the ones from the "pDevice" are preferred.
70 The third parameter governs whether only scalable or all fonts shall be queried.
71 With sal_True bitmap fonts will also be queried.
72 With sal_False vectorized and scalable fonts will be queried.
74 --------------------------------------------------------------------------
76 String FontList::GetStyleName( const FontMetric& rFontMetric ) const;
78 This method returns the StyleName of a FontMetric.
79 If no StyleName is set, a name will be generated from the set attributes.
81 --------------------------------------------------------------------------
83 OUString FontList::GetFontMapText( const FontMetric& rFontMetric ) const;
85 This method returns a Matchstring which indicates the problem that could
86 arise when using a font. This string should be displayed to the user.
88 --------------------------------------------------------------------------
90 FontMetric FontList::Get( const String& rName, const String& rStyleName ) const;
92 This method search a FontMetric for the given name and the given style name.
93 The Stylename can also be a synthetic one.
94 In that case the relevant FontMetric fields will be set.
95 If a StyleName is provided, a FontMetric structure without a Stylename can be
96 returned. To get a representation of the StyleName for displaying it to the user,
97 call GetStyleName() on this FontMetric structure.
101 FontList::GetStyleName()
103 --------------------------------------------------------------------------
105 FontMetric FontList::Get( const String& rName, FontWeight eWeight,
106 FontItalic eItalic ) const;
108 This method search a FontMetric structure for a provided name and styles.
109 This method can also return a FontMetric without a Stylename.
110 To get a representation of the StyleName to be presented to the user
111 call GetStyleName() with this FontMetric.
115 FontList::GetStyleName()
117 --------------------------------------------------------------------------
119 const int* FontList::GetSizeAry( const FontMetric& rFontMetric ) const;
121 This method returns the available sizes for the given font.
122 If it is a scalable font, standard sizes are returned.
123 The array contains the heights of the font in tenth (1/10) point.
124 The last value of the array is 0.
125 The returned array will destroyed by the FontList.
126 You should thus not reference the array after the next method call on the
130 class SVT_DLLPUBLIC FontList
133 static const int aStdSizeAry
[];
136 OUString maMapPrinterOnly
;
137 OUString maMapStyleNotAvailable
;
138 mutable OUString maMapNotAvailable
;
140 OUString maLightItalic
;
142 OUString maNormalItalic
;
144 OUString maBoldItalic
;
146 OUString maBlackItalic
;
147 mutable std::unique_ptr
<int[]> mpSizeAry
;
148 VclPtr
<OutputDevice
> mpDev
;
149 VclPtr
<OutputDevice
> mpDev2
;
150 std::vector
<std::unique_ptr
<ImplFontListNameInfo
>> m_Entries
;
152 SVT_DLLPRIVATE ImplFontListNameInfo
* ImplFind( const OUString
& rSearchName
, sal_uInt32
* pIndex
) const;
153 SVT_DLLPRIVATE ImplFontListNameInfo
* ImplFindByName( const OUString
& rStr
) const;
154 SVT_DLLPRIVATE
void ImplInsertFonts(OutputDevice
* pDev
, bool bInsertData
);
157 FontList( OutputDevice
* pDevice
,
158 OutputDevice
* pDevice2
= nullptr);
161 std::unique_ptr
<FontList
> Clone() const;
163 OUString
GetFontMapText( const FontMetric
& rFontMetric
) const;
165 const OUString
& GetNormalStr() const { return maNormal
; }
166 const OUString
& GetItalicStr() const { return maNormalItalic
; }
167 const OUString
& GetBoldStr() const { return maBold
; }
168 const OUString
& GetBoldItalicStr() const { return maBoldItalic
; }
169 const OUString
& GetStyleName( FontWeight eWeight
, FontItalic eItalic
) const;
170 OUString
GetStyleName( const FontMetric
& rFontMetric
) const;
172 FontMetric
Get( const OUString
& rName
,
173 const OUString
& rStyleName
) const;
174 FontMetric
Get( const OUString
& rName
,
176 FontItalic eItalic
) const;
178 bool IsAvailable( const OUString
& rName
) const;
179 size_t GetFontNameCount() const
181 return m_Entries
.size();
183 const FontMetric
& GetFontName(size_t nFont
) const;
184 sal_Handle
GetFirstFontMetric( const OUString
& rName
) const;
185 static sal_Handle
GetNextFontMetric( sal_Handle hFontMetric
);
186 static const FontMetric
& GetFontMetric( sal_Handle hFontMetric
);
188 const int* GetSizeAry( const FontMetric
& rFontMetric
) const;
189 static const int* GetStdSizeAry() { return aStdSizeAry
; }
192 FontList( const FontList
& ) = delete;
193 FontList
& operator =( const FontList
& ) = delete;
196 class UNLESS_MERGELIBS(SVT_DLLPUBLIC
) FontSizeNames
199 const struct ImplFSNameItem
* mpArray
;
203 FontSizeNames( LanguageType eLanguage
/* = LANGUAGE_DONTKNOW */ );
205 sal_Int32
Count() const { return mnElem
; }
206 bool IsEmpty() const { return !mnElem
; }
208 sal_Int32
Name2Size( const OUString
& ) const;
209 OUString
Size2Name( sal_Int32
) const;
211 OUString
GetIndexName( sal_Int32 nIndex
) const;
212 sal_Int32
GetIndexSize( sal_Int32 nIndex
) const;
215 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */