diff options
Diffstat (limited to 'dali/devel-api/text-abstraction')
-rw-r--r-- | dali/devel-api/text-abstraction/bidirectional-support.cpp | 7 | ||||
-rw-r--r-- | dali/devel-api/text-abstraction/bidirectional-support.h | 10 | ||||
-rw-r--r-- | dali/devel-api/text-abstraction/font-client.cpp | 19 | ||||
-rw-r--r-- | dali/devel-api/text-abstraction/font-client.h | 24 | ||||
-rw-r--r-- | dali/devel-api/text-abstraction/hyphenation.cpp | 7 | ||||
-rw-r--r-- | dali/devel-api/text-abstraction/hyphenation.h | 10 | ||||
-rw-r--r-- | dali/devel-api/text-abstraction/segmentation.cpp | 7 | ||||
-rw-r--r-- | dali/devel-api/text-abstraction/segmentation.h | 10 | ||||
-rw-r--r-- | dali/devel-api/text-abstraction/shaping.cpp | 21 | ||||
-rw-r--r-- | dali/devel-api/text-abstraction/shaping.h | 23 |
10 files changed, 127 insertions, 11 deletions
diff --git a/dali/devel-api/text-abstraction/bidirectional-support.cpp b/dali/devel-api/text-abstraction/bidirectional-support.cpp index 4d7279cff..3ff069f76 100644 --- a/dali/devel-api/text-abstraction/bidirectional-support.cpp +++ b/dali/devel-api/text-abstraction/bidirectional-support.cpp @@ -43,6 +43,13 @@ BidirectionalSupport BidirectionalSupport::Get() return Internal::BidirectionalSupport::Get(); } +BidirectionalSupport BidirectionalSupport::New() +{ + auto bidirectionalSupportImpl = new Internal::BidirectionalSupport(); + + return BidirectionalSupport(bidirectionalSupportImpl); +} + BidiInfoIndex BidirectionalSupport::CreateInfo(const Character* const paragraph, Length numberOfCharacters, bool matchLayoutDirection, diff --git a/dali/devel-api/text-abstraction/bidirectional-support.h b/dali/devel-api/text-abstraction/bidirectional-support.h index d76a2bdba..80b65b405 100644 --- a/dali/devel-api/text-abstraction/bidirectional-support.h +++ b/dali/devel-api/text-abstraction/bidirectional-support.h @@ -69,10 +69,20 @@ public: * @brief Retrieve a handle to the BidirectionalSupport instance. * * @return A handle to the BidirectionalSupport + * @remarks A reference to the singleton instance of BidirectionalSupport. */ static BidirectionalSupport Get(); /** + * @brief Create a handle to the new BidirectionalSupport instance. + * + * @return A handle to the BidirectionalSupport. + * @remarks All functions of this are not thread-safe, + * so create new handles for each worker thread to utilize them. + */ + static BidirectionalSupport New(); + + /** * @brief Creates bidirectional data for the whole paragraph. * * @param[in] paragraph Pointer to the first character of the paragraph coded in UTF32. diff --git a/dali/devel-api/text-abstraction/font-client.cpp b/dali/devel-api/text-abstraction/font-client.cpp index 10e23d3f4..95845cd96 100644 --- a/dali/devel-api/text-abstraction/font-client.cpp +++ b/dali/devel-api/text-abstraction/font-client.cpp @@ -82,6 +82,15 @@ FontClient FontClient::Get() return Internal::FontClient::Get(); } +FontClient FontClient::New() +{ + auto fontClientImpl = new Internal::FontClient(); + + fontClientImpl->SetDpiFromWindowSystem(); + + return FontClient(fontClientImpl); +} + FontClient FontClient::New(uint32_t horizontalDpi, uint32_t verticalDpi) { auto fontClientImpl = new Internal::FontClient(); @@ -122,6 +131,11 @@ void FontClient::SetDpi(unsigned int horizontalDpi, unsigned int verticalDpi) GetImplementation(*this).SetDpi(horizontalDpi, verticalDpi); } +void FontClient::SetDpiFromWindowSystem() +{ + GetImplementation(*this).SetDpiFromWindowSystem(); +} + void FontClient::GetDpi(unsigned int& horizontalDpi, unsigned int& verticalDpi) { GetImplementation(*this).GetDpi(horizontalDpi, verticalDpi); @@ -284,6 +298,11 @@ bool FontClient::AddCustomFontDirectory(const FontPath& path) return GetImplementation(*this).AddCustomFontDirectory(path); } +void FontClient::ApplyCustomFontDirectories() +{ + GetImplementation(*this).ApplyCustomFontDirectories(); +} + GlyphIndex FontClient::CreateEmbeddedItem(const EmbeddedItemDescription& description, Pixel::Format& pixelFormat) { return GetImplementation(*this).CreateEmbeddedItem(description, pixelFormat); diff --git a/dali/devel-api/text-abstraction/font-client.h b/dali/devel-api/text-abstraction/font-client.h index 61647ec1b..4ce027e23 100644 --- a/dali/devel-api/text-abstraction/font-client.h +++ b/dali/devel-api/text-abstraction/font-client.h @@ -99,15 +99,27 @@ public: * @brief Retrieve a handle to the FontClient instance. * * @return A handle to the FontClient + * @remarks A reference to the singleton instance of FontClient. */ static FontClient Get(); /** * @brief Create a handle to the new FontClient instance. * + * @return A handle to the FontClient + * @remarks All functions of this are not thread-safe, + * so create new handles for each worker thread to utilize them. + */ + static FontClient New(); + + /** + * @brief Create a handle to the new FontClient instance. + * * @param[in] horizontalDpi The horizontal resolution in DPI. * @param[in] verticalDpi The vertical resolution in DPI. * @return A handle to the FontClient + * @remarks All functions of this are not thread-safe, + * so create new handles for each worker thread to utilize them. */ static FontClient New(uint32_t horizontalDpi, uint32_t verticalDpi); @@ -180,6 +192,13 @@ public: void SetDpi(unsigned int horizontalDpi, unsigned int verticalDpi); /** + * @brief Sets the DPI of the FontClient based on the current window's DPI. + * + * @note Multiple windows are not currently supported. + */ + void SetDpiFromWindowSystem(); + + /** * @brief Retrieves the DPI previously set to the target window. * * @note Multiple windows are not currently supported. @@ -495,6 +514,11 @@ public: bool AddCustomFontDirectory(const FontPath& path); /** + * @brief Apply custom fonts directories + */ + void ApplyCustomFontDirectories(); + + /** * @brief Creates and stores an embedded item and it's metrics. * * If in the @p description there is a non empty url, it calls Dali::LoadImageFromFile() internally. diff --git a/dali/devel-api/text-abstraction/hyphenation.cpp b/dali/devel-api/text-abstraction/hyphenation.cpp index 40a0da40f..579db0009 100644 --- a/dali/devel-api/text-abstraction/hyphenation.cpp +++ b/dali/devel-api/text-abstraction/hyphenation.cpp @@ -43,6 +43,13 @@ Hyphenation Hyphenation::Get() return Internal::Hyphenation::Get(); } +Hyphenation Hyphenation::New() +{ + auto hyphenationImpl = new Internal::Hyphenation(); + + return Hyphenation(hyphenationImpl); +} + const char* Hyphenation::GetDictionaryEncoding(const char* lang) { return GetImplementation(*this).GetDictionaryEncoding(lang); diff --git a/dali/devel-api/text-abstraction/hyphenation.h b/dali/devel-api/text-abstraction/hyphenation.h index b8d5cfe74..d7190ce49 100644 --- a/dali/devel-api/text-abstraction/hyphenation.h +++ b/dali/devel-api/text-abstraction/hyphenation.h @@ -79,10 +79,20 @@ public: * @brief Retrieve a handle to the Hyphenation instance. * * @return A handle to the Hyphenation. + * @remarks A reference to the singleton instance of Hyphenation. */ static Hyphenation Get(); /** + * @brief Create a handle to the new Hyphenation instance. + * + * @return A handle to the Hyphenation. + * @remarks All functions of this are not thread-safe, + * so create new handles for each worker thread to utilize them. + */ + static Hyphenation New(); + + /** * * Gets the encoding of the dictionary for the given language * diff --git a/dali/devel-api/text-abstraction/segmentation.cpp b/dali/devel-api/text-abstraction/segmentation.cpp index fa5a01b18..8436ca540 100644 --- a/dali/devel-api/text-abstraction/segmentation.cpp +++ b/dali/devel-api/text-abstraction/segmentation.cpp @@ -43,6 +43,13 @@ Segmentation Segmentation::Get() return Internal::Segmentation::Get(); } +Segmentation Segmentation::New() +{ + auto segmentationImpl = new Internal::Segmentation(); + + return Segmentation(segmentationImpl); +} + void Segmentation::GetLineBreakPositions(const Character* const text, Length numberOfCharacters, LineBreakInfo* breakInfo) diff --git a/dali/devel-api/text-abstraction/segmentation.h b/dali/devel-api/text-abstraction/segmentation.h index 42df64f0a..6023e3eaa 100644 --- a/dali/devel-api/text-abstraction/segmentation.h +++ b/dali/devel-api/text-abstraction/segmentation.h @@ -70,10 +70,20 @@ public: * @brief Retrieve a handle to the Segmentation instance. * * @return A handle to the Segmentation + * @remarks A reference to the singleton instance of Segmentation. */ static Segmentation Get(); /** + * @brief Create a handle to the new Segmentation instance. + * + * @return A handle to the Segmentation. + * @remarks All functions of this are not thread-safe, + * so create new handles for each worker thread to utilize them. + */ + static Segmentation New(); + + /** * @brief Retrieves the line break info. * * @pre @p breakInfo must have enough space allocated for @p numberOfCharacters. diff --git a/dali/devel-api/text-abstraction/shaping.cpp b/dali/devel-api/text-abstraction/shaping.cpp index 3d9f541ac..5fa10f526 100644 --- a/dali/devel-api/text-abstraction/shaping.cpp +++ b/dali/devel-api/text-abstraction/shaping.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 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. @@ -43,12 +43,21 @@ Shaping Shaping::Get() return Internal::Shaping::Get(); } -Length Shaping::Shape(const Character* const text, - Length numberOfCharacters, - FontId fontId, - Script script) +Shaping Shaping::New() { - return GetImplementation(*this).Shape(text, + auto shapingImpl = new Internal::Shaping(); + + return Shaping(shapingImpl); +} + +Length Shaping::Shape(TextAbstraction::FontClient& fontClient, + const Character* const text, + Length numberOfCharacters, + FontId fontId, + Script script) +{ + return GetImplementation(*this).Shape(fontClient, + text, numberOfCharacters, fontId, script); diff --git a/dali/devel-api/text-abstraction/shaping.h b/dali/devel-api/text-abstraction/shaping.h index 8dd705362..c7fe312a7 100644 --- a/dali/devel-api/text-abstraction/shaping.h +++ b/dali/devel-api/text-abstraction/shaping.h @@ -2,7 +2,7 @@ #define DALI_PLATFORM_TEXT_ABSTRACTION_SHAPING_H /* - * Copyright (c) 2020 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. @@ -20,6 +20,7 @@ // INTERNAL INCLUDES #include <dali/devel-api/text-abstraction/emoji-helper.h> +#include <dali/devel-api/text-abstraction/font-client.h> #include <dali/devel-api/text-abstraction/script.h> #include <dali/devel-api/text-abstraction/text-abstraction-definitions.h> @@ -85,14 +86,25 @@ public: * @brief Retrieve a handle to the Shaping instance. * * @return A handle to the Shaping. + * @remarks A reference to the singleton instance of Shaping. */ static Shaping Get(); /** + * @brief Create a handle to the new Shaping instance. + * + * @return A handle to the Shaping. + * @remarks All functions of this are not thread-safe, + * so create new handles for each worker thread to utilize them. + */ + static Shaping New(); + + /** * Shapes the text. * * Call GetGlyphs() to retrieve the glyphs. * + * @param[in] fontClient FontClient to use in this function. * @param[in] text Pointer to the first character of the text coded in UTF32. * @param[in] numberOfCharacters The number of characters to be shaped * @param[in] fontId The font to be used to shape the text. @@ -100,10 +112,11 @@ public: * * @return The size of the buffer required to get the shaped text. */ - Length Shape(const Character* const text, - Length numberOfCharacters, - FontId fontId, - Script script); + Length Shape(TextAbstraction::FontClient& fontClient, + const Character* const text, + Length numberOfCharacters, + FontId fontId, + Script script); /** * Gets the shaped text data. |