/// <summary> /// Gets the index of the character which exceeds the specified width in the specified font. /// </summary> /// <param name="font">Font by which to measure characters</param> /// <param name="s">The string to measure</param> /// <param name="width">The width to check against</param> /// <param name="ignoreColours">Whether or not to ignore c:XXXXXX and c tags' width.</param> /// <returns></returns> public static int GetIndexWhereWidthExceeds(sNFTR font, string s, int width, bool ignoreColours) { int l = 0; ushort[] codes = Font10Converter.GetCodes(s); for (int i = 0; i < codes.Length; ++i) { if (codes[i] == '<' && codes.Length >= i + 2 && codes[i + 1] == 'c') { if (codes[i + 2] == ':') { i += 10 - 1; // -1 to account for the continue; continue; } else if (codes[i + 2] == '>') { i += 3 - 1; // -1 to account for the continue; continue; } } int idx = TexBmpConv.IndexFromCode(codes[i]); l += font.hdwc.info[idx].pixel_width + font.hdwc.info[idx].pixel_start; if (l >= width) { return(i); } } return(s.Length); }
public MainForm() { InitializeComponent(); //NewConsole.Init(); Font10Converter.Init(); TexBmpConv.Init(); }
public static int GetStringWidth(sNFTR font, string s) { int l = 0; ushort[] codes = Font10Converter.GetCodes(s); for (int i = 0; i < codes.Length; ++i) { int idx = TexBmpConv.IndexFromCode(codes[i]); l += font.hdwc.info[idx].pixel_width; } return(l); }