ultralight-ux / Ultralight

Lightweight, high-performance HTML renderer for game and app developers.
https://ultralig.ht
4.68k stars 195 forks source link

Cannot render text with italic/bold style if I use external font #76

Open cfadamp opened 5 years ago

cfadamp commented 5 years ago

Summarize the Issue Most of the cases we use our own font files for text rendering. I noticed that in recent 0.9.2 build I could not apply italic and bold styling to the text while using external font. It works if I use default HTML fonts, but not with external loaded fonts.

Steps to Reproduce I can reproduce the problem with the following html code every time:

<html>
<style> @font-face { font-family: myFont; src: url(file:///C:/htmltest/comic.ttf) format("truetype"); } </style><body>
<p>
<span style="font-family: myFont; font-size: 57px; font-style: italic; font-weight: normal;">Italic text</span></br>
<span style="font-family: myFont; font-size: 57px; font-style: normal; font-weight: bold;">Bold text</span></br>
<span style="font-family: myFont; font-size: 57px; font-style: italic; font-weight: bold;">Italic and bold text</span>
</p></body></html>

Platform Info:

adamjs commented 5 years ago

Was this a TrueType Collection file (TTC) or regular TTF? Most font files contain a single font-face so you have to load separate TTFs for bold and italic.