~ubuntu-branches/ubuntu/karmic/python-scipy/karmic

« back to all changes in this revision

Viewing changes to Lib/xplt/src/play/mac/text.m

  • Committer: Bazaar Package Importer
  • Author(s): Daniel T. Chen (new)
  • Date: 2005-03-16 02:15:29 UTC
  • Revision ID: james.westby@ubuntu.com-20050316021529-xrjlowsejs0cijig
Tags: upstream-0.3.2
ImportĀ upstreamĀ versionĀ 0.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * text.m
 
3
 * p_text for Mac OS X.
 
4
 *
 
5
 * Copyright (c) 1999.  See accompanying LEGAL file for details.
 
6
 */
 
7
 
 
8
#include "playm.h"
 
9
 
 
10
void
 
11
p_text(p_win *w, int x0, int y0, const char *text, int n)
 
12
{
 
13
  View* view = w->view;
 
14
  if (p_signalling) {
 
15
    p_abort();
 
16
    return;
 
17
  }
 
18
  if (view) {
 
19
    int i;
 
20
    CGContextRef cr = w->cr;
 
21
    if (n <= 0) n = 16350;
 
22
    for (i=0 ; i<n ; i++) if (!text[i]) break;
 
23
    n = i;
 
24
    if (!w->orient) {
 
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);
 
29
      }
 
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);
 
35
    } else {
 
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);
 
42
      }
 
43
      // Same comment as above.
 
44
      // CGContextShowTextAtPoint(cr, -(float)y0, (float)x0, text, n);
 
45
      CGContextRotateCTM(cr, -angle);
 
46
    }
 
47
  }
 
48
}