public Vector2 nk_text_calculate_text_bounds(StringSegment begin, float row_height, out StringSegment remaining, out Vector2 out_offset, out int glyphs, int op) { var line_height = row_height; var text_size = new Vector2(0, 0); var line_width = 0.0f; float glyph_width; var glyph_len = 0; var unicode = 0; var text_len = 0; out_offset = Vector2.Zero; glyphs = 0; remaining = StringSegment.Null; if (begin.IsNullOrEmpty) { return(new Vector2(0, row_height)); } glyph_len = Nuklear.nk_utf_decode(begin, &unicode); if (glyph_len == 0) { return(text_size); } glyph_width = width(new StringSegment(begin, begin.Location, glyph_len)); glyphs = 0; while (text_len < begin.Length && glyph_len != 0) { if (unicode == '\n') { text_size.X = text_size.X < line_width ? line_width : text_size.X; text_size.Y += line_height; line_width = 0; glyphs += 1; if (op == Nuklear.NK_STOP_ON_NEW_LINE) { break; } text_len++; glyph_len = Nuklear.nk_utf_decode(begin + text_len, &unicode); continue; } if (unicode == '\r') { text_len++; glyphs += 1; glyph_len = Nuklear.nk_utf_decode(begin + text_len, &unicode); continue; } glyphs = glyphs + 1; text_len += glyph_len; line_width += glyph_width; glyph_len = Nuklear.nk_utf_decode(begin + text_len, &unicode); glyph_width = width(begin + text_len); } if (text_size.X < line_width) { text_size.X = line_width; } out_offset = new Vector2(line_width, text_size.Y + line_height); if (line_width > 0 || text_size.Y == 0.0f) { text_size.Y += line_height; } if (remaining != null) { remaining = begin + text_len; } return(text_size); }
public Nuklear.nk_font AddDefaultFont(float height) { return(Nuklear.nk_font_atlas_add_default(_atlas, height, null)); }