tor-browser

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

SFNTData.h (1758B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef mozilla_gfx_SFNTData_h
      8 #define mozilla_gfx_SFNTData_h
      9 
     10 #include "mozilla/UniquePtr.h"
     11 #include "mozilla/Vector.h"
     12 
     13 namespace mozilla {
     14 namespace gfx {
     15 
     16 class SFNTData final {
     17 public:
     18  /**
     19   * Creates an SFNTData if the header is a format that we understand and
     20   * aDataLength is sufficient for the length information in the header data.
     21   * Note that the data is NOT copied, so must exist the SFNTData's lifetime.
     22   *
     23   * @param aFontData the SFNT data.
     24   * @param aDataLength length
     25   * @return UniquePtr to a SFNTData or nullptr if the header is invalid.
     26   */
     27  static UniquePtr<SFNTData> Create(const uint8_t* aFontData,
     28                                    uint32_t aDataLength);
     29 
     30  /**
     31   * Creates a unique key for the given font data and variation settings.
     32   *
     33   * @param aFontData the SFNT data
     34   * @param aDataLength length
     35   * @return unique key to be used for caching
     36   */
     37  static uint64_t GetUniqueKey(const uint8_t* aFontData, uint32_t aDataLength,
     38                               uint32_t aVarDataSize, const void* aVarData);
     39 
     40  ~SFNTData();
     41 
     42 private:
     43  SFNTData() = default;
     44 
     45  bool AddFont(const uint8_t* aFontData, uint32_t aDataLength,
     46               uint32_t aOffset);
     47 
     48  uint32_t HashHeadAndCmapTables();
     49 
     50  // Internal representation of single font in font file.
     51  class Font;
     52 
     53  Vector<Font*> mFonts;
     54 };
     55 
     56 }  // namespace gfx
     57 }  // namespace mozilla
     58 
     59 #endif  // mozilla_gfx_SFNTData_h