1 TFont theGlyphFont; 2 3 TStandardText theText( "Hello World" ); 4 UniChar unichars[12]; 5 GlyphCode glyphs[12]; 6 TTextCount numberOfChars = theText.Extract(TTextRange::GetMaximumRange(), unichars, 12); 7 theGlyphFont.MapCharactersToGlyphs( numberOfChars, unichars, glyphs); 8 GCoordinate widths[12]; 9 theGlyphFont.GetAdvanceWidths(numberOfChars, glyphs, widths); 10 11 GCoordinate offsets[12]; 12 offsets[0] = 0.; 13 14 for (long i = 0; i < numberOfCharacters - 1; i++) 15 offsets[i + 1] = offsets[i] + widths[i]; 16 17 TGGlyphRun theGlyphText( theGlyphFont, numberOfChars, glyphs, offsets, NIL, 18 TGPoint( 100, 100 ) ); 19 20 thePort.Draw( theGlyphText );
Lines 11 through 15: Calculate the X offsets
Lines 17 through 20: Create the glyph run graphic and draw it