Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 224550
Collapse All | Expand All

(-)Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java (-17 / +41 lines)
Lines 2694-2706 Link Here
2694
	this.wrapWidth = width;
2694
	this.wrapWidth = width;
2695
}
2695
}
2696
2696
2697
boolean shape (int /*long*/ hdc, StyleItem run, char[] chars, int[] glyphCount, int maxGlyphs) {
2697
boolean shape (int /*long*/ hdc, StyleItem run, char[] chars, int[] glyphCount, int maxGlyphs, SCRIPT_PROPERTIES sp) {
2698
	boolean useCMAPcheck = !sp.fComplex && !sp.fPrivateUseArea; 
2699
	SCRIPT_FONTPROPERTIES fp = new SCRIPT_FONTPROPERTIES ();
2700
	fp.cBytes = SCRIPT_FONTPROPERTIES.sizeof;
2701
	OS.ScriptGetFontProperties(hdc, run.psc, fp);
2702
	if (useCMAPcheck) {
2703
		short[] glyphs = new short[chars.length];
2704
		if (OS.ScriptGetCMap(hdc, run.psc, chars, chars.length, 0, glyphs) != OS.S_OK) {
2705
			if (run.psc != 0) {
2706
				OS.ScriptFreeCache(run.psc);
2707
				glyphCount[0] = 0;
2708
				OS.MoveMemory(run.psc, new int /*long*/ [1], OS.PTR_SIZEOF);
2709
			}
2710
			return false;
2711
		}
2712
	}
2698
	int hr = OS.ScriptShape(hdc, run.psc, chars, chars.length, maxGlyphs, run.analysis, run.glyphs, run.clusters, run.visAttrs, glyphCount);
2713
	int hr = OS.ScriptShape(hdc, run.psc, chars, chars.length, maxGlyphs, run.analysis, run.glyphs, run.clusters, run.visAttrs, glyphCount);
2699
	run.glyphCount = glyphCount[0];
2714
	run.glyphCount = glyphCount[0];
2715
	if (useCMAPcheck) return true;
2716
	
2700
	if (hr != OS.USP_E_SCRIPT_NOT_IN_FONT) {
2717
	if (hr != OS.USP_E_SCRIPT_NOT_IN_FONT) {
2701
		SCRIPT_FONTPROPERTIES fp = new SCRIPT_FONTPROPERTIES ();
2702
		fp.cBytes = SCRIPT_FONTPROPERTIES.sizeof;
2703
		OS.ScriptGetFontProperties(hdc, run.psc, fp);
2704
		short[] glyphs = new short[glyphCount[0]];
2718
		short[] glyphs = new short[glyphCount[0]];
2705
		OS.MoveMemory(glyphs, run.glyphs, glyphs.length * 2);
2719
		OS.MoveMemory(glyphs, run.glyphs, glyphs.length * 2);
2706
		int i;
2720
		int i;
Lines 2725-2730 Link Here
2725
	final int[] buffer = new int[1];
2739
	final int[] buffer = new int[1];
2726
	final char[] chars = new char[run.length];
2740
	final char[] chars = new char[run.length];
2727
	segmentsText.getChars(run.start, run.start + run.length, chars, 0);
2741
	segmentsText.getChars(run.start, run.start + run.length, chars, 0);
2742
	
2743
	
2744
	/*
2745
	* Feature in Uniscribe, the U+FEFF is not supported by
2746
	* some fonts in the system causing the remaining chars in
2747
	* the run not to draw, even though the font supports them.
2748
	* The fix is to replace U+FEFF by U+200B (ZERO-WIDTH SPACE).   
2749
	*/
2750
	for (int i = 0; i < chars.length; i++) {
2751
		if (chars[i] == '\uFEFF') chars[i] = '\u200B';
2752
	}
2753
2728
	final int maxGlyphs = (chars.length * 3 / 2) + 16;
2754
	final int maxGlyphs = (chars.length * 3 / 2) + 16;
2729
	int /*long*/ hHeap = OS.GetProcessHeap();
2755
	int /*long*/ hHeap = OS.GetProcessHeap();
2730
	run.glyphs = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, maxGlyphs * 2);
2756
	run.glyphs = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, maxGlyphs * 2);
Lines 2735-2742 Link Here
2735
	if (run.visAttrs == 0) SWT.error(SWT.ERROR_NO_HANDLES);
2761
	if (run.visAttrs == 0) SWT.error(SWT.ERROR_NO_HANDLES);
2736
	run.psc = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, OS.PTR_SIZEOF);
2762
	run.psc = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, OS.PTR_SIZEOF);
2737
	if (run.psc == 0) SWT.error(SWT.ERROR_NO_HANDLES);
2763
	if (run.psc == 0) SWT.error(SWT.ERROR_NO_HANDLES);
2738
	boolean shapeSucceed = shape(hdc, run, chars, buffer,  maxGlyphs);
2739
	final short script = run.analysis.eScript;
2764
	final short script = run.analysis.eScript;
2765
	final SCRIPT_PROPERTIES sp = new SCRIPT_PROPERTIES();
2766
	OS.MoveMemory(sp, device.scripts[script], SCRIPT_PROPERTIES.sizeof);
2767
	boolean shapeSucceed = shape(hdc, run, chars, buffer,  maxGlyphs, sp);
2740
	
2768
	
2741
	if (!shapeSucceed) {
2769
	if (!shapeSucceed) {
2742
		/* 
2770
		/* 
Lines 2744-2754 Link Here
2744
		 * Try to shape with fNoGlyphIndex when the run is in the 
2772
		 * Try to shape with fNoGlyphIndex when the run is in the 
2745
		 * Private Use Area. This allows for end-user-defined character (EUDC).
2773
		 * Private Use Area. This allows for end-user-defined character (EUDC).
2746
		 */
2774
		 */
2747
		SCRIPT_PROPERTIES properties = new SCRIPT_PROPERTIES();
2775
		if (sp.fPrivateUseArea) {
2748
		OS.MoveMemory(properties, device.scripts[script], SCRIPT_PROPERTIES.sizeof);
2749
		if (properties.fPrivateUseArea) {
2750
			run.analysis.fNoGlyphIndex = true;
2776
			run.analysis.fNoGlyphIndex = true;
2751
			shapeSucceed = shape(hdc, run, chars, buffer,  maxGlyphs);
2777
			shapeSucceed = shape(hdc, run, chars, buffer,  maxGlyphs, sp);
2752
		}
2778
		}
2753
	}
2779
	}
2754
	
2780
	
Lines 2766-2772 Link Here
2766
			/* MapFont() */
2792
			/* MapFont() */
2767
			if (OS.VtblCall(10, mLangFontLink2, hdc, dwCodePages[0], chars[0], hNewFont) == OS.S_OK) {
2793
			if (OS.VtblCall(10, mLangFontLink2, hdc, dwCodePages[0], chars[0], hNewFont) == OS.S_OK) {
2768
				int /*long*/ hFont = OS.SelectObject(hdc, hNewFont[0]);
2794
				int /*long*/ hFont = OS.SelectObject(hdc, hNewFont[0]);
2769
				shapeSucceed = shape(hdc, run, chars, buffer,  maxGlyphs);
2795
				shapeSucceed = shape(hdc, run, chars, buffer,  maxGlyphs, sp);
2770
				if (shapeSucceed) {
2796
				if (shapeSucceed) {
2771
					run.fallbackFont = hNewFont[0];
2797
					run.fallbackFont = hNewFont[0];
2772
					run.mlang = true;
2798
					run.mlang = true;
Lines 2796-2802 Link Here
2796
			cachedLogFont.lfWidth = logFont.lfWidth;
2822
			cachedLogFont.lfWidth = logFont.lfWidth;
2797
			int /*long*/ newFont = OS.CreateFontIndirect(cachedLogFont);
2823
			int /*long*/ newFont = OS.CreateFontIndirect(cachedLogFont);
2798
			OS.SelectObject(hdc, newFont);
2824
			OS.SelectObject(hdc, newFont);
2799
			shapeSucceed = shape(hdc, run, chars, buffer,  maxGlyphs);
2825
			shapeSucceed = shape(hdc, run, chars, buffer,  maxGlyphs, sp);
2800
			if (shapeSucceed) {
2826
			if (shapeSucceed) {
2801
				run.fallbackFont = newFont;
2827
				run.fallbackFont = newFont;
2802
			} else {
2828
			} else {
Lines 2813-2828 Link Here
2813
			if (device.logFontsCache == null) device.logFontsCache = new LOGFONT[device.scripts.length];
2839
			if (device.logFontsCache == null) device.logFontsCache = new LOGFONT[device.scripts.length];
2814
			final LOGFONT newLogFont = OS.IsUnicode ? (LOGFONT)new LOGFONTW () : new LOGFONTA ();
2840
			final LOGFONT newLogFont = OS.IsUnicode ? (LOGFONT)new LOGFONTW () : new LOGFONTA ();
2815
			class EnumFontFamEx {
2841
			class EnumFontFamEx {
2816
				int EnumFontFamExProc(int lpelfe, int lpntme, int FontType, int lParam) {
2842
				int /*long*/ EnumFontFamExProc (int /*long*/ lpelfe, int /*long*/ lpntme, int /*long*/ FontType, int /*long*/ lParam) {
2817
					OS.MoveMemory(newLogFont, lpelfe, LOGFONT.sizeof);
2818
					if (FontType == OS.RASTER_FONTTYPE) return 1;
2843
					if (FontType == OS.RASTER_FONTTYPE) return 1;
2844
					OS.MoveMemory(newLogFont, lpelfe, LOGFONT.sizeof);
2819
					newLogFont.lfHeight = logFont.lfHeight;
2845
					newLogFont.lfHeight = logFont.lfHeight;
2820
					newLogFont.lfWeight = logFont.lfWeight;
2846
					newLogFont.lfWeight = logFont.lfWeight;
2821
					newLogFont.lfItalic = logFont.lfItalic;
2847
					newLogFont.lfItalic = logFont.lfItalic;
2822
					newLogFont.lfWidth = logFont.lfWidth;
2848
					newLogFont.lfWidth = logFont.lfWidth;
2823
					int /*long*/ newFont = OS.CreateFontIndirect(newLogFont);
2849
					int /*long*/ newFont = OS.CreateFontIndirect(newLogFont);
2824
					OS.SelectObject(hdc, newFont);
2850
					OS.SelectObject(hdc, newFont);
2825
					if (shape(hdc, run, chars, buffer, maxGlyphs)) {
2851
					if (shape(hdc, run, chars, buffer, maxGlyphs, sp)) {
2826
						run.fallbackFont = newFont;
2852
						run.fallbackFont = newFont;
2827
						LOGFONT cacheLogFont = OS.IsUnicode ? (LOGFONT)new LOGFONTW () : new LOGFONTA ();
2853
						LOGFONT cacheLogFont = OS.IsUnicode ? (LOGFONT)new LOGFONTW () : new LOGFONTA ();
2828
						OS.MoveMemory(cacheLogFont, lpelfe, LOGFONT.sizeof);
2854
						OS.MoveMemory(cacheLogFont, lpelfe, LOGFONT.sizeof);
Lines 2840-2848 Link Here
2840
			Callback callback = new Callback(object, "EnumFontFamExProc", 4);
2866
			Callback callback = new Callback(object, "EnumFontFamExProc", 4);
2841
			int /*long*/ address = callback.getAddress();
2867
			int /*long*/ address = callback.getAddress();
2842
			if (address == 0) SWT.error(SWT.ERROR_NO_MORE_CALLBACKS);
2868
			if (address == 0) SWT.error(SWT.ERROR_NO_MORE_CALLBACKS);
2843
			SCRIPT_PROPERTIES properties = new SCRIPT_PROPERTIES();
2869
			int charSet = sp.fAmbiguousCharSet ? OS.DEFAULT_CHARSET : sp.bCharSet;
2844
			OS.MoveMemory(properties, device.scripts[script], SCRIPT_PROPERTIES.sizeof);
2845
			int charSet = properties.fAmbiguousCharSet ? OS.DEFAULT_CHARSET : properties.bCharSet;
2846
			newLogFont.lfCharSet = (byte)charSet;
2870
			newLogFont.lfCharSet = (byte)charSet;
2847
			OS.EnumFontFamiliesEx(hdc, newLogFont, address, 0, 0);
2871
			OS.EnumFontFamiliesEx(hdc, newLogFont, address, 0, 0);
2848
			callback.dispose();
2872
			callback.dispose();

Return to bug 224550