Cache default fontDescription + use default when fontDescription empty
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / text-abstraction / font-list.h
index 9170941..13e459d 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_TEXT_ABSTRACTION_FONT_LIST_H__
-#define __DALI_TEXT_ABSTRACTION_FONT_LIST_H__
+#ifndef DALI_TEXT_ABSTRACTION_FONT_LIST_H
+#define DALI_TEXT_ABSTRACTION_FONT_LIST_H
 
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
  */
 
 // EXTERNAL INCLUDES
-#include <string>
-#include <iostream>
 #include <dali/public-api/common/vector-wrapper.h>
+#include <iostream>
+#include <string>
+
+// INTERNAL INCLUDES
+#include <dali/public-api/dali-adaptor-common.h>
 
 namespace Dali
 {
-
 namespace TextAbstraction
 {
 typedef std::string FontPath;
@@ -34,24 +36,24 @@ typedef std::string FontStyle;
 
 namespace FontWidth
 {
-  /**
+/**
    * @brief Enumeration type for the font's width
    */
-  enum Type
-  {
-    NONE,            ///< Means not defined. Will use what is set as default, currently NORMAL.
-    ULTRA_CONDENSED,
-    EXTRA_CONDENSED,
-    CONDENSED,
-    SEMI_CONDENSED,
-    NORMAL,
-    SEMI_EXPANDED,
-    EXPANDED,
-    EXTRA_EXPANDED,
-    ULTRA_EXPANDED
-  };
+enum Type
+{
+  NONE, ///< Means not defined. Will use what is set as default, currently NORMAL.
+  ULTRA_CONDENSED,
+  EXTRA_CONDENSED,
+  CONDENSED,
+  SEMI_CONDENSED,
+  NORMAL,
+  SEMI_EXPANDED,
+  EXPANDED,
+  EXTRA_EXPANDED,
+  ULTRA_EXPANDED
+};
 
-  const char* const Name[] =
+const char* const Name[] =
   {
     "NONE",
     "ULTRA_CONDENSED",
@@ -62,39 +64,38 @@ namespace FontWidth
     "SEMI_EXPANDED",
     "EXPANDED",
     "EXTRA_EXPANDED",
-    "ULTRA_EXPANDED"
-  };
+    "ULTRA_EXPANDED"};
 } // namespace FontWidth
 
 namespace FontWeight
 {
-  /**
+/**
    * @brief Enumeration type for the font's weight
    */
-  enum Type
-  {
-    NONE,                      ///< Means not defined. Will use what is set as default, currently NORMAL.
-    THIN,
-    ULTRA_LIGHT,
-    EXTRA_LIGHT = ULTRA_LIGHT,
-    LIGHT,
-    DEMI_LIGHT,
-    SEMI_LIGHT = DEMI_LIGHT,
-    BOOK,
-    NORMAL,
-    REGULAR = NORMAL,
-    MEDIUM,
-    DEMI_BOLD,
-    SEMI_BOLD = DEMI_BOLD,
-    BOLD,
-    ULTRA_BOLD,
-    EXTRA_BOLD = ULTRA_BOLD,
-    BLACK,
-    HEAVY = BLACK,
-    EXTRA_BLACK = BLACK
-  };
+enum Type
+{
+  NONE, ///< Means not defined. Will use what is set as default, currently NORMAL.
+  THIN,
+  ULTRA_LIGHT,
+  EXTRA_LIGHT = ULTRA_LIGHT,
+  LIGHT,
+  DEMI_LIGHT,
+  SEMI_LIGHT = DEMI_LIGHT,
+  BOOK,
+  NORMAL,
+  REGULAR = NORMAL,
+  MEDIUM,
+  DEMI_BOLD,
+  SEMI_BOLD = DEMI_BOLD,
+  BOLD,
+  ULTRA_BOLD,
+  EXTRA_BOLD = ULTRA_BOLD,
+  BLACK,
+  HEAVY       = BLACK,
+  EXTRA_BLACK = BLACK
+};
 
-  const char* const Name[] =
+const char* const Name[] =
   {
     "NONE",
     "THIN",
@@ -107,59 +108,83 @@ namespace FontWeight
     "DEMI_BOLD",
     "BOLD",
     "ULTRA_BOLD",
-    "BLACK"
-  };
-}
+    "BLACK"};
+} // namespace FontWeight
 
 namespace FontSlant
 {
-  /**
+/**
    * @brief Enumeration type for the font's slant
    */
-  enum Type
-  {
-    NONE,           ///< Means not defined. Will use what is set as default, currently NORMAL.
-    NORMAL,
-    ROMAN = NORMAL,
-    ITALIC,
-    OBLIQUE
-  };
+enum Type
+{
+  NONE, ///< Means not defined. Will use what is set as default, currently NORMAL.
+  NORMAL,
+  ROMAN = NORMAL,
+  ITALIC,
+  OBLIQUE
+};
 
-  const char* const Name[] =
+const char* const Name[] =
   {
     "NONE",
     "NORMAL",
     "ITALIC",
-    "OBLIQUE"
-  };
+    "OBLIQUE"};
 } // namespace FontSlant
 
 struct FontDescription
 {
+  enum Type
+  {
+    INVALID,     ///< Not valid font.
+    FACE_FONT,   ///< A face font.
+    BITMAP_FONT, ///< A bitmap font. Each glyph has a url with the bitmap.
+  };
+
   FontDescription()
   : path(),
     family(),
-    width( FontWidth::NONE ),
-    weight( FontWeight::NONE ),
-    slant( FontSlant::NONE )
-  {}
+    width(FontWidth::NONE),
+    weight(FontWeight::NONE),
+    slant(FontSlant::NONE),
+    type(INVALID)
+  {
+  }
+
+  FontDescription(const FontPath&         path,
+                  const FontFamily&       family,
+                  const FontWidth::Type&  width,
+                  const FontWeight::Type& weight,
+                  const FontSlant::Type&  slant,
+                  const Type&             type)
+  : path(path),
+    family(family),
+    width(width),
+    weight(weight),
+    slant(slant),
+    type(type)
+  {
+  }
 
   ~FontDescription()
-  {}
+  {
+  }
 
   FontPath         path;   ///< The font's file name path.
   FontFamily       family; ///< The font's family name.
   FontWidth::Type  width;  ///< The font's width.
   FontWeight::Type weight; ///< The font's weight.
   FontSlant::Type  slant;  ///< The font's slant.
+  Type             type;   ///< The type of font.
 };
 
 typedef std::vector<FontDescription> FontList;
 
-DALI_IMPORT_API std::ostream& operator<<( std::ostream& o, const FontList& fontList );
+DALI_ADAPTOR_API std::ostream& operator<<(std::ostream& o, const FontList& fontList);
 
 } // namespace TextAbstraction
 
 } // namespace Dali
 
-#endif // __DALI_TEXT_ABSTRACTION_FONT_LIST_H__
+#endif // DALI_TEXT_ABSTRACTION_FONT_LIST_H