QotD    "The more I dig, the deeper I go, the more I realize how little I know" – Mayuresh A Kathe

View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Rendering a TTGlyph
Last updated at 9:38 am UTC on 7 August 2017
The method


of TTGlyph gives back the glyph rendered as an instance of the class Form.

TTFontDescription instances hold TTGlyph instances.

Method code adapted to be run as an example from a workspace

The example needs this TrueType font.

	| glyph form canvas code depth scale  font |
	font := (TextConstants at: #LiberationSans) fontArray at: 3.
	glyph := font ttcDescription at: 732.
	glyph inspect.
	scale := scale := font ttcDescription fontHeight asFloat / (font ttcDescription ascender - font ttcDescription descender).
	depth := 8.
	code := 0. "is for emphasis"
	form := Form extent: (glyph advanceWidth @ (font ttcDescription ascender - font ttcDescription descender) * scale) rounded depth: depth.
	form fillColor: Color transparent.
	canvas := form getCanvas asBalloonCanvas.
	canvas aaLevel: 4.
		transformBy: (MatrixTransform2x3 withScale: scale asPoint * (1 @ -1)).
		transformBy: (MatrixTransform2x3 withOffset: 0 @ font ttcDescription ascender negated).
		drawGeneralBezierShape: glyph contours
		color: Color black
		borderWidth: 0
		borderColor: Color black.
	form asMorph openInHand