Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _PSPRINT_FONTMANAGER_HXX_
30 : : #define _PSPRINT_FONTMANAGER_HXX_
31 : :
32 : : #include <boost/unordered_map.hpp>
33 : : #include <map>
34 : : #include <list>
35 : : #include <set>
36 : :
37 : : #include "vcl/dllapi.h"
38 : : #include "vcl/helper.hxx"
39 : : #include "vcl/vclenum.hxx"
40 : : #include "com/sun/star/lang/Locale.hpp"
41 : :
42 : : #include <vector>
43 : :
44 : : #define ATOM_FAMILYNAME 2
45 : : #define ATOM_PSNAME 3
46 : :
47 : : /*
48 : : * some words on metrics: every length returned by PrintFontManager and
49 : : * friends are PostScript afm style, that is they are 1/1000 font height
50 : : */
51 : :
52 : : // forward declarations
53 : : namespace utl { class MultiAtomProvider; } // see unotools/atom.hxx
54 : : class FontSubsetInfo;
55 : : class ImplFontOptions;
56 : : class FontSelectPattern;
57 : :
58 : : namespace psp {
59 : : class PPDParser; // see ppdparser.hxx
60 : :
61 : : namespace fonttype
62 : : {
63 : : enum type {
64 : : Unknown = 0,
65 : : Type1 = 1,
66 : : TrueType = 2,
67 : : Builtin = 3
68 : : };
69 : : }
70 : :
71 : : /*
72 : : * the difference between FastPrintFontInfo and PrintFontInfo
73 : : * is that the information in FastPrintFontInfo can usually
74 : : * be gathered without openening either the font file or
75 : : * an afm metric file. they are gathered from fonts.dir alone.
76 : : * if only FastPrintFontInfo is gathered and PrintFontInfo
77 : : * on demand and for less fonts, then performance in startup
78 : : * increases considerably
79 : : */
80 : :
81 [ # # ]: 9229 : struct FastPrintFontInfo
82 : : {
83 : : fontID m_nID; // FontID
84 : : fonttype::type m_eType;
85 : :
86 : : // font attributes
87 : : rtl::OUString m_aFamilyName;
88 : : rtl::OUString m_aStyleName;
89 : : std::list< rtl::OUString > m_aAliases;
90 : : FontFamily m_eFamilyStyle;
91 : : FontItalic m_eItalic;
92 : : FontWidth m_eWidth;
93 : : FontWeight m_eWeight;
94 : : FontPitch m_ePitch;
95 : : rtl_TextEncoding m_aEncoding;
96 : : bool m_bSubsettable;
97 : : bool m_bEmbeddable;
98 : :
99 : 9229 : FastPrintFontInfo() :
100 : : m_nID( 0 ),
101 : : m_eType( fonttype::Unknown ),
102 : : m_eFamilyStyle( FAMILY_DONTKNOW ),
103 : : m_eItalic( ITALIC_DONTKNOW ),
104 : : m_eWidth( WIDTH_DONTKNOW ),
105 : : m_eWeight( WEIGHT_DONTKNOW ),
106 : : m_ePitch( PITCH_DONTKNOW ),
107 [ + - ]: 9229 : m_aEncoding( RTL_TEXTENCODING_DONTKNOW )
108 : 9229 : {}
109 : : };
110 : :
111 : 121 : struct PrintFontInfo : public FastPrintFontInfo
112 : : {
113 : : int m_nAscend;
114 : : int m_nDescend;
115 : : int m_nLeading;
116 : : int m_nWidth;
117 : :
118 : 121 : PrintFontInfo() :
119 : : FastPrintFontInfo(),
120 : : m_nAscend( 0 ),
121 : : m_nDescend( 0 ),
122 : : m_nLeading( 0 ),
123 : 121 : m_nWidth( 0 )
124 : 121 : {}
125 : : };
126 : :
127 : : // the values are per thousand of the font size
128 : : // note: width, height contain advances, not bounding box
129 : : struct CharacterMetric
130 : : {
131 : : short int width, height;
132 : :
133 : 174149 : CharacterMetric() : width( 0 ), height( 0 ) {}
134 : : bool operator==( const CharacterMetric& rOther ) const
135 : : { return rOther.width == width && rOther.height == height; }
136 : : bool operator!=( const CharacterMetric& rOther ) const
137 : : { return rOther.width != width || rOther.height != height; }
138 : : };
139 : :
140 : : struct KernPair
141 : : {
142 : : sal_Unicode first, second;
143 : : short int kern_x, kern_y;
144 : :
145 : : KernPair() : first( 0 ), second( 0 ), kern_x( 0 ), kern_y( 0 ) {}
146 : : };
147 : :
148 : : class FontCache;
149 : :
150 : : // a class to manage printable fonts
151 : : // aims are type1 and truetype fonts
152 : :
153 : : class FontCache;
154 : :
155 : : class VCL_PLUGIN_PUBLIC PrintFontManager
156 : : {
157 : : struct PrintFont;
158 : : struct TrueTypeFontFile;
159 : : struct Type1FontFile;
160 : : struct BuiltinFont;
161 : : friend struct PrintFont;
162 : : friend struct TrueTypeFontFile;
163 : : friend struct Type1FontFile;
164 : : friend struct BuiltinFont;
165 : : friend class FontCache;
166 : :
167 : : struct PrintFontMetrics
168 : : {
169 : : // character metrics are stored by the following keys:
170 : : // lower two bytes contain a sal_Unicode (a UCS2 character)
171 : : // upper byte contains: 0 for horizontal metric
172 : : // 1 for vertical metric
173 : : // highest byte: 0 for now
174 : : boost::unordered_map< int, CharacterMetric > m_aMetrics;
175 : : // contains the unicode blocks for which metrics were queried
176 : : // this implies that metrics should be queried in terms of
177 : : // unicode blocks. here a unicode block is identified
178 : : // by the upper byte of the UCS2 encoding.
179 : : // note that the corresponding bit should be set even
180 : : // if the font does not support a single character of that page
181 : : // this map shows, which pages were queried already
182 : : // if (like in AFM metrics) all metrics are queried in
183 : : // a single pass, then all bits should be set
184 : : char m_aPages[32];
185 : :
186 : : bool m_bKernPairsQueried;
187 : : std::list< KernPair > m_aXKernPairs;
188 : : std::list< KernPair > m_aYKernPairs;
189 : : boost::unordered_map< sal_Unicode, bool > m_bVerticalSubstitutions;
190 : :
191 : : PrintFontMetrics() : m_bKernPairsQueried( false ) {}
192 : :
193 : : bool isEmpty() const { return m_aMetrics.empty(); }
194 : : };
195 : :
196 : : struct PrintFont
197 : : {
198 : : fonttype::type m_eType;
199 : :
200 : : // font attributes
201 : : int m_nFamilyName; // atom
202 : : std::list< int > m_aAliases;
203 : : int m_nPSName; // atom
204 : : rtl::OUString m_aStyleName;
205 : : FontItalic m_eItalic;
206 : : FontWidth m_eWidth;
207 : : FontWeight m_eWeight;
208 : : FontPitch m_ePitch;
209 : : rtl_TextEncoding m_aEncoding;
210 : : bool m_bFontEncodingOnly; // set if font should be only accessed by builtin encoding
211 : : CharacterMetric m_aGlobalMetricX;
212 : : CharacterMetric m_aGlobalMetricY;
213 : : PrintFontMetrics* m_pMetrics;
214 : : int m_nAscend;
215 : : int m_nDescend;
216 : : int m_nLeading;
217 : : int m_nXMin; // font bounding box
218 : : int m_nYMin;
219 : : int m_nXMax;
220 : : int m_nYMax;
221 : : bool m_bHaveVerticalSubstitutedGlyphs;
222 : : bool m_bUserOverride;
223 : :
224 : : std::map< sal_Unicode, sal_Int32 > m_aEncodingVector;
225 : : std::map< sal_Unicode, rtl::OString > m_aNonEncoded;
226 : :
227 : : PrintFont( fonttype::type eType );
228 : : virtual ~PrintFont();
229 : : virtual bool queryMetricPage( int nPage, utl::MultiAtomProvider* pProvider ) = 0;
230 : :
231 : : bool readAfmMetrics( const rtl::OString& rFileName, utl::MultiAtomProvider* pProvider, bool bFillEncodingvector, bool bOnlyGlobalAttributes );
232 : : };
233 : :
234 : : struct Type1FontFile : public PrintFont
235 : : {
236 : : int m_nDirectory; // atom containing system dependent path
237 : : rtl::OString m_aFontFile; // relative to directory
238 : : rtl::OString m_aMetricFile; // dito
239 : :
240 : : /* note: m_aFontFile and Metric file are not atoms
241 : : because they should be fairly unique */
242 : :
243 : : Type1FontFile() : PrintFont( fonttype::Type1 ), m_nDirectory( 0 ) {}
244 : : virtual ~Type1FontFile();
245 : : virtual bool queryMetricPage( int nPage, utl::MultiAtomProvider* pProvider );
246 : : };
247 : :
248 : : struct TrueTypeFontFile : public PrintFont
249 : : {
250 : : int m_nDirectory; // atom containing system dependent path
251 : : rtl::OString m_aFontFile; // relative to directory
252 : : int m_nCollectionEntry; // 0 for regular fonts, 0 to ... for fonts stemming from collections
253 : : unsigned int m_nTypeFlags; // copyright bits and PS-OpenType flag
254 : :
255 : : TrueTypeFontFile();
256 : : virtual ~TrueTypeFontFile();
257 : : virtual bool queryMetricPage( int nPage, utl::MultiAtomProvider* pProvider );
258 : : };
259 : :
260 : : struct BuiltinFont : public PrintFont
261 : : {
262 : : int m_nDirectory; // atom containing system dependent path
263 : : rtl::OString m_aMetricFile;
264 : :
265 : : BuiltinFont() : PrintFont( fonttype::Builtin ) {}
266 : : virtual ~BuiltinFont();
267 : : virtual bool queryMetricPage( int nPage, utl::MultiAtomProvider* pProvider );
268 : : };
269 : :
270 : : fontID m_nNextFontID;
271 : : boost::unordered_map< fontID, PrintFont* > m_aFonts;
272 : : boost::unordered_map< int, FontFamily > m_aFamilyTypes;
273 : : std::list< rtl::OUString > m_aPrinterDrivers;
274 : : std::list< rtl::OString > m_aFontDirectories;
275 : : std::list< int > m_aPrivateFontDirectories;
276 : : utl::MultiAtomProvider* m_pAtoms;
277 : : // for speeding up findFontFileID
278 : : boost::unordered_map< rtl::OString, std::set< fontID >, rtl::OStringHash >
279 : : m_aFontFileToFontID;
280 : :
281 : : boost::unordered_map< rtl::OString, int, rtl::OStringHash >
282 : : m_aDirToAtom;
283 : : boost::unordered_map< int, rtl::OString > m_aAtomToDir;
284 : : int m_nNextDirAtom;
285 : :
286 : : boost::unordered_multimap< rtl::OString, sal_Unicode, rtl::OStringHash >
287 : : m_aAdobenameToUnicode;
288 : : boost::unordered_multimap< sal_Unicode, rtl::OString >
289 : : m_aUnicodeToAdobename;
290 : : boost::unordered_multimap< sal_Unicode, sal_uInt8 > m_aUnicodeToAdobecode;
291 : : boost::unordered_multimap< sal_uInt8, sal_Unicode > m_aAdobecodeToUnicode;
292 : :
293 : : mutable FontCache* m_pFontCache;
294 : :
295 : : mutable std::vector< fontID > m_aOverrideFonts;
296 : :
297 : : rtl::OString getAfmFile( PrintFont* pFont ) const;
298 : : rtl::OString getFontFile( PrintFont* pFont ) const;
299 : :
300 : : bool analyzeFontFile( int nDirID, const rtl::OString& rFileName, std::list< PrintFont* >& rNewFonts, const char *pFormat=NULL ) const;
301 : : rtl::OUString convertTrueTypeName( void* pNameRecord ) const; // actually a NameRecord* formt font subsetting code
302 : : void analyzeTrueTypeFamilyName( void* pTTFont, std::list< rtl::OUString >& rnames ) const; // actually a TrueTypeFont* from font subsetting code
303 : : bool analyzeTrueTypeFile( PrintFont* pFont ) const;
304 : : // finds the font id for the nFaceIndex face in this font file
305 : : // There may be multiple font ids for TrueType collections
306 : : fontID findFontFileID( int nDirID, const rtl::OString& rFile, int nFaceIndex ) const;
307 : :
308 : : // There may be multiple font ids for TrueType collections
309 : : std::vector<fontID> findFontFileIDs( int nDirID, const rtl::OString& rFile ) const;
310 : :
311 : : bool knownFontFile( int nDirID, const rtl::OString& rFile ) const
312 : : {
313 : : return findFontFileID(nDirID, rFile, 0) != 0;
314 : : }
315 : :
316 : : fontID findFontBuiltinID( int nPSNameAtom ) const;
317 : :
318 : : FontFamily matchFamilyName( const rtl::OUString& rFamily ) const;
319 : :
320 : 181223 : PrintFont* getFont( fontID nID ) const
321 : : {
322 : 181223 : boost::unordered_map< fontID, PrintFont* >::const_iterator it;
323 [ + - ]: 181223 : it = m_aFonts.find( nID );
324 [ - + ][ + - ]: 181223 : return it == m_aFonts.end() ? NULL : it->second;
325 : : }
326 : : void fillPrintFontInfo( PrintFont* pFont, FastPrintFontInfo& rInfo ) const;
327 : : void fillPrintFontInfo( PrintFont* pFont, PrintFontInfo& rInfo ) const;
328 : :
329 : : rtl::OString getDirectory( int nAtom ) const;
330 : : int getDirectoryAtom( const rtl::OString& rDirectory, bool bCreate = false );
331 : :
332 : : /* try to initialize fonts from libfontconfig
333 : :
334 : : called from <code>initialize()</code>
335 : : */
336 : : void initFontconfig();
337 : : void countFontconfigFonts( boost::unordered_map<rtl::OString, int, rtl::OStringHash>& o_rVisitedPaths );
338 : : /* deinitialize fontconfig
339 : : */
340 : : void deinitFontconfig();
341 : :
342 : : /* register an application specific font directory for libfontconfig
343 : :
344 : : since fontconfig is asked for font substitutes before OOo will check for font availability
345 : : and fontconfig will happily substitute fonts it doesn't know (e.g. "Arial Narrow" -> "DejaVu Sans Book"!)
346 : : it becomes necessary to tell the library about all the hidden font treasures
347 : :
348 : : @returns
349 : : true if libfontconfig accepted the directory
350 : : false else (e.g. no libfontconfig found)
351 : : */
352 : : bool addFontconfigDir(const rtl::OString& rDirectory);
353 : :
354 : : bool readOverrideMetrics();
355 : :
356 : : PrintFontManager();
357 : : ~PrintFontManager();
358 : : public:
359 : : static PrintFontManager& get(); // one instance only
360 : :
361 : : // There may be multiple font ids for TrueType collections
362 : : std::vector<fontID> addFontFile( const rtl::OString& rFileName );
363 : :
364 : : void initialize();
365 : :
366 : : // returns the number of managed fonts
367 : : int getFontCount() const { return m_aFonts.size(); }
368 : :
369 : : // caution: the getFontList* methods can change the font list on demand
370 : : // depending on the pParser argument. That is getFontCount() may
371 : : // return a larger value after getFontList()
372 : :
373 : : // returns the ids of all managed fonts. on pParser != NULL
374 : : // all fonttype::Builtin type fonts are not listed
375 : : // which do not occur in the PPD of pParser
376 : : void getFontList( std::list< fontID >& rFontIDs, const PPDParser* pParser = NULL, bool bUseOverrideMetrics = false );
377 : : // get the font list and fast font info. see getFontList for pParser
378 : : void getFontListWithFastInfo( std::list< FastPrintFontInfo >& rFonts, const PPDParser* pParser = NULL, bool bUseOverrideMetrics = false );
379 : :
380 : : // get font info for a specific font
381 : : bool getFontInfo( fontID nFontID, PrintFontInfo& rInfo ) const;
382 : : // get fast font info for a specific font
383 : : bool getFontFastInfo( fontID nFontID, FastPrintFontInfo& rInfo ) const;
384 : :
385 : : // routines to get font info in small pieces
386 : :
387 : : // get a specific fonts PSName name
388 : : const rtl::OUString& getPSName( fontID nFontID ) const;
389 : :
390 : : // get a specific fonts family name aliases
391 : : void getFontFamilyAliases( fontID nFontID ) const;
392 : :
393 : : // get a specific fonts type
394 : 10272 : fonttype::type getFontType( fontID nFontID ) const
395 : : {
396 : 10272 : PrintFont* pFont = getFont( nFontID );
397 [ + - ]: 10272 : return pFont ? pFont->m_eType : fonttype::Unknown;
398 : : }
399 : :
400 : : // get a specific fonts italic type
401 : 60 : FontItalic getFontItalic( fontID nFontID ) const
402 : : {
403 : 60 : PrintFont* pFont = getFont( nFontID );
404 [ + - ]: 60 : return pFont ? pFont->m_eItalic : ITALIC_DONTKNOW;
405 : : }
406 : :
407 : : // get a specific fonts width type
408 : : FontWidth getFontWidth( fontID nFontID ) const
409 : : {
410 : : PrintFont* pFont = getFont( nFontID );
411 : : return pFont ? pFont->m_eWidth : WIDTH_DONTKNOW;
412 : : }
413 : :
414 : : // get a specific fonts weight type
415 : 211 : FontWeight getFontWeight( fontID nFontID ) const
416 : : {
417 : 211 : PrintFont* pFont = getFont( nFontID );
418 [ + - ]: 211 : return pFont ? pFont->m_eWeight : WEIGHT_DONTKNOW;
419 : : }
420 : :
421 : : // get a specific fonts pitch type
422 : : FontPitch getFontPitch( fontID nFontID ) const
423 : : {
424 : : PrintFont* pFont = getFont( nFontID );
425 : : return pFont ? pFont->m_ePitch : PITCH_DONTKNOW;
426 : : }
427 : :
428 : : // get a specific fonts encoding
429 : 0 : rtl_TextEncoding getFontEncoding( fontID nFontID ) const
430 : : {
431 : 0 : PrintFont* pFont = getFont( nFontID );
432 [ # # ]: 0 : return pFont ? pFont->m_aEncoding : RTL_TEXTENCODING_DONTKNOW;
433 : : }
434 : :
435 : : // should i only use font's builtin encoding ?
436 : 0 : bool getUseOnlyFontEncoding( fontID nFontID ) const
437 : : {
438 : 0 : PrintFont* pFont = getFont( nFontID );
439 [ # # ]: 0 : return pFont ? pFont->m_bFontEncodingOnly : false;
440 : : }
441 : :
442 : : // get a specific fonts system dependent filename
443 : 50808 : rtl::OString getFontFileSysPath( fontID nFontID ) const
444 : : {
445 : 50808 : return getFontFile( getFont( nFontID ) );
446 : : }
447 : :
448 : : // get the ttc face number
449 : : int getFontFaceNumber( fontID nFontID ) const;
450 : :
451 : : // get a specific fonts ascend
452 : : int getFontAscend( fontID nFontID ) const;
453 : :
454 : : // get a specific fonts descent
455 : : int getFontDescend( fontID nFontID ) const;
456 : :
457 : : // get a fonts glyph bounding box
458 : : bool getFontBoundingBox( fontID nFont, int& xMin, int& yMin, int& xMax, int& yMax );
459 : :
460 : : // info whether an array of glyphs has vertical substitutions
461 : : void hasVerticalSubstitutions( fontID nFontID, const sal_Unicode* pCharacters,
462 : : int nCharacters, bool* pHasSubst ) const;
463 : :
464 : : // get a specific fonts metrics
465 : :
466 : : // get metrics for a sal_Unicode range
467 : : // the user is responsible to allocate pArray large enough
468 : : bool getMetrics( fontID nFontID, sal_Unicode minCharacter, sal_Unicode maxCharacter, CharacterMetric* pArray, bool bVertical = false ) const;
469 : : // get metrics for an array of sal_Unicode characters
470 : : // the user is responsible to allocate pArray large enough
471 : : bool getMetrics( fontID nFontID, const sal_Unicode* pString, int nLen, CharacterMetric* pArray, bool bVertical = false ) const;
472 : :
473 : : // get encoding vector of font, currently only for Type1 and Builtin fonts
474 : : // returns NULL if encoding vector is empty or font is neither type1 or
475 : : // builtin; if ppNonEncoded is set and non encoded type1 glyphs exist
476 : : // then *ppNonEncoded is set to the mapping for nonencoded glyphs.
477 : : // the encoding vector contains -1 for non encoded glyphs
478 : : const std::map< sal_Unicode, sal_Int32 >* getEncodingMap( fontID nFontID, const std::map< sal_Unicode, rtl::OString >** ppNonEncoded ) const;
479 : :
480 : : // to get font substitution transparently use the
481 : : // getKernPairs method of PrinterGfx
482 : : const std::list< KernPair >& getKernPairs( fontID nFontID, bool bVertical = false ) const;
483 : :
484 : : // evaluates copyright flags for TrueType fonts
485 : : // type1 fonts do not have such a feature, so return for them is true
486 : : // returns true for builtin fonts (surprise!)
487 : : bool isFontDownloadingAllowed( fontID nFont ) const;
488 : :
489 : : // helper for type 1 fonts
490 : : std::list< rtl::OString > getAdobeNameFromUnicode( sal_Unicode aChar ) const;
491 : :
492 : : std::pair< boost::unordered_multimap< sal_Unicode, sal_uInt8 >::const_iterator,
493 : : boost::unordered_multimap< sal_Unicode, sal_uInt8 >::const_iterator >
494 : : getAdobeCodeFromUnicode( sal_Unicode aChar ) const
495 : : {
496 : : return m_aUnicodeToAdobecode.equal_range( aChar );
497 : : }
498 : : std::list< sal_Unicode > getUnicodeFromAdobeName( const rtl::OString& rName ) const;
499 : : std::pair< boost::unordered_multimap< sal_uInt8, sal_Unicode >::const_iterator,
500 : : boost::unordered_multimap< sal_uInt8, sal_Unicode >::const_iterator >
501 : : getUnicodeFromAdobeCode( sal_uInt8 aChar ) const
502 : : {
503 : : return m_aAdobecodeToUnicode.equal_range( aChar );
504 : : }
505 : :
506 : : // creates a new font subset of an existing TrueType font
507 : : // returns true in case of success, else false
508 : : // nFont: the font to be subsetted
509 : : // rOutFile: the file to put the new subset into;
510 : : // must be a valid osl file URL
511 : : // pGlyphIDs: input array of glyph ids for new font
512 : : // pNewEncoding: the corresponding encoding in the new font
513 : : // pWidths: output array of widths of requested glyphs
514 : : // nGlyphs: number of glyphs in arrays
515 : : // pCapHeight:: capital height of the produced font
516 : : // pXMin, pYMin, pXMax, pYMax: outgoing font bounding box
517 : : // TODO: callers of this method should use its FontSubsetInfo counterpart directly
518 : : bool createFontSubset( FontSubsetInfo&,
519 : : fontID nFont,
520 : : const rtl::OUString& rOutFile,
521 : : sal_Int32* pGlyphIDs,
522 : : sal_uInt8* pNewEncoding,
523 : : sal_Int32* pWidths,
524 : : int nGlyphs,
525 : : bool bVertical = false
526 : : );
527 : : void getGlyphWidths( fontID nFont,
528 : : bool bVertical,
529 : : std::vector< sal_Int32 >& rWidths,
530 : : std::map< sal_Unicode, sal_uInt32 >& rUnicodeEnc );
531 : :
532 : :
533 : : // font administration functions
534 : :
535 : : // for importFonts to provide the user feedback
536 : : class ImportFontCallback
537 : : {
538 : : public:
539 : : enum FailCondition { NoWritableDirectory, NoAfmMetric, AfmCopyFailed, FontCopyFailed };
540 : : virtual void importFontsFailed( FailCondition eReason ) = 0;
541 : : virtual void progress( const rtl::OUString& rFile ) = 0;
542 : : virtual bool queryOverwriteFile( const rtl::OUString& rFile ) = 0;
543 : : virtual void importFontFailed( const rtl::OUString& rFile, FailCondition ) = 0;
544 : : virtual bool isCanceled() = 0;
545 : :
546 : : protected:
547 : : ~ImportFontCallback() {}
548 : : };
549 : :
550 : : /* system dependendent font matching
551 : :
552 : : <p>
553 : : <code>matchFont</code> matches a pattern of font characteristics
554 : : and returns the closest match if possibe. If a match was found
555 : : the <code>FastPrintFontInfo</code> passed in as parameter
556 : : will be update to the found matching font.
557 : : </p>
558 : : <p>
559 : : implementation note: currently the function is only implemented
560 : : for fontconfig.
561 : : </p>
562 : :
563 : : @param rInfo
564 : : out of the FastPrintFontInfo structure the following
565 : : fields will be used for the match:
566 : : <ul>
567 : : <li>family name</li>
568 : : <li>italic</li>
569 : : <li>width</li>
570 : : <li>weight</li>
571 : : <li>pitch</li>
572 : : </ul>
573 : :
574 : : @param rLocale
575 : : if <code>rLocal</code> contains non empty strings the corresponding
576 : : locale will be used for font matching also; e.g. "Sans" can result
577 : : in different fonts in e.g. english and japanese
578 : :
579 : : @returns
580 : : true if a match was found
581 : : false else
582 : : */
583 : : bool matchFont( FastPrintFontInfo& rInfo, const com::sun::star::lang::Locale& rLocale );
584 : : ImplFontOptions* getFontOptions( const FastPrintFontInfo&, int nSize, void (*subcallback)(void*)) const;
585 : :
586 : : bool Substitute( FontSelectPattern &rPattern, rtl::OUString& rMissingCodes );
587 : :
588 : : int FreeTypeCharIndex( void *pFace, sal_uInt32 aChar );
589 : : };
590 : :
591 : : } // namespace
592 : :
593 : : #endif // _PSPRINT_FONTMANAGER_HXX_
594 : :
595 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|