Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 12949 Details for
Bug 69253
Force monospace font feature (fixed width for bold and regular)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
for org.eclipse.swt plugin
org.eclipse.swt.patch (text/plain), 8.64 KB, created by
Michel Ishizuka
on 2004-07-04 03:01:19 EDT
(
hide
)
Description:
for org.eclipse.swt plugin
Filename:
MIME Type:
Creator:
Michel Ishizuka
Created:
2004-07-04 03:01:19 EDT
Size:
8.64 KB
patch
obsolete
>Index: Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java,v >retrieving revision 1.40 >diff -u -r1.40 TextLayout.java >--- Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java 24 Jun 2004 08:55:52 -0000 1.40 >+++ Eclipse SWT/win32/org/eclipse/swt/graphics/TextLayout.java 4 Jul 2004 05:56:26 -0000 >@@ -47,7 +47,9 @@ > StyleItem[] allRuns; > StyleItem[][] runs; > int[] lineOffset, lineY, lineWidth; >- >+ >+ boolean forceMonospace; >+ > static final char LTR_MARK = '\u200E', RTL_MARK = '\u200F'; > static final int SCRIPT_VISATTR_SIZEOF = 2; > static final int GOFFSET_SIZEOF = 8; >@@ -146,6 +148,8 @@ > styles[1] = new StyleItem(); > text = ""; //$NON-NLS-1$ > if (device.tracking) device.new_Object(this); >+ >+ forceMonospace = false; > } > > void breakRun(StyleItem run) { >@@ -172,8 +176,13 @@ > allRuns = itemize(); > for (int i=0; i<allRuns.length - 1; i++) { > StyleItem run = allRuns[i]; >- OS.SelectObject(srcHdc, getItemFont(run)); >+ int hFont = getItemFont(run); >+ OS.SelectObject(srcHdc, hFont); > shape(srcHdc, run); >+ >+ if (forceMonospace && font != null && hFont != font.handle) { >+ forceMonospace(srcHdc, run); >+ } > } > SCRIPT_LOGATTR logAttr = new SCRIPT_LOGATTR(); > SCRIPT_PROPERTIES properties = new SCRIPT_PROPERTIES(); >@@ -280,9 +289,14 @@ > newRun.analysis = run.analysis; > run.free(); > run.length = start; >- OS.SelectObject(srcHdc, getItemFont(run)); >+ int hFont = getItemFont(run); >+ OS.SelectObject(srcHdc, hFont); > shape (srcHdc, run); > shape (srcHdc, newRun); >+ if (forceMonospace && font != null && hFont != font.handle) { >+ forceMonospace(srcHdc, run); >+ forceMonospace(srcHdc, newRun); >+ } > StyleItem[] newAllRuns = new StyleItem[allRuns.length + 1]; > System.arraycopy(allRuns, 0, newAllRuns, 0, i + 1); > System.arraycopy(allRuns, i + 1, newAllRuns, i + 2, allRuns.length - i - 1); >@@ -491,15 +505,16 @@ > drawX += run.width; > } > drawX = alignmentX; >+ boolean endsWithLineBreak = false; > for (int i = 0; i < lineRuns.length; i++) { > StyleItem run = lineRuns[i]; > if (run.length == 0) continue; > if (drawX > clip.x + clip.width) break; > if (drawX + run.width >= clip.x) { >+ int end = run.start + run.length - 1; >+ boolean fullSelection = hasSelection && selectionStart <= run.start && selectionEnd >= end; > if (!run.tab && (!run.lineBreak || run.softBreak)) { >- int end = run.start + run.length - 1; > int fg = foreground; >- boolean fullSelection = hasSelection && selectionStart <= run.start && selectionEnd >= end; > if (fullSelection) { > fg = selectionForeground.handle; > } else { >@@ -527,8 +542,9 @@ > rect.bottom = drawY + lineHeight; > OS.ScriptTextOut(hdc, run.psc, drawX, drawRunY, OS.ETO_CLIPPED, rect, run.analysis , 0, 0, run.glyphs, run.glyphCount, run.advances, null, run.goffsets); > } >- } >+ } > } >+ endsWithLineBreak = run.lineBreak && !run.softBreak; > drawX += run.width; > } > } >@@ -1963,4 +1979,55 @@ > } > return offset; > } >+ >+/** >+ * Sets whether using the force monospace operation. >+ * >+ * @param forceMonospace whether using the force monospace operation >+ */ >+public void setForceMonospace (boolean forceMonospace) { >+ this.forceMonospace = forceMonospace; >+} >+ >+/** >+ * return whether using the force monospace operation. >+ * >+ * @return whether using the force monospace operation. >+ */ >+public boolean getForceMonospace () { >+ return forceMonospace; >+} >+ >+/** >+ * Force monospace. >+ * For example, MS Gothic is a monospaced font. >+ * However width of regular is not same as bold. >+ * This method resolve this problem. >+ * >+ * This method does not include the resolution of the problem 417434 in Microsoft Knowledge Base. >+ * 417434 described a problem related to east asian full width characters. >+ * In monospace font, full width characters need twice width of half width characters. >+ * However, before WindowsXP, full width characters is not twich width of half width charcters in specific size. >+ * >+ * @param forceMonospace whether using the force monospace operation >+ * >+ * @see http://support.microsoft.com/default.aspx?scid=kb;ja;JP417434 >+ */ >+void forceMonospace(int srcHdc, StyleItem run) { >+ StyleItem dummyRun = new StyleItem(); >+ >+ dummyRun.style = new TextStyle(font, run.style.foreground, run.style.background); >+ dummyRun.analysis = run.analysis; >+ dummyRun.start = run.start; >+ dummyRun.length = run.length; >+ OS.SelectObject(srcHdc, font.handle); >+ shape(srcHdc, dummyRun); >+ int temp; >+ temp = run.advances; run.advances = dummyRun.advances; dummyRun.advances = temp; >+ temp = run.goffsets; run.goffsets = dummyRun.goffsets; dummyRun.goffsets = temp; >+ run.width = dummyRun.width; >+ >+ dummyRun.free(); >+} >+ > } >Index: Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java,v >retrieving revision 1.225 >diff -u -r1.225 StyledText.java >--- Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java 24 Jun 2004 08:55:52 -0000 1.225 >+++ Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java 4 Jul 2004 05:56:34 -0000 >@@ -150,6 +150,8 @@ > Caret defaultCaret = null; > boolean updateCaretDirection = true; > >+ boolean forceMonospace; >+ > final static boolean IS_CARBON; > final static boolean DOUBLE_BUFFERED; > static { >@@ -5323,6 +5325,8 @@ > renderer.dispose(); > } > renderer = new DisplayRenderer(getDisplay(), getFont(), this, tabLength); >+ renderer.forceMonospace = forceMonospace; >+ > lineHeight = renderer.getLineHeight(); > if (wordWrap) { > content = new WrappedContent(renderer, logicalContent); >@@ -7793,4 +7797,45 @@ > // word wrap may have changed on one of the visible lines > super.redraw(); > } >+ >+/** >+ * Sets whether using the force monospace operation. >+ * >+ * @param forceMonospace whether using the force monospace operation >+ * >+ * @see org.eclipse.swt.graphics.TextLayout#forceMonospace(int, StyleItem) >+ */ >+public void setForceMonospace (boolean forceMonospace) { >+ >+ if (this.forceMonospace != forceMonospace) { >+ this.forceMonospace = forceMonospace; >+ >+ //same as #setFont(Font) >+ initializeRenderer(); >+ >+ //line height is not change. >+ //// keep the same top line visible. fixes 5815 >+ //if (lineHeight != oldLineHeight) { >+ // setVerticalScrollOffset(verticalScrollOffset * lineHeight / oldLineHeight, true); >+ // claimBottomFreeSpace(); >+ //} >+ calculateContentWidth(); >+ calculateScrollBars(); >+ if (isBidi()) createCaretBitmaps(); >+ caretDirection = SWT.NULL; >+ // always set the caret location. Fixes 6685 >+ setCaretLocation(); >+ super.redraw(); >+ } >+} >+ >+/** >+ * return whether using the force monospace operation. >+ * >+ * @return whether using the force monospace operation. >+ */ >+public boolean getForceMonospace () { >+ return forceMonospace; >+} >+ > } >Index: Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java,v >retrieving revision 1.31 >diff -u -r1.31 StyledTextRenderer.java >--- Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java 24 Jun 2004 08:55:51 -0000 1.31 >+++ Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextRenderer.java 4 Jul 2004 05:56:35 -0000 >@@ -26,7 +26,9 @@ > private int tabWidth; // width in pixels of a tab character > private int ascent, descent; > private int lineEndSpaceWidth; // width in pixels of the space used to represent line delimiters >- >+ >+ boolean forceMonospace; >+ > /** > * Creates an instance of <class>StyledTextRenderer</class>. > * </p> >@@ -414,6 +416,7 @@ > layout.setOrientation(getOrientation()); > layout.setSegments(getBidiSegments(lineOffset, line)); > layout.setTabs(new int[]{tabWidth}); >+ layout.setForceMonospace (forceMonospace); > int length = line.length(); > StyledTextEvent event = getLineStyleData(lineOffset, line); > StyleRange[] styles = event != null ? event.styles : null; >@@ -442,6 +445,7 @@ > if (lastOffset != length) layout.setStyle(null, lastOffset, length); > return layout; > } >+ > TextLayout createTextLayout(int lineOffset) { > return new TextLayout(device); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 69253
: 12949 |
12950
|
12951
|
12952
|
13082
|
13083
|
13084
|
13085
|
13088
|
13095
|
13096
|
13097
|
13098
|
13125