void testFont(k.Pcb.kicad_pcb k_pcb) { Font.NewStroke stroke_font = new Font.NewStroke(); k.TextEffects effects = new k.TextEffects(); effects.font.Size = new SizeF(2.54f, 2.54f); effects.font.thickness = 0.15f; stroke_font.DrawText(k_pcb, new PointF(25.4f, 25.4f), "Hello", effects, k.Layer.Drawings); SizeF extent = stroke_font.GetTextSize("Hello", effects); DrawRect(k_pcb, new PointF(25.4f, 25.4f), extent, 0); }
void Test() { Font.NewStroke stroke_font = new Font.NewStroke(); string s; SizeF text_size; k.TextEffects effects = new k.TextEffects(); effects.font.Size = new SizeF(1f, 1f); s = "H"; text_size = stroke_font.GetTextSize(s, effects); Trace(string.Format("text size {0} = {1}, {2}", s, text_size.Width, text_size.Height)); s = "Hello"; text_size = stroke_font.GetTextSize(s, effects); Trace(string.Format("text size {0} = {1}, {2}", s, text_size.Width, text_size.Height)); }
// public static TextEffects Parse(SNodeBase node) { if ((node is SExpression) && ((node as SExpression).Name == "effects")) { SExpression expr = node as SExpression; TextEffects result = new TextEffects(); int index = 0; while (index < expr.Items.Count) { SExpression sexpr = expr.Items[index] as SExpression; // justify: horiz_align, mirror switch (sexpr.Name) { case "font": result.font = FontAttributes.Parse(expr.Items[0] as SExpression); break; case "justify": foreach (SNodeBase s2 in sexpr.Items) { if (s2 is SNodeAtom) { SNodeAtom atom = s2 as SNodeAtom; switch (atom.Value) { case "mirror": result.mirror = true; break; case "left": result.horiz_align = TextJustify.left; break; case "right": result.horiz_align = TextJustify.right; break; case "top": result.vert_align = VerticalAlign.top; break; case "bottom": result.vert_align = VerticalAlign.bottom; break; } } } break; } index++; } return(result); } else { return(null); // error } }