Java Code Examples for org.eclipse.swt.graphics.TextLayout#setAscent()
The following examples show how to use
org.eclipse.swt.graphics.TextLayout#setAscent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TextPainterWithPadding.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
private TextLayout getCellTextLayout(LayerCell cell) { int orientation = editor.getTable().getStyle() & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT); TextLayout layout = new TextLayout(editor.getTable().getDisplay()); layout.setOrientation(orientation); layout.setSpacing(Constants.SEGMENT_LINE_SPACING); layout.setFont(font); layout.setAscent(ascent); layout.setDescent(descent); // 和 StyledTextEditor 同步 layout.setTabs(new int[] { tabWidth }); Rectangle rectangle = cell.getBounds(); int width = rectangle.width - leftPadding - rightPadding; width -= 1; if (wrapText && width > 0) { layout.setWidth(width); } String displayText = InnerTagUtil.resolveTag(innerTagFactory.parseInnerTag((String) cell.getDataValue())); if (XliffEditorParameter.getInstance().isShowNonpirnttingCharacter()) { displayText = displayText.replaceAll("\\n", Constants.LINE_SEPARATOR_CHARACTER + "\n"); displayText = displayText.replaceAll("\\t", Constants.TAB_CHARACTER + "\u200B"); displayText = displayText.replaceAll(" ", Constants.SPACE_CHARACTER + "\u200B"); } layout.setText(displayText); List<InnerTagBean> innerTagBeans = innerTagFactory.getInnerTagBeans(); for (InnerTagBean innerTagBean : innerTagBeans) { String placeHolder = placeHolderBuilder.getPlaceHolder(innerTagBeans, innerTagBeans.indexOf(innerTagBean)); int start = displayText.indexOf(placeHolder); if (start == -1) { continue; } TextStyle style = new TextStyle(); Point rect = tagRender.calculateTagSize(innerTagBean); style.metrics = new GlyphMetrics(rect.y, 0, rect.x + SEGMENT_LINE_SPACING * 2); layout.setStyle(style, start, start + placeHolder.length() - 1); } return layout; }
Example 2
Source File: TextPainterWithPadding.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
private TextLayout getCellTextLayout(LayerCell cell) { int orientation = editor.getTable().getStyle() & (SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT); TextLayout layout = new TextLayout(editor.getTable().getDisplay()); layout.setOrientation(orientation); layout.setSpacing(Constants.SEGMENT_LINE_SPACING); layout.setFont(font); layout.setAscent(ascent); layout.setDescent(descent); // 和 StyledTextEditor 同步 layout.setTabs(new int[] { tabWidth }); Rectangle rectangle = cell.getBounds(); int width = rectangle.width - leftPadding - rightPadding; width -= 1; if (wrapText && width > 0) { layout.setWidth(width); } String displayText = InnerTagUtil.resolveTag(innerTagFactory.parseInnerTag((String) cell.getDataValue())); if (XliffEditorParameter.getInstance().isShowNonpirnttingCharacter()) { displayText = displayText.replaceAll("\\n", Constants.LINE_SEPARATOR_CHARACTER + "\n"); displayText = displayText.replaceAll("\\t", Constants.TAB_CHARACTER + ""); displayText = displayText.replaceAll(" ", Constants.SPACE_CHARACTER + ""); } layout.setText(displayText); List<InnerTagBean> innerTagBeans = innerTagFactory.getInnerTagBeans(); for (InnerTagBean innerTagBean : innerTagBeans) { String placeHolder = placeHolderBuilder.getPlaceHolder(innerTagBeans, innerTagBeans.indexOf(innerTagBean)); int start = displayText.indexOf(placeHolder); if (start == -1) { continue; } TextStyle style = new TextStyle(); Point rect = tagRender.calculateTagSize(innerTagBean); style.metrics = new GlyphMetrics(rect.y, 0, rect.x + SEGMENT_LINE_SPACING * 2); layout.setStyle(style, start, start + placeHolder.length() - 1); } return layout; }