5
* Copyright (c) 1999. See accompanying LEGAL file for details.
11
p_text(p_win *w, int x0, int y0, const char *text, int n)
20
CGContextRef cr = w->cr;
21
if (n <= 0) n = 16350;
22
for (i=0 ; i<n ; i++) if (!text[i]) break;
25
CGContextSetTextPosition (cr, (float)x0, (float)y0);
26
for (i = 0; i < n; i++)
27
{ CGGlyph c = (unsigned short)(text[i]) - 29;
28
CGContextShowGlyphs(cr, &c, 1);
30
// The following would have been easier, but unfortunately it only works
31
// if the font is selected using CGContextSelectFont. That, however, would
32
// mean that we need to create the font each time we want to draw some
33
// text. Hence, use CGContextSetFont with CGContextShowGlyphs instead.
34
// CGContextShowTextAtPoint(cr, (float)x0, (float)y0, text, n);
36
const float angle = -M_PI/2;
37
CGContextRotateCTM(cr, angle);
38
CGContextSetTextPosition (cr, -(float)y0, (float)x0);
39
for (i = 0; i < n; i++)
40
{ CGGlyph c = (unsigned short)(text[i]) - 29;
41
CGContextShowGlyphs(cr, &c, 1);
43
// Same comment as above.
44
// CGContextShowTextAtPoint(cr, -(float)y0, (float)x0, text, n);
45
CGContextRotateCTM(cr, -angle);