Merge "[AT-SPI] Rework intercepting key events" into devel/master
[platform/core/uifw/dali-adaptor.git] / dali / internal / text / text-abstraction / plugin / font-client-utils.cpp
index 445e026..a6d56fa 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 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.
@@ -131,10 +131,10 @@ const FontSlant::Type IntToSlantType(int slant)
   return static_cast<FontSlant::Type>(ValueToIndex(slant, FONT_SLANT_TYPE_TO_INT, NUM_FONT_SLANT_TYPE - 1u));
 }
 
-const std::string DEFAULT_FONT_FAMILY_NAME("Tizen");
-const int         DEFAULT_FONT_WIDTH(100);
-const int         DEFAULT_FONT_WEIGHT(80);
-const int         DEFAULT_FONT_SLANT(0);
+const char* DEFAULT_FONT_FAMILY_NAME("Tizen");
+const int   DEFAULT_FONT_WIDTH(100);
+const int   DEFAULT_FONT_WEIGHT(80);
+const int   DEFAULT_FONT_SLANT(0);
 
 const std::string_view DefaultFontFamily()
 {
@@ -161,7 +161,7 @@ const FontSlant::Type DefaultFontSlant()
  * @param[in] srcHeight The height of the bitmap.
  * @param[in] srcBuffer The buffer of the bitmap.
  */
-void ConvertBitmap(TextAbstraction::FontClient::GlyphBufferData& data, unsigned int srcWidth, unsigned int srcHeight, const unsigned char* const srcBuffer, const Pixel::Format srcFormat)
+void ConvertBitmap(TextAbstraction::GlyphBufferData& data, unsigned int srcWidth, unsigned int srcHeight, const unsigned char* const srcBuffer, const Pixel::Format srcFormat)
 {
   // Set the input dimensions.
   const ImageDimensions inputDimensions(srcWidth, srcHeight);
@@ -176,7 +176,7 @@ void ConvertBitmap(TextAbstraction::FontClient::GlyphBufferData& data, unsigned
   data.format = srcFormat;
 
   // Note we don't compress here
-  data.compressionType = TextAbstraction::FontClient::GlyphBufferData::CompressionType::NO_COMPRESSION;
+  data.compressionType = TextAbstraction::GlyphBufferData::CompressionType::NO_COMPRESSION;
 
   const uint32_t bytePerPixel = Dali::Pixel::GetBytesPerPixel(srcFormat);
 
@@ -193,6 +193,12 @@ void ConvertBitmap(TextAbstraction::FontClient::GlyphBufferData& data, unsigned
   {
     data.isBufferOwned = true;
     data.buffer        = (uint8_t*)malloc(bufferSize); // @note The caller is responsible for deallocating the bitmap data using free.
+
+    if(DALI_UNLIKELY(!data.buffer))
+    {
+      DALI_LOG_ERROR("malloc is failed. request malloc size : %u\n", bufferSize);
+      return;
+    }
     Dali::Internal::Platform::LanczosSample(srcBuffer,
                                             inputDimensions,
                                             srcWidth,
@@ -211,7 +217,7 @@ void ConvertBitmap(TextAbstraction::FontClient::GlyphBufferData& data, unsigned
  * @param[in] moveBuffer Whether the bitmap buffer move. True if just copy buffer pointer. False if we use memcpy. (Default is false.)
  * @note If you set moveBuffer=true, the bitmap's buffer moved frome srcBitmap to data. So srcBitmap buffer changed as nullptr.
  */
-void ConvertBitmap(TextAbstraction::FontClient::GlyphBufferData& data, FT_Bitmap& srcBitmap, bool isShearRequired, bool moveBuffer)
+void ConvertBitmap(TextAbstraction::GlyphBufferData& data, FT_Bitmap& srcBitmap, bool isShearRequired, bool moveBuffer)
 {
   data.buffer = nullptr;
   if(srcBitmap.width * srcBitmap.rows > 0)
@@ -305,7 +311,7 @@ void ConvertBitmap(TextAbstraction::FontClient::GlyphBufferData& data, FT_Bitmap
           data.format = Pixel::L8; // Sets the pixel format.
 
           // Note we don't compress here
-          data.compressionType = TextAbstraction::FontClient::GlyphBufferData::CompressionType::NO_COMPRESSION;
+          data.compressionType = TextAbstraction::GlyphBufferData::CompressionType::NO_COMPRESSION;
 
           if(moveBuffer)
           {