#include <dali/devel-api/text-abstraction/font-client.h>
#include <dali/devel-api/text-abstraction/glyph-info.h>
#include <dali/integration-api/debug.h>
+#include "font-client-impl.h"
// EXTERNAL INCLUDES
#include <harfbuzz/hb.h>
#include <harfbuzz/hb-ft.h>
-#include <ft2build.h>
-#include <iostream>
-
namespace Dali
{
namespace Internal
{
-const char* DEFAULT_LANGUAGE = "en";
+const char* const DEFAULT_LANGUAGE = "en";
const unsigned int DEFAULT_LANGUAGE_LENGTH = 2u;
const float FROM_266 = 1.0f / 64.0f;
struct Shaping::Plugin
{
Plugin()
- : mFreeTypeLibrary( NULL ),
- mIndices(),
+ : mIndices(),
mAdvance(),
mCharacterMap(),
mFontId( 0u )
~Plugin()
{
- FT_Done_FreeType( mFreeTypeLibrary );
- }
-
- void Initialize()
- {
- int error = FT_Init_FreeType( &mFreeTypeLibrary );
- if( FT_Err_Ok != error )
- {
- DALI_LOG_ERROR( "FreeType Init error: %d\n", error );
- }
}
Length Shape( const Character* const text,
mOffset.Reserve( 2u * numberOfGlyphs );
TextAbstraction::FontClient fontClient = TextAbstraction::FontClient::Get();
-
- // Get the font's path file name from the font Id.
- FontDescription fontDescription;
- fontClient.GetDescription( fontId, fontDescription );
+ TextAbstraction::Internal::FontClient& fontClientImpl = TextAbstraction::GetImplementation( fontClient );
// Create a FreeType font's face.
FT_Face face;
- FT_Error retVal = FT_New_Face( mFreeTypeLibrary, fontDescription.path.c_str(), 0u, &face );
- if( FT_Err_Ok != retVal )
+
+ face = fontClientImpl.GetFreetypeFace( fontId );
+ if( nullptr == face )
{
- DALI_LOG_ERROR( "Failed to open face: %s\n", fontDescription.path.c_str() );
+ // Nothing to do if the face is null.
return 0u;
}
- unsigned int horizontalDpi = 0u;
- unsigned int verticalDpi = 0u;
- fontClient.GetDpi( horizontalDpi, verticalDpi );
-
- FT_Set_Char_Size( face,
- 0u,
- fontClient.GetPointSize( fontId ),
- horizontalDpi,
- verticalDpi );
-
/* Get our harfbuzz font struct */
hb_font_t* harfBuzzFont;
harfBuzzFont = hb_ft_font_create( face, NULL );
/* Cleanup */
hb_buffer_destroy( harfBuzzBuffer );
hb_font_destroy( harfBuzzFont );
- FT_Done_Face( face );
return mIndices.Count();
}
}
}
- FT_Library mFreeTypeLibrary;
-
Vector<CharacterIndex> mIndices;
Vector<float> mAdvance;
Vector<float> mOffset;
if( !mPlugin )
{
mPlugin = new Plugin();
- mPlugin->Initialize();
}
}