diff options
| author | yuri <yuri> | 2009-04-24 09:28:30 +0000 |
|---|---|---|
| committer | yuri <yuri> | 2009-04-24 09:28:30 +0000 |
| commit | f13defde281dbd383dbc21488154a109dff50b40 (patch) | |
| tree | d2b2725fc4c8054797cc3018abd5e1baef489e2d /src/fl_font_mac.cxx | |
| parent | ca3984892fecd1e2784e65226b2c44d2eba0671b (diff) | |
add fl_draw(int angle, const char* ... functions for rotated text drawing
STR#1840 closed, STR#207 not closed because non-xft functions not implemented
drawing of N Utf8 characters need correction for rotated and not rotated fl_draw functions not solved!
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6779 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/fl_font_mac.cxx')
| -rw-r--r-- | src/fl_font_mac.cxx | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/fl_font_mac.cxx b/src/fl_font_mac.cxx index a7b10f463..3e9db0763 100644 --- a/src/fl_font_mac.cxx +++ b/src/fl_font_mac.cxx @@ -339,6 +339,29 @@ void fl_draw(const char *str, int n, float x, float y) { err = ATSUDrawText(layout, kATSUFromTextBeginning, n, FloatToFixed(x), FloatToFixed(y)); } +void fl_draw(int angle, const char *str, int n, int x, int y) { + OSStatus err; + // convert to UTF-16 first + UniChar *uniStr = mac_Utf8_to_Utf16(str, n, &n); + + // avoid a crash if no font has been selected by user yet ! + check_default_font(); + // now collect our ATSU resources + ATSUTextLayout layout = fl_fontsize->layout; + + Fixed ang = IntToFixed(-angle); + ByteCount iSize[] = {sizeof(Fixed), sizeof(CGContextRef)}; + ATSUAttributeTag iTag[] = {kATSULineRotationTag, kATSUCGContextTag}; + ATSUAttributeValuePtr aAttr[] = { &ang, &fl_gc}; + ATSUSetLayoutControls(layout, 2, iTag, iSize, aAttr); + + err = ATSUSetTextPointerLocation(layout, uniStr, kATSUFromTextBeginning, n, n); + err = ATSUDrawText(layout, kATSUFromTextBeginning, n, FloatToFixed(x), FloatToFixed(y)); + //restore layout baseline + ang = IntToFixed(0); + ATSUSetLayoutControls(layout, 2, iTag, iSize, aAttr); +} + void fl_rtl_draw(const char* c, int n, int x, int y) { // I guess with ATSU the thing to do is force the layout mode to RTL and let ATSU draw the text... double offs = fl_width(c, n); |
