/// <summary> /// Draws a text /// </summary> /// <param name="text">The text to be drawn</param> /// <param name="font">The texts font</param> /// <param name="x">The texts x-position</param> /// <param name="y">The texts y-position</param> /// <param name="z">The texts z-position</param> /// <param name="color">The text color</param> public static void DrawText(string text, CFont font, float x, float y, float z, SColorF color, bool allMonitors = true) { if (font.Height <= 0f || text == "") { return; } CFontStyle fontStyle = _GetFontStyle(font); float dx = x; foreach (char chr in text) { fontStyle.DrawGlyph(chr, font.Height, dx, y, z, color, allMonitors); dx += fontStyle.GetWidth(chr, font.Height); } }
public static void DrawTextReflection(string text, CFont font, float x, float y, float z, SColorF color, float rspace, float rheight) { if (font.Height <= 0f || text == "") { return; } CFontStyle fontStyle = _GetFontStyle(font); float dx = x; foreach (char chr in text) { fontStyle.DrawGlyphReflection(chr, font.Height, dx, y, z, color, rspace, rheight); dx += fontStyle.GetWidth(chr, font.Height); } }
public static void DrawText(string text, CFont font, float x, float y, float z, SColorF color, float begin, float end) { if (font.Height <= 0f || text == "") { return; } float w = GetTextWidth(text, font); if (w <= 0f) { return; } float xStart = x + w * begin; float xEnd = x + w * end; float xCur = x; CFontStyle fontStyle = _GetFontStyle(font); foreach (char chr in text) { float w2 = fontStyle.GetWidth(chr, font.Height); float b = (xStart - xCur) / w2; if (b < 1f) { if (b < 0f) { b = 0f; } float e = (xEnd - xCur) / w2; if (e > 0f) { if (e > 1f) { e = 1f; } fontStyle.DrawGlyph(chr, font.Height, xCur, y, z, color, b, e); } } xCur += w2; } }
public static float GetTextWidth(string text, CFont font) { CFontStyle fontStyle = _GetFontStyle(font); return(text.Sum(chr => fontStyle.GetWidth(chr, font.Height))); }