src/macosx/native/sun/font/AWTStrike.m

Print this page




  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #import <JavaNativeFoundation/JavaNativeFoundation.h>
  27 #import "java_awt_geom_PathIterator.h"
  28 #import "sun_awt_SunHints.h"
  29 #import "sun_font_CStrike.h"
  30 #import "CGGlyphImages.h"
  31 #import "CGGlyphOutlines.h"
  32 #import "AWTStrike.h"
  33 #import "CoreTextSupport.h"
  34 //#import "jni_util.h"
  35 





  36 @implementation AWTStrike
  37 
  38 static CGAffineTransform sInverseTX = { 1, 0, 0, -1, 0, 0 };
  39 
  40 - (id) initWithFont:(AWTFont *)awtFont
  41                  tx:(CGAffineTransform)tx
  42            invDevTx:(CGAffineTransform)invDevTx
  43               style:(JRSFontRenderingStyle)style
  44             aaStyle:(jint)aaStyle {
  45 
  46     self = [super init];
  47     if (self) {
  48         fAWTFont = [awtFont retain];
  49         fStyle = style;
  50         fAAStyle = aaStyle;
  51 
  52         fTx = tx; // composited glyph and device transform
  53 
  54         fAltTx = tx;
  55         fAltTx.b *= -1;


  85 }
  86 
  87 @end
  88 
  89 
  90 #define AWT_FONT_CLEANUP_SETUP \
  91     BOOL _fontThrowJavaException = NO;
  92 
  93 #define AWT_FONT_CLEANUP_CHECK(a)                                       \
  94     if ((a) == NULL) {                                                  \
  95         _fontThrowJavaException = YES;                                  \
  96         goto cleanup;                                                   \
  97     }                                                                   \
  98     if ((*env)->ExceptionCheck(env) == JNI_TRUE) {                      \
  99         goto cleanup;                                                   \
 100     }
 101 
 102 #define AWT_FONT_CLEANUP_FINISH                                         \
 103     if (_fontThrowJavaException == YES) {                               \
 104         char s[512];                                                    \
 105         sprintf(s, "%s-%s:%d", __FILE__, __FUNCTION__, __LINE__);       \
 106         [JNFException raise:env as:kRuntimeException reason:s];         \
 107     }
 108 
 109 
 110 /*
 111  * Creates an affine transform from the corresponding doubles sent
 112  * from CStrike.getGlyphTx().
 113  */
 114 static inline CGAffineTransform
 115 GetTxFromDoubles(JNIEnv *env, jdoubleArray txArray)
 116 {
 117     if (txArray == NULL) {
 118         return CGAffineTransformIdentity;
 119     }
 120 
 121     jdouble *txPtr = (*env)->GetPrimitiveArrayCritical(env, txArray, NULL);
 122 
 123     CGAffineTransform tx =
 124         CGAffineTransformMake(txPtr[0], txPtr[1], txPtr[2],
 125                               txPtr[3], txPtr[4], txPtr[5]);




  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 #import <JavaNativeFoundation/JavaNativeFoundation.h>
  27 #import "java_awt_geom_PathIterator.h"
  28 #import "sun_awt_SunHints.h"
  29 #import "sun_font_CStrike.h"
  30 #import "CGGlyphImages.h"
  31 #import "CGGlyphOutlines.h"
  32 #import "AWTStrike.h"
  33 #import "CoreTextSupport.h"
  34 //#import "jni_util.h"
  35 
  36 /* Use THIS_FILE when it is available. */
  37 #ifndef THIS_FILE
  38     #define THIS_FILE __FILE__
  39 #endif
  40 
  41 @implementation AWTStrike
  42 
  43 static CGAffineTransform sInverseTX = { 1, 0, 0, -1, 0, 0 };
  44 
  45 - (id) initWithFont:(AWTFont *)awtFont
  46                  tx:(CGAffineTransform)tx
  47            invDevTx:(CGAffineTransform)invDevTx
  48               style:(JRSFontRenderingStyle)style
  49             aaStyle:(jint)aaStyle {
  50 
  51     self = [super init];
  52     if (self) {
  53         fAWTFont = [awtFont retain];
  54         fStyle = style;
  55         fAAStyle = aaStyle;
  56 
  57         fTx = tx; // composited glyph and device transform
  58 
  59         fAltTx = tx;
  60         fAltTx.b *= -1;


  90 }
  91 
  92 @end
  93 
  94 
  95 #define AWT_FONT_CLEANUP_SETUP \
  96     BOOL _fontThrowJavaException = NO;
  97 
  98 #define AWT_FONT_CLEANUP_CHECK(a)                                       \
  99     if ((a) == NULL) {                                                  \
 100         _fontThrowJavaException = YES;                                  \
 101         goto cleanup;                                                   \
 102     }                                                                   \
 103     if ((*env)->ExceptionCheck(env) == JNI_TRUE) {                      \
 104         goto cleanup;                                                   \
 105     }
 106 
 107 #define AWT_FONT_CLEANUP_FINISH                                         \
 108     if (_fontThrowJavaException == YES) {                               \
 109         char s[512];                                                    \
 110         sprintf(s, "%s-%s:%d", THIS_FILE, __FUNCTION__, __LINE__);       \
 111         [JNFException raise:env as:kRuntimeException reason:s];         \
 112     }
 113 
 114 
 115 /*
 116  * Creates an affine transform from the corresponding doubles sent
 117  * from CStrike.getGlyphTx().
 118  */
 119 static inline CGAffineTransform
 120 GetTxFromDoubles(JNIEnv *env, jdoubleArray txArray)
 121 {
 122     if (txArray == NULL) {
 123         return CGAffineTransformIdentity;
 124     }
 125 
 126     jdouble *txPtr = (*env)->GetPrimitiveArrayCritical(env, txArray, NULL);
 127 
 128     CGAffineTransform tx =
 129         CGAffineTransformMake(txPtr[0], txPtr[1], txPtr[2],
 130                               txPtr[3], txPtr[4], txPtr[5]);