Support custom fonts registration
[platform/core/uifw/dali-adaptor.git] / dali / internal / text / text-abstraction / font-client-plugin-impl.h
index 3ada20c..9bbc70c 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_TEXT_ABSTRACTION_FONT_CLIENT_PLUGIN_IMPL_H
 
 /*
- * Copyright (c) 2017 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -35,6 +35,7 @@ class VectorFontCache;
 #include FT_GLYPH_H
 #include FT_OUTLINE_H
 #include FT_STROKER_H
+#include FT_SYNTHESIS_H
 
 // forward declarations of font config types.
 struct _FcCharSet;
@@ -66,7 +67,7 @@ struct FontClient::Plugin
    */
   struct FallbackCacheItem
   {
-    FallbackCacheItem( const FontDescription& fontDescription, FontList* fallbackFonts, CharacterSetList* characterSets );
+    FallbackCacheItem( FontDescription&& fontDescription, FontList* fallbackFonts, CharacterSetList* characterSets );
 
     FontDescription fontDescription; ///< The font description.
     FontList* fallbackFonts;         ///< The list of fallback fonts for the given font-description.
@@ -80,6 +81,8 @@ struct FontClient::Plugin
   {
     FontDescriptionCacheItem( const FontDescription& fontDescription,
                               FontDescriptionId index );
+    FontDescriptionCacheItem( FontDescription&& fontDescription,
+                              FontDescriptionId index );
 
     FontDescription fontDescription; ///< The font description.
     FontDescriptionId index;         ///< Index to the vector of font descriptions.
@@ -88,11 +91,11 @@ struct FontClient::Plugin
   /**
    * @brief Caches the font id of the pair font point size and the index to the vector of font descriptions of validated fonts.
    */
-  struct FontIdCacheItem
+  struct FontDescriptionSizeCacheItem
   {
-    FontIdCacheItem( FontDescriptionId validatedFontId,
-                     PointSize26Dot6 requestedPointSize,
-                     FontId fontId );
+    FontDescriptionSizeCacheItem( FontDescriptionId validatedFontId,
+                                  PointSize26Dot6 requestedPointSize,
+                                  FontId fontId );
 
     FontDescriptionId validatedFontId;    ///< Index to the vector with font descriptions.
     PointSize26Dot6   requestedPointSize; ///< The font point size.
@@ -297,9 +300,9 @@ struct FontClient::Plugin
   bool GetVectorMetrics( GlyphInfo* array, uint32_t size, bool horizontal );
 
   /**
-   * @copydoc Dali::TextAbstraction::FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth )
+   * @copydoc Dali::TextAbstraction::FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, bool softwareItalic, bool softwareBold, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth )
    */
-  void CreateBitmap( FontId fontId, GlyphIndex glyphIndex, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth );
+  void CreateBitmap( FontId fontId, GlyphIndex glyphIndex, bool softwareItalic, bool softwareBold, Dali::TextAbstraction::FontClient::GlyphBufferData& data, int outlineWidth );
 
   /**
    * @copydoc Dali::TextAbstraction::FontClient::CreateBitmap( FontId fontId, GlyphIndex glyphIndex, int outlineWidth )
@@ -321,6 +324,16 @@ struct FontClient::Plugin
    */
   bool IsColorGlyph( FontId fontId, GlyphIndex glyphIndex );
 
+  /**
+   * @copydoc Dali::TextAbstraction::Internal::FontClient::GetFreetypeFace()
+   */
+  FT_FaceRec_* GetFreetypeFace( FontId fontId );
+
+  /**
+   * @copydoc Dali::TextAbstraction::FontClient::AddCustomFontDirectory()
+   */
+  bool AddCustomFontDirectory( const FontPath& path );
+
 private:
 
   /**
@@ -429,8 +442,8 @@ private:
    * @brief Finds a fallback font list from the cache for a given font-description
    *
    * @param[in] fontDescription The font to validate.
-   * @param[out] A valid pointer to a font list, or NULL if not found.
-   * @param[out] characterSetList A valid pointer to a character set list, or NULL if not found.
+   * @param[out] A valid pointer to a font list, or @e nullptr if not found.
+   * @param[out] characterSetList A valid pointer to a character set list, or @e nullptr if not found.
    */
   bool FindFallbackFontList( const FontDescription& fontDescription,
                              FontList*& fontList,
@@ -515,11 +528,11 @@ private:
 
   std::vector<FallbackCacheItem> mFallbackCache; ///< Cached fallback font lists.
 
-  std::vector<FontFaceCacheItem>        mFontCache;            ///< Caches the FreeType face and font metrics of the triplet 'path to the font file name, font point size and face index'.
-  std::vector<FontDescriptionCacheItem> mValidatedFontCache;   ///< Caches indices to the vector of font descriptions for a given font.
-  FontList                              mFontDescriptionCache; ///< Caches font descriptions for the validated font.
-  CharacterSetList                      mCharacterSetCache;    ///< Caches character set lists for the validated font.
-  std::vector<FontIdCacheItem>          mFontIdCache;          ///< Caches font identifiers for the pairs of font point size and the index to the vector with font descriptions of the validated fonts.
+  std::vector<FontFaceCacheItem>            mFontFaceCache;            ///< Caches the FreeType face and font metrics of the triplet 'path to the font file name, font point size and face index'.
+  std::vector<FontDescriptionCacheItem>     mValidatedFontCache;       ///< Caches indices to the vector of font descriptions for a given font.
+  FontList                                  mFontDescriptionCache;     ///< Caches font descriptions for the validated font.
+  CharacterSetList                          mCharacterSetCache;        ///< Caches character set lists for the validated font.
+  std::vector<FontDescriptionSizeCacheItem> mFontDescriptionSizeCache; ///< Caches font identifiers for the pairs of font point size and the index to the vector with font descriptions of the validated fonts.
 
   VectorFontCache* mVectorFontCache;            ///< Separate cache for vector data blobs etc.
   Vector<EllipsisItem> mEllipsisCache;          ///< Caches ellipsis glyphs for a particular point size.