void initialize(IGlyphSlot glyph) { slot = glyph; Bounds = slot.Area; Character = slot.Character; ID = Factory.NewID(Name); }
static IRectangleF InitializeGlyphSlot(IGlyphSlot slot, out PointF Min, out PointF Max) { Min = Max = PointF.Empty; float x = slot.Area.X; float y = slot.Area.Y; float w = slot.Area.Width; float h = slot.Area.Height; if (slot.Initialized) return Factory.newRectangleF(x, y, w, h); if (char.IsWhiteSpace(slot.Character)) { if (slot.Character == ' ') w = (slot.Points[1].X - slot.Points[0].X).Ceiling(); return Factory.newRectangleF(x, y, w, h); } if (slot.Points.Count < 4) return Factory.newRectangleF(x, y, w, h); var num = slot.Points.Count - 4; Min = new PointF(float.MaxValue, float.MaxValue); Max = new PointF(float.MinValue, float.MinValue); var points = slot.Points; for (int i = 0; i < num; i++) { Min = Min.Min(points[i]); Max = Max.Max(points[i]); } var off = new PointF(-Min.X, -Min.Y, Min.Quadratic); for (int i = 0; i < num; i++) slot.Points[i] = new PointF(points[i].X + off.X, points[i].Y + off.Y, points[i].Quadratic); w = Math.Max(slot.Points[num + 1].X - slot.Points[num].X - Min.X, Max.X - Min.X).Round(); h = (Max.Y - Min.Y).Ceiling(); x = Min.X.Ceiling(); y = (slot.XHeight - h) - Min.Y.Ceiling(); return Factory.newRectangleF(x, y, w, h); }
public static IGlyphSlot RotateSlot(this IGlyphSlot slot, Angle angle, int currentX, int currentY, out float newX, out float newY) { newX = currentX; newY = currentY; if (slot.Points == null || slot.Points.Count == 0 || !angle.Valid || char.IsWhiteSpace(slot.Character)) { return(slot); } Angle a = new Angle(-angle.Degree, 0, 0); var Points = new PointF[slot.Points.Count]; for (int i = 0; i < Points.Length; i++) { var p = new PointF(slot.Points[i].X + slot.Min.X, slot.Points[i].Y + slot.Min.Y, slot.Points[i].Quadratic); Points[i] = a.Rotate(p); } angle.Rotate(currentX, currentY, out newX, out newY); return(Factory.newGlyphSlot(slot.Character, Points, slot.Contours.ToArray(), slot.XHeight)); }
public virtual IGlyph newGlyph(IGlyphSlot slot) => new Glyph(slot);
public Glyph(IGlyphSlot glyph) { initialize(glyph); }