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 "fontinstance.hxx"
24 // extend std namespace to add custom hash needed for LogicalFontInstance
28 template <> struct hash
< pair
< sal_UCS4
, FontWeight
> >
30 size_t operator()(const pair
< sal_UCS4
, FontWeight
>& rData
) const
32 size_t h1
= hash
<sal_UCS4
>()(rData
.first
);
33 size_t h2
= hash
<int>()(rData
.second
);
40 LogicalFontInstance::LogicalFontInstance( const FontSelectPattern
& rFontSelData
)
41 : mpFontCache(nullptr)
42 , maFontSelData( rFontSelData
)
43 , mxFontMetric( new ImplFontMetricData( rFontSelData
))
44 , mpConversion( nullptr )
47 , mnOwnOrientation( 0 )
50 , mpUnicodeFallbackList( nullptr )
52 maFontSelData
.mpFontInstance
= this;
55 LogicalFontInstance::~LogicalFontInstance()
57 delete mpUnicodeFallbackList
;
58 mpFontCache
= nullptr;
59 mxFontMetric
= nullptr;
62 void LogicalFontInstance::AddFallbackForUnicode( sal_UCS4 cChar
, FontWeight eWeight
, const OUString
& rFontName
)
64 if( !mpUnicodeFallbackList
)
65 mpUnicodeFallbackList
= new UnicodeFallbackList
;
66 (*mpUnicodeFallbackList
)[ std::pair
< sal_UCS4
, FontWeight
>(cChar
,eWeight
) ] = rFontName
;
69 bool LogicalFontInstance::GetFallbackForUnicode( sal_UCS4 cChar
, FontWeight eWeight
, OUString
* pFontName
) const
71 if( !mpUnicodeFallbackList
)
74 UnicodeFallbackList::const_iterator it
= mpUnicodeFallbackList
->find( std::pair
< sal_UCS4
, FontWeight
>(cChar
,eWeight
) );
75 if( it
== mpUnicodeFallbackList
->end() )
78 *pFontName
= (*it
).second
;
82 void LogicalFontInstance::IgnoreFallbackForUnicode( sal_UCS4 cChar
, FontWeight eWeight
, const OUString
& rFontName
)
84 UnicodeFallbackList::iterator it
= mpUnicodeFallbackList
->find( std::pair
< sal_UCS4
,FontWeight
>(cChar
,eWeight
) );
85 if( it
== mpUnicodeFallbackList
->end() )
87 if( (*it
).second
== rFontName
)
88 mpUnicodeFallbackList
->erase( it
);
92 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */