Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Funzione per trovare il font della dimensione adatta
- let FindFont (g : Graphics) (str : string) (box : SizeF) (preferredfont : Font) =
- let stringsize = g.MeasureString(str, preferredfont)
- let scaleRatio = min (box.Height / stringsize.Height) (box.Width / stringsize.Width)
- let scalefontsize = scaleRatio * preferredfont.Size
- new Font(preferredfont.FontFamily, float32 scalefontsize)
- type PIGlyph() =
- inherit LWControl()
- let mutable letter = 'A'
- let mutable letterSize = 12.0f
- member this.Lettera
- with get() = letter
- and set(v) = letter <- v
- member this.LetterSize
- with get() = letterSize
- and set(v) = letterSize <- v
- override this.OnPaint e =
- let parent = this.Parent
- let g = e.Graphics
- let r = RectangleF(this.Position, this.Size) |> RectF2Rect
- g.DrawRectangle(Pens.Red, r)
- let fittingfont = FindFont g (string letter) this.Size FontArray.[curFontIndex]
- g.DrawString(string letter, fittingfont, Brushes.Black, this.Position)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement