MinikinFontForTest.cpp revision 63635cff5861dcaed963c7332eecf51b9d7d920a
1/* 2 * Copyright (C) 2015 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#include "MinikinFontForTest.h" 18 19#include <minikin/MinikinFont.h> 20 21#include <SkTypeface.h> 22 23#include <cutils/log.h> 24 25MinikinFontForTest::MinikinFontForTest(const std::string& font_path) : mFontPath(font_path) { 26 mTypeface = SkTypeface::CreateFromFile(font_path.c_str()); 27} 28 29MinikinFontForTest::~MinikinFontForTest() { 30} 31 32float MinikinFontForTest::GetHorizontalAdvance(uint32_t /* glyph_id */, 33 const android::MinikinPaint& /* paint */) const { 34 LOG_ALWAYS_FATAL("MinikinFontForTest::GetHorizontalAdvance is not yet implemented"); 35 return 0.0f; 36} 37 38void MinikinFontForTest::GetBounds(android::MinikinRect* /* bounds */, uint32_t /* glyph_id */, 39 const android::MinikinPaint& /* paint */) const { 40 LOG_ALWAYS_FATAL("MinikinFontForTest::GetBounds is not yet implemented"); 41} 42 43bool MinikinFontForTest::GetTable(uint32_t tag, uint8_t *buf, size_t *size) { 44 if (buf == NULL) { 45 const size_t tableSize = mTypeface->getTableSize(tag); 46 *size = tableSize; 47 return tableSize != 0; 48 } else { 49 const size_t actualSize = mTypeface->getTableData(tag, 0, *size, buf); 50 *size = actualSize; 51 return actualSize != 0; 52 } 53} 54 55int32_t MinikinFontForTest::GetUniqueId() const { 56 return mTypeface->uniqueID(); 57} 58