LCOV - code coverage report
Current view: top level - gfx/2d - SFNTData.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 1 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : #include "u16string.h"
      13             : 
      14             : namespace mozilla {
      15             : namespace gfx {
      16             : 
      17             : class SFNTData final
      18             : {
      19             : public:
      20             : 
      21             :   /**
      22             :    * Creates an SFNTData if the header is a format that we understand and
      23             :    * aDataLength is sufficient for the length information in the header data.
      24             :    * Note that the data is NOT copied, so must exist the SFNTData's lifetime.
      25             :    *
      26             :    * @param aFontData the SFNT data.
      27             :    * @param aDataLength length
      28             :    * @return UniquePtr to a SFNTData or nullptr if the header is invalid.
      29             :    */
      30             :   static UniquePtr<SFNTData> Create(const uint8_t *aFontData,
      31             :                                     uint32_t aDataLength);
      32             : 
      33             :   /**
      34             :    * Creates a unique key for the given font data and variation settings.
      35             :    *
      36             :    * @param aFontData the SFNT data
      37             :    * @param aDataLength length
      38             :    * @return unique key to be used for caching
      39             :    */
      40             :   static uint64_t GetUniqueKey(const uint8_t *aFontData, uint32_t aDataLength,
      41             :                                uint32_t aVarDataSize, const void* aVarData);
      42             : 
      43             :   ~SFNTData();
      44             : 
      45             :   /**
      46             :    * Gets the full name from the name table of the font corresponding to the
      47             :    * index. If the full name string is not present it will use the family space
      48             :    * concatenated with the style.
      49             :    * This will only read names that are already UTF16.
      50             :    *
      51             :    * @param aFontData SFNT data.
      52             :    * @param aDataLength length of aFontData.
      53             :    * @param aU16FullName string to be populated with the full name.
      54             :    * @return true if the full name is successfully read.
      55             :    */
      56             :   bool GetU16FullName(uint32_t aIndex, mozilla::u16string& aU16FullName);
      57             : 
      58             :   /**
      59             :    * Populate a Vector with the first UTF16 full name from each name table of
      60             :    * the fonts. If the full name string is not present it will use the family
      61             :    * space concatenated with the style.
      62             :    * This will only read names that are already UTF16.
      63             :    *
      64             :    * @param aU16FullNames the Vector to be populated.
      65             :    * @return true if at least one name found otherwise false.
      66             :    */
      67             :   bool GetU16FullNames(Vector<mozilla::u16string>& aU16FullNames);
      68             : 
      69             :   /**
      70             :    * Returns the index for the first UTF16 name matching aU16FullName.
      71             :    *
      72             :    * @param aU16FullName full name to find.
      73             :    * @param aIndex out param for the index if found.
      74             :    * @param aTruncatedLen length to truncate the compared font name to.
      75             :    * @return true if the full name is successfully read.
      76             :    */
      77             :   bool GetIndexForU16Name(const mozilla::u16string& aU16FullName, uint32_t* aIndex,
      78             :                           size_t aTruncatedLen = 0);
      79             : 
      80             : private:
      81             : 
      82           0 :   SFNTData() {}
      83             : 
      84             :   bool AddFont(const uint8_t *aFontData, uint32_t aDataLength,
      85             :                uint32_t aOffset);
      86             : 
      87             :   // Internal representation of single font in font file.
      88             :   class Font;
      89             : 
      90             :   Vector<Font*> mFonts;
      91             : };
      92             : 
      93             : } // gfx
      94             : } // mozilla
      95             : 
      96             : #endif // mozilla_gfx_SFNTData_h

Generated by: LCOV version 1.13