Lines 47-53
Link Here
|
47 |
StyleItem[] allRuns; |
47 |
StyleItem[] allRuns; |
48 |
StyleItem[][] runs; |
48 |
StyleItem[][] runs; |
49 |
int[] lineOffset, lineY, lineWidth; |
49 |
int[] lineOffset, lineY, lineWidth; |
50 |
|
50 |
|
|
|
51 |
boolean forceMonospace; |
52 |
|
51 |
static final char LTR_MARK = '\u200E', RTL_MARK = '\u200F'; |
53 |
static final char LTR_MARK = '\u200E', RTL_MARK = '\u200F'; |
52 |
static final int SCRIPT_VISATTR_SIZEOF = 2; |
54 |
static final int SCRIPT_VISATTR_SIZEOF = 2; |
53 |
static final int GOFFSET_SIZEOF = 8; |
55 |
static final int GOFFSET_SIZEOF = 8; |
Lines 146-151
Link Here
|
146 |
styles[1] = new StyleItem(); |
148 |
styles[1] = new StyleItem(); |
147 |
text = ""; //$NON-NLS-1$ |
149 |
text = ""; //$NON-NLS-1$ |
148 |
if (device.tracking) device.new_Object(this); |
150 |
if (device.tracking) device.new_Object(this); |
|
|
151 |
|
152 |
forceMonospace = false; |
149 |
} |
153 |
} |
150 |
|
154 |
|
151 |
void breakRun(StyleItem run) { |
155 |
void breakRun(StyleItem run) { |
Lines 172-179
Link Here
|
172 |
allRuns = itemize(); |
176 |
allRuns = itemize(); |
173 |
for (int i=0; i<allRuns.length - 1; i++) { |
177 |
for (int i=0; i<allRuns.length - 1; i++) { |
174 |
StyleItem run = allRuns[i]; |
178 |
StyleItem run = allRuns[i]; |
175 |
OS.SelectObject(srcHdc, getItemFont(run)); |
179 |
int hFont = getItemFont(run); |
|
|
180 |
OS.SelectObject(srcHdc, hFont); |
176 |
shape(srcHdc, run); |
181 |
shape(srcHdc, run); |
|
|
182 |
|
183 |
if (forceMonospace && font != null && hFont != font.handle) { |
184 |
forceMonospace(srcHdc, run); |
185 |
} |
177 |
} |
186 |
} |
178 |
SCRIPT_LOGATTR logAttr = new SCRIPT_LOGATTR(); |
187 |
SCRIPT_LOGATTR logAttr = new SCRIPT_LOGATTR(); |
179 |
SCRIPT_PROPERTIES properties = new SCRIPT_PROPERTIES(); |
188 |
SCRIPT_PROPERTIES properties = new SCRIPT_PROPERTIES(); |
Lines 280-288
Link Here
|
280 |
newRun.analysis = run.analysis; |
289 |
newRun.analysis = run.analysis; |
281 |
run.free(); |
290 |
run.free(); |
282 |
run.length = start; |
291 |
run.length = start; |
283 |
OS.SelectObject(srcHdc, getItemFont(run)); |
292 |
int hFont = getItemFont(run); |
|
|
293 |
OS.SelectObject(srcHdc, hFont); |
284 |
shape (srcHdc, run); |
294 |
shape (srcHdc, run); |
285 |
shape (srcHdc, newRun); |
295 |
shape (srcHdc, newRun); |
|
|
296 |
if (forceMonospace && font != null && hFont != font.handle) { |
297 |
forceMonospace(srcHdc, run); |
298 |
forceMonospace(srcHdc, newRun); |
299 |
} |
286 |
StyleItem[] newAllRuns = new StyleItem[allRuns.length + 1]; |
300 |
StyleItem[] newAllRuns = new StyleItem[allRuns.length + 1]; |
287 |
System.arraycopy(allRuns, 0, newAllRuns, 0, i + 1); |
301 |
System.arraycopy(allRuns, 0, newAllRuns, 0, i + 1); |
288 |
System.arraycopy(allRuns, i + 1, newAllRuns, i + 2, allRuns.length - i - 1); |
302 |
System.arraycopy(allRuns, i + 1, newAllRuns, i + 2, allRuns.length - i - 1); |
Lines 491-505
Link Here
|
491 |
drawX += run.width; |
505 |
drawX += run.width; |
492 |
} |
506 |
} |
493 |
drawX = alignmentX; |
507 |
drawX = alignmentX; |
|
|
508 |
boolean endsWithLineBreak = false; |
494 |
for (int i = 0; i < lineRuns.length; i++) { |
509 |
for (int i = 0; i < lineRuns.length; i++) { |
495 |
StyleItem run = lineRuns[i]; |
510 |
StyleItem run = lineRuns[i]; |
496 |
if (run.length == 0) continue; |
511 |
if (run.length == 0) continue; |
497 |
if (drawX > clip.x + clip.width) break; |
512 |
if (drawX > clip.x + clip.width) break; |
498 |
if (drawX + run.width >= clip.x) { |
513 |
if (drawX + run.width >= clip.x) { |
|
|
514 |
int end = run.start + run.length - 1; |
515 |
boolean fullSelection = hasSelection && selectionStart <= run.start && selectionEnd >= end; |
499 |
if (!run.tab && (!run.lineBreak || run.softBreak)) { |
516 |
if (!run.tab && (!run.lineBreak || run.softBreak)) { |
500 |
int end = run.start + run.length - 1; |
|
|
501 |
int fg = foreground; |
517 |
int fg = foreground; |
502 |
boolean fullSelection = hasSelection && selectionStart <= run.start && selectionEnd >= end; |
|
|
503 |
if (fullSelection) { |
518 |
if (fullSelection) { |
504 |
fg = selectionForeground.handle; |
519 |
fg = selectionForeground.handle; |
505 |
} else { |
520 |
} else { |
Lines 527-534
Link Here
|
527 |
rect.bottom = drawY + lineHeight; |
542 |
rect.bottom = drawY + lineHeight; |
528 |
OS.ScriptTextOut(hdc, run.psc, drawX, drawRunY, OS.ETO_CLIPPED, rect, run.analysis , 0, 0, run.glyphs, run.glyphCount, run.advances, null, run.goffsets); |
543 |
OS.ScriptTextOut(hdc, run.psc, drawX, drawRunY, OS.ETO_CLIPPED, rect, run.analysis , 0, 0, run.glyphs, run.glyphCount, run.advances, null, run.goffsets); |
529 |
} |
544 |
} |
530 |
} |
545 |
} |
531 |
} |
546 |
} |
|
|
547 |
endsWithLineBreak = run.lineBreak && !run.softBreak; |
532 |
drawX += run.width; |
548 |
drawX += run.width; |
533 |
} |
549 |
} |
534 |
} |
550 |
} |
Lines 1963-1966
Link Here
|
1963 |
} |
1979 |
} |
1964 |
return offset; |
1980 |
return offset; |
1965 |
} |
1981 |
} |
|
|
1982 |
|
1983 |
/** |
1984 |
* Sets whether using the force monospace operation. |
1985 |
* |
1986 |
* @param forceMonospace whether using the force monospace operation |
1987 |
*/ |
1988 |
public void setForceMonospace (boolean forceMonospace) { |
1989 |
this.forceMonospace = forceMonospace; |
1990 |
} |
1991 |
|
1992 |
/** |
1993 |
* return whether using the force monospace operation. |
1994 |
* |
1995 |
* @return whether using the force monospace operation. |
1996 |
*/ |
1997 |
public boolean getForceMonospace () { |
1998 |
return forceMonospace; |
1999 |
} |
2000 |
|
2001 |
/** |
2002 |
* Force monospace. |
2003 |
* For example, MS Gothic is a monospaced font. |
2004 |
* However width of regular is not same as bold. |
2005 |
* This method resolve this problem. |
2006 |
* |
2007 |
* This method does not include the resolution of the problem 417434 in Microsoft Knowledge Base. |
2008 |
* 417434 described a problem related to east asian full width characters. |
2009 |
* In monospace font, full width characters need twice width of half width characters. |
2010 |
* However, before WindowsXP, full width characters is not twich width of half width charcters in specific size. |
2011 |
* |
2012 |
* @param forceMonospace whether using the force monospace operation |
2013 |
* |
2014 |
* @see http://support.microsoft.com/default.aspx?scid=kb;ja;JP417434 |
2015 |
*/ |
2016 |
void forceMonospace(int srcHdc, StyleItem run) { |
2017 |
StyleItem dummyRun = new StyleItem(); |
2018 |
|
2019 |
dummyRun.style = new TextStyle(font, run.style.foreground, run.style.background); |
2020 |
dummyRun.analysis = run.analysis; |
2021 |
dummyRun.start = run.start; |
2022 |
dummyRun.length = run.length; |
2023 |
OS.SelectObject(srcHdc, font.handle); |
2024 |
shape(srcHdc, dummyRun); |
2025 |
int temp; |
2026 |
temp = run.advances; run.advances = dummyRun.advances; dummyRun.advances = temp; |
2027 |
temp = run.goffsets; run.goffsets = dummyRun.goffsets; dummyRun.goffsets = temp; |
2028 |
run.width = dummyRun.width; |
2029 |
|
2030 |
dummyRun.free(); |
2031 |
} |
2032 |
|
1966 |
} |
2033 |
} |