GithubHelp home page GithubHelp logo

Using custom fonts about lcui HOT 4 CLOSED

TheSystemIsCorrupt avatar TheSystemIsCorrupt commented on June 2, 2024
Using custom fonts

from lcui.

Comments (4)

lc-soft avatar lc-soft commented on June 2, 2024 1

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.

LCUI/src/gui/css_parser.c

Lines 1079 to 1098 in ae7d27c

static void LoadFontFile(void *arg1, void *arg2)
{
LCUIFont_LoadFile(arg1);
LCUIWidget_RefreshTextView();
}
static void OnParsedFontFace(LCUI_CSSFontFace face)
{
static int worker_id = -1;
LCUI_TaskRec task = { 0 };
task.func = LoadFontFile;
task.arg[0] = strdup2(face->src);
task.destroy_arg[0] = free;
if (worker_id > -1) {
LCUI_PostAsyncTaskTo(&task, worker_id);
} else {
worker_id = LCUI_PostAsyncTask(&task);
}
}

from lcui.

TheSystemIsCorrupt avatar TheSystemIsCorrupt commented on June 2, 2024 1

@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?

from lcui.

TheSystemIsCorrupt avatar TheSystemIsCorrupt commented on June 2, 2024 1

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");
}

from lcui.

TheSystemIsCorrupt avatar TheSystemIsCorrupt commented on June 2, 2024

Same source works in firefox :
lcui-vs-firefox

<!DOCTYPE html>
<html>
	<head>
	  <link rel="stylesheet" href="app_data\style.css">
	</head>
	
	<body>
	  <ui>
		<div type="textview" class="header_text">Hello World!</div>
	  </ui>
	</body>
</html> 

from lcui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.