int UI_DrawString (const char* fontID, align_t align, int x, int y, int absX, int maxWidth, int lineHeight, const char* c, int boxHeight, int scrollPos, int* curLine, bool increaseLine, longlines_t method) { const uiFont_t* font = UI_GetFontByID(fontID); const align_t verticalAlign = (align_t)(align / 3); /* top, center, bottom */ int lines; if (!font) Com_Error(ERR_FATAL, "Could not find font with id: '%s'", fontID); if (lineHeight <= 0) lineHeight = UI_FontGetHeight(font->name); /* vertical alignment makes only a single-line adjustment in this * function. That means that ALIGN_Lx values will not show more than * one line in any case. */ if (verticalAlign == 1) y += -(lineHeight / 2); else if (verticalAlign == 2) y += -lineHeight; lines = R_FontDrawString(fontID, align, x, y, absX, maxWidth, lineHeight, c, boxHeight, scrollPos, curLine, method); if (curLine && increaseLine) *curLine += lines; return lines * lineHeight; }
/** * @sa CL_ParseClientData */ bool UI_ParseFont (const char* name, const char** text) { const char* errhead = "UI_ParseFont: unexpected end of file (font"; /* search for font with same name */ if (UI_GetFontByID(name)) { Com_Printf("UI_ParseFont: font \"%s\" with same name found, second ignored\n", name); return false; } if (numFonts >= MAX_FONTS) { Com_Printf("UI_ParseFont: Max fonts reached\n"); return false; } /* initialize the UI */ uiFont_t* font = &fonts[numFonts]; OBJZERO(*font); font->name = Mem_PoolStrDup(name, ui_sysPool, 0); Com_DPrintf(DEBUG_CLIENT, "...found font %s (%i)\n", font->name, numFonts); /* get it's body */ const char* token = Com_Parse(text); if (!*text || *token != '{') { Com_Printf("UI_ParseFont: font \"%s\" without body ignored\n", name); return false; } numFonts++; do { /* get the name type */ token = Com_EParse(text, errhead, name); if (!*text) return false; if (*token == '}') break; const value_t* v; for (v = fontValues; v->string; v++) if (Q_streq(token, v->string)) { /* found a definition */ token = Com_EParse(text, errhead, name); if (!*text) return false; switch (v->type) { case V_TRANSLATION_STRING: token++; case V_HUNK_STRING: Mem_PoolStrDupTo(token, &Com_GetValue<char*>(font, v), ui_sysPool, 0); break; default: Com_EParseValue(font, token, v->type, v->ofs, v->size); break; } break; } if (!v->string) Com_Printf("UI_ParseFont: unknown token \"%s\" ignored (font %s)\n", token, name); } while (*text); UI_RegisterFont(font); return true; }