Languages

Menu
Sites
Language
Custom font family in Tizen Native App ( Using .ttf )

i am creating my tizen native app, and i want to change the fonts in my app using .ttf file of fonts

here is muy Code :

i had defined the path of my font file as below

#define LATO_REGULAR "/opt/usr/apps/org.example.taskist/res/Font/Lato-Regular.ttf"

then i had Appended a font path to the list of font paths used by the application :

evas_font_path_global_append(LATO_REGULAR);

now time to use the fonts in the texts of th label :

i created the Label by below code :

ad->label= elm_label_add(ad->Box);
elm_object_text_set(ad->label,"<font=Lato:style=Regular font_size=40>Title</font>");
my_box_pack(ad->Box,ad->label, 1.0, 0.0, -1.0, 0.5);

this code is showing the simple label "Title" (without the Lato-Regular fonts) .

and i need a label only istead of 

Evas_Object *text= evas_object_text_add(e);
evas_object_text_font_set(text,LATO_REGULAR, 40);

Please Help , Thanks

View Selected Answer

Responses

13 Replies
Yasin Ali

Hi,

Check this site for Font related code and their implementation in detailed form.

https://developer.tizen.org/development/guides/native-application/user-interface/efl/fonts#edje

See Using the Edje Text Class.

Hope it will help.

 

Dinal Jivani

Hello Yasin Ali , 

Thank You , but I am not getting exactly, Can you please help me with a Code Example .

bhoomika rathod

I also tried this way but i didn't get any solution for the same issue. Is there any other way?
Plz help.

Shaswati Saha

According to this link, the way to do this using EDC doesn't work. So, I would like to suggest you to follow the link Yasin Ali suggested and try doing it using EDC. Please share your status here after trying with EDC.

Dinal Jivani

i had already used my font using EDC as below;

fonts {
 //  font: "Digital.otf" "LED";
}

collections {

 //  base_scale:1.0;
   group { name: "main";
      parts
      {
                part { 
                name: "text_example";
                type: TEXT;
                description { state: "default" 0;
                   color: 255 255 255 255;
                   rel1 {
                      relative: 0.2 0.2;
                   }
                   rel2 {
                      relative: 0.8 0.3;
                   }
                   text {
                      text: "Dinal";
                      font: "LED";
                      size: 25;
                      align: 0.5 0;
                   }
                }
             }

        }
    }
}

and it (EDC) is working very well.

 

but the problem is what if i want to use it in label component in .C file : 

label=elm_label_add(ad->conform);

evas_object_text_set(label,"<font=LED><align=center><font_size=60><color=#FFFFFF>Dinal</color></font_size></font><align>");

i know this might be wrong way but ,how should i use my font (LED) in above line ,

my font is in /res/ folder 

i already used evas_font_path_global_append() , FcConfigAppFontAddFile()

but i had no success for that .

Regards

 

 

Dinal Jivani

sorry for the comment issue in my above code

fonts {
   font: "Digital.otf" "LED";
}

 

Shaswati Saha

Would you please try with below code?

char *buf = "<font=Sans:style=Regular font_size=50>Hello</font/>Font";
elm_object_part_text_set(layout, "textblock1", buf);

According to the Setting the Font for a UI Component section, it might work.

Dinal Jivani

it will work for a obvious but it will consider whole text and display : 

"<font=Sans:style=Regular font_size=50>Hello</font/>Font"

instead of 'Hello Font'

the styles to this text will be of EDC and not those given from the string

i.e. : <font=Sans:style=Regular font_size=50> ............

but my Ecact question is , how can i use my font in label without using any EDC Code .

Thank You, Dinal Jivani

GEUNSOO KIM

If you want to use inline-styles on EDC elements, you should use TEXTBLOCK type for the text part, not TEXT type.

Dinal Jivani

forget about the EDC my brother GEUNSOO KIM

what if i want to give font family to label in .C file without any EDC code

GEUNSOO KIM

well... I never tried that way,  so I cannot sure my comment will help you out from the issue or not. it is up to you.

In common sense, you should register your font into system no matter what.

It could be layout EDC or theme EDC. yes, you need EDC anyway as far as I known. there could be other ways but I don't know.

I think that defining a theme with your style and after loading the theme, you can use the style as you expected.

Dinal Jivani

Hello Everyone ,

while doing research and development i got some stuff , i had tried but didn't got it :

if you understand it properly, please help , have a look at this code :


#include <fontconfig/fontconfig.h>

#define FONT "/opt/usr/apps/org.example.watchapplication/res/font/"

call it before create_base_gui(ad);

FcConfigAppFontAddFile(NULL, (const FcChar8 *) FONT"Organo.ttf");
create_base_gui(ad);

and then use it in this way : Use filename as a Font Family name

evas_object_text_font_set(ad->text, "Organo", 20)

Mark as answer
Dinal Jivani

Hello Everyone , 

well finally I got the solution for using the font in .C file 

we can use those fonts in using evas_object_text_add 

here's the Code :

#define FONT "/opt/usr/apps/com.weetech.digital.clock.led.color.themes/res/font/"


ad->Date=evas_object_text_add(ad->layout);
evas_object_text_text_set(ad->Date,"01 - 19 - 2018");
evas_object_text_font_set(ad->Date, FONT"Digital.otf",50);
evas_object_color_set(ad->Date, 250, 150, 0, 255);
elm_object_part_content_set(ad->layout, "Date", ad->Date);

Luckily, Its working Good 

Thanks, Dinal Jivani    :D  :)