tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

AndroidSystemFontIterator.cpp (1253B)


      1 /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
      2 * This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 #include "AndroidSystemFontIterator.h"
      7 
      8 #include "nsDebug.h"
      9 
     10 namespace mozilla {
     11 
     12 AndroidSystemFontIterator::~AndroidSystemFontIterator() {
     13  ASystemFontIterator_close(mIterator);
     14 }
     15 
     16 AndroidSystemFontIterator::AndroidSystemFontIterator()
     17    : mIterator(ASystemFontIterator_open()) {}
     18 
     19 void AndroidSystemFontIterator::Preload() {
     20  // Trigger first system font creation to fill system cache.
     21  AndroidSystemFontIterator iterator;
     22  (void)iterator;
     23 }
     24 
     25 Maybe<AndroidFont> AndroidSystemFontIterator::Next() {
     26  if (mIterator) {
     27    if (AFont* font = ASystemFontIterator_next(mIterator)) {
     28      return Some(AndroidFont(font));
     29    } else {
     30      ASystemFontIterator_close(mIterator);
     31      mIterator = nullptr;
     32      return Nothing();
     33    }
     34  }
     35  return Nothing();
     36 }
     37 
     38 AndroidFont::~AndroidFont() { AFont_close(mFont); }
     39 
     40 const char* AndroidFont::GetFontFilePath() {
     41  if (mFont) {
     42    return AFont_getFontFilePath(mFont);
     43  }
     44  return nullptr;
     45 }
     46 
     47 }  // namespace mozilla