Using custom fonts
TheSystemIsCorrupt opened this issue · 4 comments
Hi, it's few days I found your library it's very clean, nice and smooth, thank you so much for this great library.
I was working with ultralight and qtwebengine and they are heavy for what I want and lcui is just what I needed.
I could successfully build all the lcui projects and demos and now I started to learn how it works, I couldn't find any documatiaon in english that tells how to connect ui to backend c like clicks and data syncing.
Currently i attempted to use a custom font for the page I searched in lcui-design and found out some fontface interface inside css files, I tried it but it doesn't work.
This is my file structre :
app-start.exe
app_data/style.css
app_data/main.xml
app_data/font.ttf
Here's main.xml :
<?xml version="1.0" encoding="UTF-8" ?>
<LCUI-app>
<resource type="text/css" src="app_data\style.css"/>
<ui>
<w type="textview" class="big_header">Hello World</w>
</ui>
</LCUI-app>
And here's style.css :
@font-face
{
font-family: 'textfont';
src: url("font.ttf");
}
.big_header
{
font-family: textfont;
font-size:30px;
color: #eeeeee;
text-align: center;
width:100%;
margin-top: 20px;
}
root
{
font-family: textfont;
min-width: 920px;
min-height: 480px;
background-color: #7940ff;
}
Application runs without any error but the font never gets applied, am I missing something?
How can I use a custom font?
LCUI loads the font file specified by src
in @font-face
, but does not register the font with a new font-family
in the font library. Therefore, you need to use the default font family name in the font file.
Lines 1079 to 1098 in ae7d27c
@lc-soft thanks! Does this mean we only can have one font for our application ui?
Can you explain what you mean from :
> Therefore, you need to use the default word family name in the font file.
Let's say I have Impact.ttf and Roboto.ttf is it possible to use them both in same ui page? if yes how?
Oh now I get it, the font name inside the font file!
Some other note if someone seek for same thing, in html/css font path should be releative to css file but in lcui it should be relative to app/exe file.
/* Bold */
@font-face
{
src: url("app_Data/font.ttf");
}
/* Light */
@font-face
{
src: url("app_Data/font2.ttf");
}