aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilenio Quarti2012-01-16 10:42:58 (EST)
committerFelipe Heidrich2012-01-16 10:42:58 (EST)
commit1bccd9551405353b093a48e5b41738e24b6850d6 (patch)
treeb34995291013947d22500e36b0da612b4bb0bb21
parentff22354677b5d9a3279f7c1ed7dedaeab283bd03 (diff)
downloadeclipse.platform.swt-1bccd9551405353b093a48e5b41738e24b6850d6.zip
eclipse.platform.swt-1bccd9551405353b093a48e5b41738e24b6850d6.tar.gz
eclipse.platform.swt-1bccd9551405353b093a48e5b41738e24b6850d6.tar.bz2
Bug 367809 - [SWT Mac OS X] path.addString does not appear to handle
unicode properly
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras11
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras6
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSAttributedString.java7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java23
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Path.java21
6 files changed, 49 insertions, 23 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
index c56f7e0..3d248b2 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
@@ -4751,6 +4751,17 @@
<enum name="NSFileHandlingPanelOKButton" swt_gen="true"></enum>
<enum name="NSFlagsChanged" swt_gen="true"></enum>
<enum name="NSFocusRingTypeNone" swt_gen="true"></enum>
+ <enum name="NSFontPanelAllEffectsModeMask" swt_gen="true"></enum>
+ <enum name="NSFontPanelAllModesMask" swt_gen="true"></enum>
+ <enum name="NSFontPanelCollectionModeMask" swt_gen="true"></enum>
+ <enum name="NSFontPanelDocumentColorEffectModeMask" swt_gen="true"></enum>
+ <enum name="NSFontPanelFaceModeMask" swt_gen="true"></enum>
+ <enum name="NSFontPanelShadowEffectModeMask" swt_gen="true"></enum>
+ <enum name="NSFontPanelSizeModeMask" swt_gen="true"></enum>
+ <enum name="NSFontPanelStandardModesMask" swt_gen="true"></enum>
+ <enum name="NSFontPanelStrikethroughEffectModeMask" swt_gen="true"></enum>
+ <enum name="NSFontPanelTextColorEffectModeMask" swt_gen="true"></enum>
+ <enum name="NSFontPanelUnderlineEffectModeMask" swt_gen="true"></enum>
<enum name="NSHelpFunctionKey" swt_gen="true"></enum>
<enum name="NSHelpKeyMask" swt_gen="true"></enum>
<enum name="NSHourMinuteDatePickerElementFlag" swt_gen="true"></enum>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras
index ef51c74..8947ccd 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/FoundationFull.bridgesupport.extras
@@ -50,6 +50,12 @@
</method>
</class>
<class name="NSAttributedString" swt_gen="mixed">
+ <method selector="attribute:atIndex:effectiveRange:" swt_gen="true">
+ <arg swt_gen="true"></arg>
+ <arg swt_gen="true"></arg>
+ <arg swt_gen="true"></arg>
+ <retval swt_gen="true"></retval>
+ </method>
<method selector="attributedSubstringFromRange:" swt_gen="true">
<arg swt_gen="true"></arg>
<retval swt_gen="true"></retval>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSAttributedString.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSAttributedString.java
index 7d26d52..336244f 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSAttributedString.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSAttributedString.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2010 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -69,6 +69,11 @@ public NSSize size() {
return result;
}
+public id attribute(NSString attrName, int /*long*/ location, int /*long*/ range) {
+ int /*long*/ result = OS.objc_msgSend(this.id, OS.sel_attribute_atIndex_effectiveRange_, attrName != null ? attrName.id : 0, location, range);
+ return result != 0 ? new id(result) : null;
+}
+
public NSAttributedString attributedSubstringFromRange(NSRange range) {
int /*long*/ result = OS.objc_msgSend(this.id, OS.sel_attributedSubstringFromRange_, range);
return result == this.id ? this : (result != 0 ? new NSAttributedString(result) : null);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
index 01d3f53..979688a 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
@@ -960,6 +960,7 @@ public static final int /*long*/ sel_arrayWithCapacity_ = sel_registerName("arra
public static final int /*long*/ sel_arrayWithObject_ = sel_registerName("arrayWithObject:");
public static final int /*long*/ sel_arrowCursor = sel_registerName("arrowCursor");
public static final int /*long*/ sel_ascender = sel_registerName("ascender");
+public static final int /*long*/ sel_attribute_atIndex_effectiveRange_ = sel_registerName("attribute:atIndex:effectiveRange:");
public static final int /*long*/ sel_attributedStringValue = sel_registerName("attributedStringValue");
public static final int /*long*/ sel_attributedStringWithAttachment_ = sel_registerName("attributedStringWithAttachment:");
public static final int /*long*/ sel_attributedSubstringFromRange_ = sel_registerName("attributedSubstringFromRange:");
@@ -2281,17 +2282,17 @@ public static final int NSEventTypeSwipe = 31;
public static final int NSFileHandlingPanelOKButton = 1;
public static final int NSFlagsChanged = 12;
public static final int NSFocusRingTypeNone = 1;
-public static final int NSFontPanelFaceModeMask = 1 << 0;
-public static final int NSFontPanelSizeModeMask = 1 << 1;
-public static final int NSFontPanelCollectionModeMask = 1 << 2;
-public static final int NSFontPanelUnderlineEffectModeMask = 1<<8;
-public static final int NSFontPanelStrikethroughEffectModeMask = 1<<9;
-public static final int NSFontPanelTextColorEffectModeMask = 1<< 10;
-public static final int NSFontPanelDocumentColorEffectModeMask = 1<<11;
-public static final int NSFontPanelShadowEffectModeMask = 1<<12;
-public static final int NSFontPanelAllEffectsModeMask = 0XFFF00;
-public static final int NSFontPanelStandardModesMask = 0xFFFF;
-public static final int NSFontPanelAllModesMask = 0xFFFFFFFF;
+public static final int NSFontPanelAllEffectsModeMask = 1048320;
+public static final int NSFontPanelAllModesMask = -1;
+public static final int NSFontPanelCollectionModeMask = 4;
+public static final int NSFontPanelDocumentColorEffectModeMask = 2048;
+public static final int NSFontPanelFaceModeMask = 1;
+public static final int NSFontPanelShadowEffectModeMask = 4096;
+public static final int NSFontPanelSizeModeMask = 2;
+public static final int NSFontPanelStandardModesMask = 65535;
+public static final int NSFontPanelStrikethroughEffectModeMask = 512;
+public static final int NSFontPanelTextColorEffectModeMask = 1024;
+public static final int NSFontPanelUnderlineEffectModeMask = 256;
public static final int NSHelpFunctionKey = 63302;
public static final int NSHelpKeyMask = 4194304;
public static final int NSHourMinuteDatePickerElementFlag = 12;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java
index ea28083..c7e10d4 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/GC.java
@@ -1678,8 +1678,8 @@ public void drawText (String string, int x, int y, int flags) {
NSPoint pt = new NSPoint();
pt.x = x;
pt.y = y;
+ NSRange range = data.layoutManager.glyphRangeForTextContainer(data.textContainer);
if ((flags & SWT.DRAW_TRANSPARENT) == 0) {
- data.layoutManager.glyphRangeForTextContainer(data.textContainer);
NSRect rect = data.layoutManager.usedRectForTextContainer(data.textContainer);
rect.x = x;
rect.y = y;
@@ -1692,8 +1692,6 @@ public void drawText (String string, int x, int y, int flags) {
bg.setFill();
NSBezierPath.fillRect(rect);
}
- NSRange range = new NSRange();
- range.length = data.layoutManager.numberOfGlyphs();
data.layoutManager.drawGlyphsForGlyphRange(range, pt);
handle.restoreGraphicsState();
} finally {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Path.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Path.java
index 7a87377..e0261a9 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Path.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/graphics/Path.java
@@ -362,6 +362,7 @@ public void addString(String string, float x, float y, Font font) {
size.width = OS.MAX_TEXT_CONTAINER_SIZE;
size.height = OS.MAX_TEXT_CONTAINER_SIZE;
textContainer.initWithContainerSize(size);
+ textContainer.setLineFragmentPadding(0);
textStorage.addLayoutManager(layoutManager);
layoutManager.addTextContainer(textContainer);
NSRange range = new NSRange();
@@ -382,18 +383,22 @@ public void addString(String string, float x, float y, Font font) {
attrStr.release();
range = layoutManager.glyphRangeForTextContainer(textContainer);
if (range.length != 0) {
- int /*long*/ glyphs = OS.malloc(4 * range.length * 2);
- layoutManager.getGlyphs(glyphs, range);
+ int /*long*/ glyphs = OS.malloc((range.length + 1) * 4);
+ int count = layoutManager.getGlyphs(glyphs, range);
NSBezierPath path = NSBezierPath.bezierPath();
- NSPoint point = new NSPoint();
- path.moveToPoint(point);
- path.appendBezierPathWithGlyphs(glyphs, range.length, font.handle);
+ for (int i = 0; i < count; i++) {
+ NSPoint pt = layoutManager.locationForGlyphAtIndex(i);
+ NSRect lineFragmentRect = layoutManager.lineFragmentUsedRectForGlyphAtIndex(i, 0);
+ NSFont actualFont = new NSFont(textStorage.attribute(OS.NSFontAttributeName, layoutManager.characterIndexForGlyphAtIndex(i), 0));
+ pt.x = pt.x + x + lineFragmentRect.x;
+ pt.y = - pt.y - y - lineFragmentRect.y;
+ path.moveToPoint(pt);
+ path.appendBezierPathWithGlyphs(glyphs + (i * 4), 1, actualFont);
+ }
+ OS.free(glyphs);
NSAffineTransform transform = NSAffineTransform.transform();
transform.scaleXBy(1, -1);
- float /*double*/ baseline = layoutManager.defaultBaselineOffsetForFont(font.handle);
- transform.translateXBy(x, -(y + baseline));
path.transformUsingAffineTransform(transform);
- OS.free(glyphs);
handle.appendBezierPath(path);
}
textContainer.release();