View Full Version : Proposed changes to the FONT-system!
jmarshall
2005-06-24, 19:11
hi again,
as you are all aware, ttf fonts are now running very nicely. they are as fast as using xpr fonts, but use less memory. furthermore, you don't need to generate a different size/style for each thing you want to deal with + they have the added benefit of being easy to obtain and being able to render foreign character sets easily.
the old font system was designed primarily for xpr fonts, and is cumbersome + bothersome to use with ttf fonts. sure, it works fine as it is from a skinners perspective, but doesn't work from a users perspective (hard to change fonts for eastern language users) or from a python scripters perspective (have to "guess" or do workarounds to find what fonts are loaded).
i thus propose the following changes to the font system.
font.xml will now no longer contain differing <fontset> blocks - instead, it should have only 1 block.
secondly, the setup will go as follows:
<fonts>
<defaultfont>arial.ttf</defaultfont>
<font>
<name>special12</name>
<size>16</size>
</font>
<font>
<name>special13</name>
<size>16</size>
<style>bold</style>
</font>
</fonts>
the changes are basically that the fontsets are gone, as are the <filename> tags. you only have the possibility of using the one font, but ofcourse you have the <style> tag to get italics, bold, and bolditalics as you wish. the fonts are referenced by their <name> tags in the other skin files as per usual.
in xbmc, on skin load, it'll load the <defaultfont> font up and use that, unless the user has requested an alternative one (located either in the skin/fonts folder, or in xbmc/media/fonts).
the fonts from within xbmc will be referenced by the following naming system:
fontxxxyy
where xxx is the size, and yy is an optional style parameter (b, i, or bi)
the "normal" fonts we've had up till now (font13 etc.) will thus be auto-translated over by xbmc to the new system, so old python scripts and the like shouldn't need updating.
now, this is all just a proposal - nothing has been set in stone, in fact i've only just started thinking about things.
if any of you can see any issues with it, please raise them now. one thing i'm not sure how to handle is differing resolutions from within python. currently each script has to take care of this for scaling everything else, though, so really this isn't all that much of an issue imo.
note that it will require a compatibility upgrade, thus the skin version will need increasing.
cheers,
jonathan
this is one of the best news you gave us jonathan, finally we will not have to worry about creating xpr fonts anymore and the possibilty to select the style is just a great!
tnx :)
ok, this may sound stupid, but how about giving skinners the option to render text 90degrees cw or ccw maybe some cases where there's not enough room to do it horiz.
:nuts:
so this will be ditching the xpr fonts then? is the only purpose now of the font.xml file now just for <defaultfont>? so the current names like 'font12' will translate into '<defaultfont>12'?
i think a python script should be able to have their own fonts dir (in their cwd) so they can include their own fonts and finally be able to fully control their appearance.
while we are talking about font styles, is there a way to do an outline of a font? this would look great in skins and subtitles.
Chokemaniac
2005-06-26, 23:50
xpr fonts can have outlines and shadows.. hope we're not completely getting rid of xpr fonts....
was always a good way to "hide" the true font - i was always using payfonts for my skins. i guess with ttf fonts the copyright will be a biggr issue since everybody coud use ttf fonts h downloaded with a skin on his comp while xpr fonts ar rather useless.
i know other xbox apps are working with ttf allready, but i think xbmc was aways different when it comes to copyrirights
plus xpr fonts are still clearly smoother (specialy in hdtv resos)
yet all im saying is - dont ditch xpr completely...
/chokey
hiding them doesn't make things more legal *:d
anyways, i think it would be nice if you could load your own fonts with scripts (naturally scriptwise will be my take on this). i can see several ways of doing this and i can't really decide*which would be most convenient..
1. you make your own font.xml and load a font in same dir as this file. this would need to be appended to the already loaded font info, thus you should use your own names. cmd could be like xbmc.loadfont("q:\\scripts\\whatever\\font.xml"). then you just proceed as usual.
2. you could do it that same way as now. much more to code into each line because of the parameter, but perhaps easier for beginners?
eg. xbmcgui.controllabel(1,1,1,1, [fontname (either loaded or filename), size, style, ??])
this presented, i don't know if this is even in question at all...would this be possible and something you would be willing to incorporate? it's kinda enough of a pain getting things to work nice on all tvs/builds/skins already than to stumble upon users with builds where some fonts are missing from main xbmc xml and thus no text is shown or whatever.
the most important thing here is that scripters need larger fonts than font14. at least that's my opinion on it, and a more customisable system would be really good (which we're getting here no matter the outcome as long as ttf is an option in the xml)
last, thanks for bringing this up jonathan. :)
Gamester17
2005-06-27, 09:37
i like to suggest that we collect and add as many legal ttf-fonts to the xbmc cvs as well (preferably open sourced if possible, but as long as they are free to use for non-commersial projects they will due), that way normal end-users don't have to have to copy fonts from their windows computers to get the ones they need or want, and skinners/python-writters will always have access to a wide base of fonts that they know is always there. ...as a start i think sourceforge.net (http://sourceforge.net) and freshmeat.net (http://www.freshmeat.net) can be scavaged for usage/reusabe fonts (linux-distrubutions could be another source), (check for example out corefonts (http://sourceforge.net/projects/corefonts/), xf86-corefonts (http://sourceforge.net/projects/font-tool/), linux libertine open fonts (http://sourceforge.net/projects/linuxlibertine/), metatype (http://sourceforge.net/projects/metatype/), free unicode fonts (http://sourceforge.net/projects/freeunifont/), vietunicode (http://sourceforge.net/projects/vietunicode/), culmus (http://sourceforge.net/projects/culmus/), cjk-environment (http://sourceforge.net/projects/cce2k/), free bangla fonts (http://www.nongnu.org/freebangfont/), lala (http://freshmeat.net/projects/linuxalexlala/), dustismo (http://freshmeat.net/projects/dustismofont/)) * *...if you find a font in a other format than ttf then mayhe you can try converting it to ttf?, or even create your own (there are many free programs to do this available on sourceforge.net (http://sourceforge.net)/freshmeat.net (http://www.freshmeat.net)).
edit: there's also a huge link-collection of mostly free to use (for non-commersial pursoses) on microsoft's typography (font) site (http://www.microsoft.com/typography/links/links.aspx?type=foundries&part=1)
http://www.dafont.com
http://www.acidfonts.com/dingbats1.htm
http://www.webpagepublicity.com/free-fonts.html
ps! off-topic, i agree with chokemaniac that to have support for outlines and shadows on our ttf fonts too would be a great addition to xbmc as well :cool:
@jmarshall, off-topic to above but on-topic for subject of this thread: checkout, open type organizer (http://sourceforge.net/projects/oto) ttf_lib (http://freshmeat.net/projects/ttf_lib/), choosefont (http://freshmeat.net/projects/choosefont/) and fontlinge (http://freshmeat.net/projects/fontlinge/) lovely features.
yeah, if enough good fonts are included i can't see that much of a reason to include font loading capabilites from scripts. it works out the way it is now, and with lots of more choices and especially sizes things would work out good i think. if it's not that much work to include it in python i guess it wouldn't hurt, but it seems to me it would require some planning?
i wish more people jumped in here...
jmarshall
2005-06-27, 22:57
thanks all for the responses thus-far (hopefully there'll be some more contributing as well!)
i am planning on ditching xpr fonts completely, if at all possible. reason is obvious: they can't (easily) handle different fontsets. nothing much can be done about the "smoothness" or otherwise unfortunately - the aliasing is done within the ttf engine. i personally haven't noticed too much of a difference to warrant hanging on to xpr.
as for outlining + shadowing, perhaps we can come up with something for that...
the main idea was to get the font manager to load the fonts as they're needed (currently they're only loaded on skin load - even if they aren't needed until later), and to remove the size/style restrictions on python scripts.
for scripters, the idea is that you just have to change the fontname that you pass to controls (ie no real changes to the interface at all)
eg:
font_18b
will use the normal skin font, size 18, in bold etc.
we could perhaps extend this so that you can also do:
q:\scripts\fonts\blah.ttf_26bi
to load the awesome font blah.ttf in size 26, bold italic, but imo it's better to have scripts use the normal skin stuff as much as possible to keep things consistent (though i know that's difficult in a lot of cases)
orientation vertically is doable, but probably won't be done short-term.
and lastly, i'd personally prefer that we didn't distribute a large number of fonts with the standard xbmc cvs - i don't see the reason for it, as it's generally in the skinners realm to state what type of font "look" they want. then we just include the arial.ttf as a backup for those that require it for foreign language support.
cheers,
jonathan
Nuka1195
2005-06-30, 21:38
the thing with having a default font for scripters to use is that it's hard to design for different fonts. a script would look good in pmiii and lousy in serenity ii. if at all possible to do, it would be nice for scripters to have their own fonts.
something i've been "pondering" quite hard lately.
let's face it, ttf looks crap compared to xpr (atleast in pm3), why's this? because the xpr fonts are bitmaps that have been kind of "softened", using a similar method to cleartype ™, this magic is mainly for lcd's but i suspect it may improve quality on crt's a bit also. grc.com has detailed info how it all works (sub-pixel rendering). nevertheless, jmarshall said that its unfortunatly not supported by our current ttf renderer.
if we could get a similar method as cleartype ™ for ttf rendering, they would look similar in quality. then we would have the best of two worlds!
to add to this discussion a bit here. i have started a new project on sourceforge called xboxmediacenter toolkit (https://sourceforge.net/projects/xbmctk/) (hope you don't mind the name). i started it as i am planning on developing a few open-source utilities for xbmc in c#. it would make sense to me if the fonts collected were a part of this "toolkit". a small program could then be made to go hand in had with the fonts that could be used to select/preview the font of your choice and set styles you liked, which would generate the font.xml for them (as an example of one of the tools in the set), when you are done. just an idea.
anyways, any xbmc devs/project leaders of course have full rights to be added to the project and i will step down as the admin even and only stay on as a developer of the apps if so desired.
Gamester17
2005-07-04, 14:10
there must be some open source code out there for smoothing (smooth = soften / blur) fonts like cleartype does?, (code that work on our anti-aliased ttf fonts?).
ps! you can find information on cleartype and other specs on related microsoft typography here (link) (http://www.microsoft.com/typography/default.mspx). also checkout allegrofont (http://nekros.freeshell.org/delirium/alfont.php) and freetype (http://savannah.nongnu.org/projects/freetype) libraries for code ;)
edit: did a little research; it appears that microsoft has kind-of open sourced its cleartype® technology (http://www.google.se/search?hl=sv&q=cleartype+open+source&meta=) (under their ip license (http://www.microsoft.com/mscorp/ip/) for non-commersial use) though i've not found any code ???
Gamester17
2005-07-27, 10:37
where did we get our existing ttf-renderer?, might freetype (http://freetype.sourceforge.net)-library be a good alternativ?, (or allegrofont (http://nekros.freeshell.org/delirium/alfont.php) which is a modified version of freetype (http://sourceforge.net/projects/freetype))
...if our existing ttf renderer is better then maybe someone could look porting some of the extra features that freetype and allegrofont offers?
jmarshall
2005-07-27, 12:25
it's built-in to the xdk.
porting another library for this use is a lot of work, for very little benefit.
i don't have time to change the font system as above anyway before i go on holiday, so it will be remaining as the status-quo as far as i'm concerned.
cheers,
jonathan
manekineko
2005-11-08, 20:10
i've had this request on sourceforge forever, with no response, i was wondering if i could get a little insight into the reason behind this?
http://sourceforge.net/tracker....=581841 (http://sourceforge.net/tracker/?func=detail&aid=1302338&group_id=87054&atid=581841)
"could you please add the ability to scale ttf font
sizes? on small hdtvs, the fonts are by default so
small as to be illegible. the only way to correct this
appears to be by manually editing the fonts.xml file
for the appropriate resolution. it would be extremely
convenient to be able to modify this directly from the
gui in the same place where font style (default v.
arial ttf) is selected."
this seems like a relatively easy and very important usability fix for a fairly sizeable percentage of the userbase, that'll only get more significant as time goes on. can't something please be done about thsi?
los93sol
2005-11-10, 04:29
yep, or even allowing seperate resolutions for the player and the gui
i like the xpr fonts alot better but i have a widescreenhd tv and you can tell. if it went just to ttf only, i am sure we would be used to it after a week or so and we wouldn't know the difference. as far as i am concerned the font.xml seemed kind of useless when skinning. you should be able to size the fonts in real time like your example. fontxx18bold or include it in the control with the other settings:
<posx>23</posx>
<posy>23</posy>
<font>arial.ttf</font>
<fontsize>12</fontsize>
<fonttype>bold</fonttype>
whatever you decide to do as long as ttf fonts are still used i am sure i can set up my skin app to use your method :)
Gamester17
2006-08-28, 13:43
Throught I bump this discussion now that the FreeType library been added to XBMC.
@JMarshall, what features/functions or options have already been added and what new ones can be added with this library, ex:
- Anta-aliasing (if already implemented is it done by the FreeType library in software or it done on the GPU-hardware via the XDK?)
- Softning/Bluring (sub-pixel rendering) similar to ClearType (http://www.themacobserver.com/columns/devilsadvocate/2003/20030523.shtml).
- Blur edges
- Colored text rendering.
- Semi-transparent.
- Outlines (like xpr fonts has)
- Shadows (like xpr fonts has)
- Boarders (black edges)
- Hollowing.
- Bold, italic and underlined fonts/text in the skin.
- Bold, italic and underlined subtitles in so called "Advanced Subtitles (http://forum.xboxmediacenter.com/showthread.php?t=6982)" text-based subs (see libass in the MPlayer CVS on www.mplayerhq.hu (http://www.mplayerhq.hu)).
- Giving skinners the option to render text 90-degrees left/right.
By the way, how much RAM-memory does FreeType take up compared to the XDK TTF-renderer? and has the XDK TTF-renderer library now been completly removed from XBMC code?
May I also once again suggest that we maybe start to collect free 'legal' TTF fonts and include when with XBMC so end-users don't have to copy unicode-fonts, etc. from their PC(?)
Chandler
2006-08-28, 19:34
...May I also once again suggest that we maybe start to collect free 'legal' TTF fonts and include when with XBMC so end-users don't have to copy unicode-fonts, etc. from their PC(?)
Here 6500 free fonts (http://www.webpagepublicity.com/free-fonts.html) to begin, thks Google :laugh:
jmarshall
2006-08-29, 01:11
Anti-aliasing is done by FreeType2 to produce a greyscale transparency map. (Full white == opaque, full black == fully transparent). The letters are then cached to a texture which we render from for speed purposes (the GPU alpha blending then handles the antialiasing to the backgrounds).
Coloured text (other than a single colour, ofcourse) is not an option with libfreetype. Semitransprent is ofcourse possible.
Outlines are probably simple enough to do, but don't look any good on most TVs.
Shadows are already possible with both XPR and TTF fonts.
Boarders and Hollowing are basically just outlining. IMO a waste of time.
Bold and italic subs are already doable. Underlining is not (and looks stupid)
Subtitles have nothing to do with this - it needs to be done in the sub parser.
And yes, skinners can render text at whatever angle they please in label + button controls.
FreeType takes up 16k more in the XBE than the TTF renderer. Yes, the XDK code has been completely removed.
TTF fonts take up less memory than XPR.
Cheers,
Jonathan
TheBoxMan
2007-08-14, 15:29
is this the reason that, after upgrading from an XBMC 2 release from last november time to the most recent version my MC 360 skin nolonger displays any text? (as in the skin looks ok except for the fact there is no writing anywhere?)
If so how do I go about fixing this?
MajorTom
2007-08-14, 15:32
is this the reason that, after upgrading from an XBMC 2 release from last november time to the most recent version my MC 360 skin nolonger displays any text? (as in the skin looks ok except for the fact there is no writing anywhere?)
If so how do I go about fixing this?
Have you updated to the latest build of MC360 (released last week I think).... Probably solve your problem.
Gamester17
2007-08-15, 14:57
Have you updated to the latest build of MC360 (released last week I think).... Probably solve your problem.Yes it probably will. Previous versions of the MC360 skin uses XPR fonts (read this whole thread)
TheBoxMan
2007-08-15, 16:37
cool. I'll sort it out as soon as I get back home this evening.
*feels pleased to have figured out what the problem was*
:D