1 /*
2  * Copyright (C) 2022 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #define LOG_TAG "Minikin"
18 
19 #include "minikin/MinikinFontFactory.h"
20 
21 #include <log/log.h>
22 
23 #include "MinikinInternal.h"
24 
25 namespace minikin {
26 
27 namespace {
28 static const MinikinFontFactory* gMinikinFontFactory = nullptr;
29 }
30 
~MinikinFontFactory()31 MinikinFontFactory::~MinikinFontFactory() {}
32 
33 // static
getInstance()34 const MinikinFontFactory& MinikinFontFactory::getInstance() {
35     MINIKIN_ASSERT(gMinikinFontFactory != nullptr, "setInstance should have been called.");
36     return *gMinikinFontFactory;
37 }
38 
39 // static
setInstance(const MinikinFontFactory * factory)40 void MinikinFontFactory::setInstance(const MinikinFontFactory* factory) {
41     MINIKIN_ASSERT(gMinikinFontFactory == nullptr || gMinikinFontFactory == factory,
42                    "MinikinFontFactory cannot be changed after it is set.");
43     gMinikinFontFactory = factory;
44 }
45 
46 }  // namespace minikin
47