summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorali-alzyod <ali198724@gmail.com>2021-08-30 21:13:38 +0300
committerali-alzyod <ali198724@gmail.com>2021-08-30 21:13:38 +0300
commit3a5d04b12506daf0e6ce41b218190e65f68cdc3a (patch)
tree430114fb49f39186402f81e12bcaffcae0cc4424 /src/lib
parentdfd0bafdcc8adbc97a43a878c84c25991a627405 (diff)
downloadefl-3a5d04b12506daf0e6ce41b218190e65f68cdc3a.tar.gz
Content Fit Enhancment
Summary: Allow user to get currently used font size when Text Fitting is enabled. previously, the user can not know what is current font size, he only specifies font size ranges, and the algorithm internally decides suitable font size. with this change, the user has the ability to know the font size, that the fitting algorithm has picked Reviewers: raster Subscribers: raster, cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D12288
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c16
-rw-r--r--src/lib/evas/canvas/evas_textblock_legacy.h7
2 files changed, 23 insertions, 0 deletions
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index 8f339fe5d2..12bcd38eda 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -431,6 +431,7 @@ struct _TEXT_FIT_CONTENT_CONFIG
unsigned int min_font_size,max_font_size;
unsigned int step_size;
unsigned int *p_size_array;
+ int font_size;
size_t size_list_length;
Eina_Size2D size_cache[256+1]; /** used hash font sizes 1-255 */
Eina_Size2D last_size;
@@ -17881,6 +17882,7 @@ int fit_text_block(Evas_Object *eo_obj)
/*Lower bound founded, subtract one to move for nearest value*/
fc->last_size_index = MAX(l-1, 0);
fit_style_update(eo_obj,fc->p_size_array[fc->last_size_index],(fc->last_size_index != 0) && fc->options != TEXTBLOCK_FIT_MODE_HEIGHT ,EINA_FALSE);
+ fc->font_size = fc->p_size_array[fc->last_size_index];
fit_finish_fitting(eo_obj);
}
}
@@ -18052,6 +18054,20 @@ int compareUINT(const void * a, const void * b)
else return 0;
}
+EVAS_API int evas_textblock_fit_font_size_get(Evas_Object *obj){
+ EINA_SAFETY_ON_NULL_RETURN_VAL(obj, EVAS_ERROR_INVALID_PARAM);
+ Efl_Canvas_Textblock_Data *o = efl_data_scope_get(obj, MY_CLASS);
+ TEXT_FIT_CONTENT_CONFIG *fc = &o->fit_content_config;
+ if (fc->options == TEXTBLOCK_FIT_MODE_NONE)
+ {
+ return -1;
+ }
+ else
+ {
+ return fc->font_size;
+ }
+}
+
EVAS_API int evas_textblock_fit_size_array_set(Evas_Object *obj, const unsigned int *p_size_array, size_t size_array_len)
{
int n_ret = EVAS_ERROR_SUCCESS;
diff --git a/src/lib/evas/canvas/evas_textblock_legacy.h b/src/lib/evas/canvas/evas_textblock_legacy.h
index ae1aaf72b6..e4fee16149 100644
--- a/src/lib/evas/canvas/evas_textblock_legacy.h
+++ b/src/lib/evas/canvas/evas_textblock_legacy.h
@@ -1143,6 +1143,13 @@ EVAS_API int evas_textblock_fit_size_array_get(const Evas_Object *obj, unsigned
*/
EVAS_API int evas_textblock_fit_size_array_set(Evas_Object *obj, const unsigned int *p_size_array, size_t size_array_len);
+/** Get the object fitting font size that is currently used.
+ *
+ * @param obj The textblock object.
+ * @return Returns current used font size for fitting, or -1 if there is no fitting.
+ * @since 1.26
+ */
+EVAS_API int evas_textblock_fit_font_size_get(Evas_Object *obj);