public static ElementSegment Get(string name) { ElementSegment es = null; if (TypeList.TryGetValue(name, out es)) { return(es); } return(null); }
public ElementSection(BinaryReader reader) : base(reader) { uint count = LEB128.ReadUInt32(reader); if (count > int.MaxValue) { throw new NotImplementedException($"Count larger than {int.MaxValue} bytes not supported."); } entries = new ElementSegment[count]; for (uint i = 0; i < count; i++) { entries[i] = new ElementSegment(reader); } }
protected override void UpdateWidthList(out List <Element> widths, float pixelsPerUnit) { widths = d_widthList; d_widthList.Clear(); if (d_text.Length == 0) { return; } float unitsPerPixel = 1f / pixelsPerUnit; int fontsize = (int)(d_fontSize * pixelsPerUnit); size.x = 0; size.y = FontCache.GetLineHeight(d_font, fontsize, d_fontStyle) * unitsPerPixel; float wordSpacing = owner.GetWordSpacing(d_font); Func <char, float> fontwidth = (char code) => { return((FontCache.GetAdvance(d_font, fontsize, d_fontStyle, code) + wordSpacing) * unitsPerPixel); }; ElementSegment es = owner.elementSegment; if (es == null) { for (int i = 0; i < d_text.Length; ++i) { var e = new Element(fontwidth(d_text[i])); #if UNITY_EDITOR e.text = "" + d_text[i]; #endif widths.Add(e); } } else { es.Segment(d_text, widths, fontwidth); } for (int i = 0; i < d_widthList.Count; ++i) { size.x += d_widthList[i].totalwidth; } //size.x *= pixelsPerUnit; //size.y *= pixelsPerUnit; }
static public void Add(string name, ElementSegment es) { TypeList.Add(name, es); }