diff -r 2515d9be07ce config --- a/config Sun May 20 17:53:42 2012 +0200 +++ b/config Tue May 21 20:44:40 2013 +0200 @@ -108,7 +108,7 @@ # DEBUG = -g -DTDEBUG=5 WARN = -Wall -Wextra -Wno-unused-parameter -Wno-unused-function -OPT = -O1 +OPT = -O2 -fno-strict-aliasing INCL = -I. -Iinclude -I$(INCDIR) LIBCFLAGS = $(DEBUG) $(WARN) $(OPT) $(INCL) $(EXTRADEFS) MODCFLAGS = -shared -L $(LIBDIR) diff -r 2515d9be07ce tek/lib/visual_api.c --- a/tek/lib/visual_api.c Sun May 20 17:53:42 2012 +0200 +++ b/tek/lib/visual_api.c Tue May 21 20:44:40 2013 +0200 @@ -181,22 +181,44 @@ /*****************************************************************************/ /* -** openfont(name, pxsize) +** openfont(name, pxsize, attr) +** attr: "b" bold, "i" italic, "s" scalable */ +static TBOOL iTStrChr(TSTRPTR s, TINT c) +{ + TINT d; + while ((d = *s)) + { + if (d == c) + return TTRUE; + s++; + } + return TFALSE; +} + + LOCAL LUACFUNC TINT tek_lib_visual_openfont(lua_State *L) { - TTAGITEM ftags[5], *tp = ftags; + TTAGITEM ftags[8], *tp = ftags; TEKVisual *vis; TEKFont *font; TSTRPTR name = (TSTRPTR) luaL_optstring(L, 1, ""); TINT size = luaL_optinteger(L, 2, -1); + TSTRPTR attr = (TSTRPTR) luaL_optstring(L, 3, ""); lua_getfield(L, LUA_REGISTRYINDEX, TEK_LIB_VISUAL_BASECLASSNAME); vis = lua_touserdata(L, -1); lua_pop(L, 1); + tp->tti_Tag = TVisual_FontBold; + tp++->tti_Value = (TTAG) !!iTStrChr(attr, 'b'); + tp->tti_Tag = TVisual_FontItalic; + tp++->tti_Value = (TTAG) !!iTStrChr(attr, 'i'); + tp->tti_Tag = TVisual_FontScaleable; + tp++->tti_Value = (TTAG) !!iTStrChr(attr, 's'); + if (name && name[0] != 0) { tp->tti_Tag = TVisual_FontName; diff -r 2515d9be07ce tek/ui/class/display.lua --- a/tek/ui/class/display.lua Sun May 20 17:53:42 2012 +0200 +++ b/tek/ui/class/display.lua Tue May 21 20:44:40 2013 +0200 @@ -95,7 +95,7 @@ local unpack = unpack module("tek.ui.class.display", tek.ui.class.element) -_VERSION = "Display 25.1" +_VERSION = "Display 26.0" local Display = _M @@ -112,12 +112,12 @@ local DEF_RGB_HALFSHINE = "#e1e1e1" local DEF_RGB_FOCUS = "#e05014" -local DEF_MAINFONT = "sans-serif,helvetica,arial,Vera:14" -local DEF_SMALLFONT = "sans-serif,helvetica,arial,Vera:12" -local DEF_MENUFONT = "sans-serif,helvetica,arial,Vera:14" -local DEF_FIXEDFONT = "monospace,fixed,courier new,VeraMono:14" -local DEF_LARGEFONT = "sans-serif,helvetica,arial,Vera:18" -local DEF_HUGEFONT = "sans-serif,utopia,arial,Vera:24" +local DEF_MAINFONT = "sans-serif,helvetica/s,arial,Vera:14" +local DEF_SMALLFONT = "sans-serif,helvetica/s,arial,Vera:12" +local DEF_MENUFONT = "sans-serif,helvetica/s,arial,Vera:14" +local DEF_FIXEDFONT = "monospace,courier new/s,fixed,VeraMono:14" +local DEF_LARGEFONT = "sans-serif,helvetica/s,arial,Vera:18" +local DEF_HUGEFONT = "sans-serif,helvetica/s,arial,Vera:24" local ColorDefaults = { @@ -338,14 +338,16 @@ end ------------------------------------------------------------------------------- --- font = openFont(fontname): Opens the named font. For a discussion +-- font = openFont(fontname[, attr]): Opens the named font. For a discussion -- of the {{fontname}} format, see [[#tek.ui.class.text : Text]]. +-- In the optional {{attr}} string, the letter {{b}} will be used as a hint +-- for bold, and {{i}} for italic. ------------------------------------------------------------------------------- -function Display:openFont(fname) +function Display:openFont(fname, attr) local fname = fname or "" if not self.FontCache[fname] then - local name, size = fname:match("^([^:]*)%s*:?%s*(%d*)$") + local name, attr2, size = fname:match("^([^:/]*)/?(%a*)%s*:?%s*(%d*)$") local defname = FontDefaults[name] local deff = defname and (self.Properties[defname[1]] or defname[2]) if deff then @@ -360,8 +362,11 @@ if name == "" then name = FontDefaults[""][2]:match("^([^:,]*),?[^:]*:?(%d*)$") end - db.info("Open font: '%s' -> '%s:%d'", fname, name, size or -1) - local font = Visual.openFont(name, size) + local fattr + name, fattr = name:match("^([^/]*)/?(.*)$") + fattr = fattr .. attr2 .. (attr or "") + db.info("Open font: '%s' -> '%s:%d/%s'", fname, name, size or -1, fattr) + local font = Visual.openFont(name, size, fattr) if font then local r = { font, font:getAttrs { }, fname, name } self.FontCache[fname] = r