Java 类org.eclipse.swt.graphics.FontData 实例源码

项目:neoscada    文件:TitleRenderer.java   
private Font createFont ( final ResourceManager resourceManager )
{
    final Font defaultFont = resourceManager.getDevice ().getSystemFont ();

    if ( defaultFont == null )
    {
        return null;
    }

    final FontData fd[] = FontDescriptor.copy ( defaultFont.getFontData () );
    if ( fd == null )
    {
        return null;
    }

    for ( final FontData f : fd )
    {
        if ( this.fontSize > 0 )
        {
            f.setHeight ( this.fontSize );
        }
    }
    return resourceManager.createFont ( FontDescriptor.createFrom ( fd ) );
}
项目:convertigo-eclipse    文件:ViewLabelProvider.java   
public ViewLabelProvider() {
    Device device = Display.getCurrent();

    fontSystem = device.getSystemFont();

    FontData fontData = fontSystem.getFontData()[0];

    fontDetectedDatabaseObject = new Font(device, fontData);

    FontData fontDataModified = fontSystem.getFontData()[0];
    fontDataModified.setStyle(SWT.BOLD);
    fontModifiedDatabaseObject = new Font(device, fontDataModified);

    colorUnloadedProject = new Color(device, 12, 116, 176);
    colorDisabledDatabaseObject = new Color(device, 255, 0, 0);
    colorInheritedDatabaseObject = new Color(device, 150, 150, 150);
    colorUnreachableDatabaseObject = new Color(device, 255, 140, 0);
    colorDetectedDatabaseObject = new Color(device, 192, 219, 207);
}
项目:convertigo-eclipse    文件:StatisticsDialog.java   
private void addStats() {

        for (String key : statsProject.keySet()) {
            if (key != project.getName()) {
                CLabel title = new CLabel(descriptifRight, SWT.BOLD);
                title.setText(key);
                title.setImage(new Image(display, getClass()
                        .getResourceAsStream(
                                "images/stats_"
                                        + key.replaceAll(" ", "_")
                                                .toLowerCase() + "_16x16.png")));
                title.setBackground(new Color(display, 255, 255, 255));
                title.setMargins(10, 10, 0, 0);

                FontData[] fd = title.getFont().getFontData();
                fd[0].setStyle(SWT.BOLD);
                title.setFont(new Font(title.getFont().getDevice(), fd));

                CLabel subText = new CLabel(descriptifRight, SWT.NONE);
                subText.setText(statsProject.get(key)
                        .replaceAll("<br/>", "\r\n").replaceAll("&nbsp;", " "));
                subText.setBackground(new Color(display, 255, 255, 255));
                subText.setMargins(30, 0, 0, 0);
            }
        }
    }
项目:avoCADo    文件:MELabel.java   
@Override
void paintElement(PaintEvent e) {
    GC g = e.gc;
    g.setBackground(this.getBackground());
    int width  = this.getBounds().width;
    int height = this.getBounds().height;

    // clear entire canvas where button will be painted
    g.fillRectangle(0, 0, width, height);

    // draw text
    g.setForeground(this.meColorForeground);
    FontData fd = new FontData();
    fd.setHeight(8);
    if(textIsBold){
        fd.setStyle(SWT.BOLD);
    }else{
        fd.setStyle(SWT.NORMAL);
    }
    g.setFont(new Font(this.getDisplay(), fd));
    Point textPt = g.textExtent(this.meLabel);          
    g.drawText(this.meLabel, (width-textPt.x)/2, (height-textPt.y)/2);
}
项目:SWET    文件:TipDayEx.java   
private void fillTipArea() {
    if (TipDayEx.fontName == null) {
        final FontData[] fontData = Display.getDefault().getSystemFont()
                .getFontData();
        if (fontData != null && fontData.length > 0) {
            TipDayEx.fontName = String.format("\"%s\"", fontData[0].getName());
        } else {
            TipDayEx.fontName = "Arial,​\"Helvetica Neue\",​Helvetica,​sans-serif";
        }
    }
    String text = String.format(
            "<html><body bgcolor=\"#EFEFEF\" text=\"#000000\" style='font-family:%s;font-size=14px\'>%s</body></html>",
            TipDayEx.fontName, this.tips.get(TipDayEx.index));
    // System.err.println(text);
    this.tipArea.setText(text);
}
项目:SWET    文件:TipDayEx.java   
private void fillTipArea() {
    if (TipDayEx.fontName == null) {
        final FontData[] fontData = Display.getDefault().getSystemFont()
                .getFontData();
        if (fontData != null && fontData.length > 0) {
            TipDayEx.fontName = String.format("\"%s\"", fontData[0].getName());
        } else {
            TipDayEx.fontName = "Arial,​\"Helvetica Neue\",​Helvetica,​sans-serif";
        }
    }
    String text = String.format(
            "<html><body bgcolor=\"#EFEFEF\" text=\"#000000\" style='font-family:%s;font-size=14px\'>%s</body></html>",
            TipDayEx.fontName, this.tips.get(TipDayEx.index));
    System.err.println(text);
    this.tipArea.setText(text);
}
项目:Hydrograph    文件:HeaderAndDataFormattingDialog.java   
private void addSelectionListeneronToFontButton(Button fontButton, TableEditor fontEditor) {
    fontButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            String fontdata = "";
            dialog = new FontDialog(Display.getCurrent().getActiveShell(), SWT.NONE);
            dialog.setText("Select Font");
            String string = formatMap.get(excelFormats[4]);
            fontdata = checkDefaultValue(fontEditor, fontdata, string);
            RGB checkDefaultColor = checkDefaultColor(fontdata, string);
            dialog.setRGB(checkDefaultColor);
            FontData defaultFont = new FontData(fontdata);
            dialog.setFontData(defaultFont);
            FontData newFont = dialog.open();
            RGB rgb = dialog.getRGB();
            String convertRGBToHEX = convertRGBToHEX(rgb);
            if (newFont != null) {
                fontEditor.getItem().setText(1, newFont.toString() + "|" + convertRGBToHEX);

            }
        }

    });
}
项目:Hydrograph    文件:CommentBoxLabelEditManager.java   
/**
 * update scaledFonts
 * @param zoom
 *              at zoom 
 */
private void updateScaledFont(double zoom) {
    if (cachedZoom == zoom)
        return;

    Text text = (Text)getCellEditor().getControl();
    Font font = getEditPart().getFigure().getFont();

    disposeScaledFont();
    cachedZoom = zoom;
    if (zoom == 1.0)
        text.setFont(font);
    else {
        FontData fd = font.getFontData()[0];
        fd.setHeight((int)(fd.getHeight() * zoom));
        text.setFont(scaledFont = new Font(null, fd));
    }
}
项目:solidity-ide    文件:CustomCSSHelpHoverProvider.java   
protected String getStyleSheet() {
    if (fgStyleSheet == null)
        fgStyleSheet = loadStyleSheet();
    String css = fgStyleSheet;
    if (css != null) {
        FontData fontData = JFaceResources.getFontRegistry().getFontData(
                fontSymbolicName)[0];
        css = HTMLPrinter.convertTopLevelFont(css, fontData);
    }
    return css;
}
项目:PhET    文件:SWTGraphics2D.java   
/** {@inheritDoc} */
public Font getFont() {
    if (curFont != null) {
        int style = Font.PLAIN;

        final FontData[] fd = curFont.getFontData();
        if (fd.length > 0) {
            if ((fd[0].getStyle() & SWT.BOLD) != 0) {
                style = style | Font.BOLD;
            }
            if ((fd[0].getStyle() & SWT.ITALIC) != 0) {
                style = style | SWT.ITALIC;
            }

            return new Font(fd[0].getName(), style, fd[0].getHeight());
        }
        return null;
    }
    else {
        return null;
    }
}
项目:TranskribusSwtGui    文件:VirtualKeyboard.java   
private Button initButton(Pair<Integer, String> c) {
        Button b = new Button(this, SWT.PUSH);

        FontData[] fD = b.getFont().getFontData();
        fD[0].setHeight(16);
//      b.setFont( new Font(getDisplay(), fD[0]));
        b.setFont(Fonts.createFont(fD[0]));

        String text = c.getRight();
        Integer code = c.getLeft();

//      b.setText(Character.toString(c));
//      b.setToolTipText(Character.getName(c));

        //Character tmp = c.toCharArray()[0];
        b.setText(text);
        b.setToolTipText(Character.getName(code));

        b.addSelectionListener(btnSelectionListener);

        return b;
    }
项目:ermaster-k    文件:CompositeFactory.java   
public static Label createExampleLabel(Composite composite, String title,
        int span) {
    Label label = new Label(composite, SWT.NONE);
    label.setText(ResourceString.getResourceString(title));

    if (span > 0) {
        GridData gridData = new GridData();
        gridData.horizontalSpan = span;
        label.setLayoutData(gridData);
    }

    FontData fontData = Display.getCurrent().getSystemFont().getFontData()[0];
    Font font = Resources.getFont(fontData.getName(), 8);
    label.setFont(font);

    return label;
}
项目:team-explorer-everywhere    文件:WorkItemHistoryControl.java   
private void setTextControlFont(final Text text) {
    final FontData[] tahomaFontData = getShell().getDisplay().getFontList("Tahoma", true); //$NON-NLS-1$
    if (tahomaFontData != null && tahomaFontData.length > 0) {
        historyFont = new Font(getShell().getDisplay(), "Tahoma", 10, SWT.NORMAL); //$NON-NLS-1$
    }

    if (historyFont != null) {
        text.setFont(historyFont);
    }

    addDisposeListener(new DisposeListener() {
        @Override
        public void widgetDisposed(final DisposeEvent e) {
            if (historyFont != null) {
                historyFont.dispose();
            }
        }
    });
}
项目:team-explorer-everywhere    文件:Datepicker.java   
private void configureMacOSX() {
    final FontData fontData = font.getFontData()[0];
    fontData.setHeight(11);
    font.dispose();
    font = new Font(getDisplay(), fontData);

    final FontData fontBoldData = fontBold.getFontData()[0];
    fontBoldData.setHeight(11);
    fontBold.dispose();
    fontBold = new Font(getDisplay(), fontBoldData);

    setBackground(getDisplay().getSystemColor(SWT.COLOR_WHITE));

    spacing = new Point(0, 2);

    weekdayStringLength = 1;
    dayAlignment = SWT.RIGHT;
    drawOtherDays = false;
}
项目:google-cloud-eclipse    文件:FontUtil.java   
/**
 * Converts the font of the control by adding a single style bit, unless the font already have
 * that style.
 * <p>
 * If the font is converted, it will attach a {@link DisposeListener}
 * to the <code>control</code> to dispose the font when it's not needed anymore.
 * <p>
 * <em>If converting fonts is a frequent operation, this method will create
 * several {@link DisposeListener}s that can lead to high resource allocation</em>
 *
 * @param control whose font will be changed
 * @param style e.g. SWT.BOLD or SWT.ITALIC
 */
public static void convertFont(Control control, int style) {
  for (FontData fontData : control.getFont().getFontData()) {
    if (hasStyle(fontData, style)) {
      return;
    }
  }
  FontDescriptor fontDescriptor = FontDescriptor.createFrom(control.getFont()).setStyle(style);
  final Font newFont = fontDescriptor.createFont(control.getDisplay());
  control.setFont(newFont);
  control.addDisposeListener(new DisposeListener() {
    @Override
    public void widgetDisposed(DisposeEvent event) {
      newFont.dispose();
    }
  });
}
项目:ermasterr    文件:NodeElementEditPart.java   
protected Font changeFont(final IFigure figure) {
    final NodeElement nodeElement = (NodeElement) getModel();

    String fontName = nodeElement.getFontName();
    int fontSize = nodeElement.getFontSize();

    if (Check.isEmpty(fontName)) {
        final FontData fontData = Display.getCurrent().getSystemFont().getFontData()[0];
        fontName = fontData.getName();
        nodeElement.setFontName(fontName);
    }
    if (fontSize <= 0) {
        fontSize = ViewableModel.DEFAULT_FONT_SIZE;
        nodeElement.setFontSize(fontSize);
    }

    font = Resources.getFont(fontName, fontSize);

    figure.setFont(font);

    return font;
}
项目:TuxGuitar-1.3.1-fork    文件:TGMatrixConfig.java   
public void save(FontData fontData,
                 RGB rgbForeground,
                 RGB rgbBorder,
                 RGB rgbPosition,
                 RGB rgbNote,
                 RGB rgbPlay,
                 RGB rgbLines[]){
    TGConfigManager config = TuxGuitar.getInstance().getConfig();

    config.setValue(TGConfigKeys.MATRIX_FONT,fontData);
    config.setValue(TGConfigKeys.MATRIX_COLOR_FOREGROUND,rgbForeground);
    config.setValue(TGConfigKeys.MATRIX_COLOR_BORDER,rgbBorder);
    config.setValue(TGConfigKeys.MATRIX_COLOR_POSITION,rgbPosition);
    config.setValue(TGConfigKeys.MATRIX_COLOR_NOTE,rgbNote);
    config.setValue(TGConfigKeys.MATRIX_COLOR_PLAY_NOTE,rgbPlay);
    config.setValue(TGConfigKeys.MATRIX_COLOR_LINE_1,rgbLines[0]);
    config.setValue(TGConfigKeys.MATRIX_COLOR_LINE_2,rgbLines[1]);
    config.setValue(TGConfigKeys.MATRIX_COLOR_LINE_3,rgbLines[2]);
}
项目:TuxGuitar-1.3.1-fork    文件:Option.java   
protected Label showLabel(Composite parent,int hAlign,int vAlign,boolean grabExcessHSpace,boolean grabExcessVSpace,int labelStyle,int fontStyle,int fontScale,String text){
    Label label = new Label(parent,labelStyle);
    label.setText(text);
    label.setLayoutData(new GridData(hAlign,vAlign,grabExcessHSpace,grabExcessVSpace));

    FontData[] fontDatas = label.getFont().getFontData();
    if(fontDatas.length > 0){
        final Font font = new Font(label.getDisplay(),fontDatas[0].getName(),(fontDatas[0].getHeight() + fontScale),fontStyle);
        label.setFont(font);
        label.addDisposeListener(new DisposeListener() {
            public void widgetDisposed(DisposeEvent arg0) {
                font.dispose();
            }
        });
    }
    return label;
}
项目:TuxGuitar-1.3.1-fork    文件:StylesOption.java   
private void addFontButtonListeners(final Button button, final FontData fontData){
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent arg0) {
            if(StylesOption.this.initialized){
                Font font = new Font(getDisplay(),fontData);
                FontData[] fontDataList = font.getFontData();
                font.dispose();
                FontDialog fontDialog = new FontDialog(getShell());
                fontDialog.setFontList(fontDataList);
                FontData result = fontDialog.open();
                if(result != null){
                    loadFontData(result, fontData,button);
                }
            }
        }
    });
}
项目:TuxGuitar-1.3.1-fork    文件:TGFretBoardConfig.java   
private FontData getFontChooser(final Composite parent,String title,FontData fontData){
    final FontData selection = new FontData(fontData.getName(),fontData.getHeight(),fontData.getStyle());

    Label label = new Label(parent, SWT.NULL);
    label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, true));
    label.setText(title);

    Button button = new Button(parent, SWT.PUSH);
    button.setLayoutData(getAlignmentData(MINIMUM_CONTROL_WIDTH,SWT.FILL));
    button.setText(TuxGuitar.getProperty("choose"));
    button.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent arg0) {
            Font font = new Font(parent.getDisplay(),selection);
            FontDialog fontDialog = new FontDialog(parent.getShell());
            fontDialog.setFontList(font.getFontData());
            FontData fd = fontDialog.open();
            if(fd != null){
                selection.setName( fd.getName() );
                selection.setHeight( fd.getHeight() );
                selection.setStyle( fd.getStyle() );
            }
            font.dispose();
        }
    });
    return selection;
}
项目:TuxGuitar-1.3.1-fork    文件:TGConfigManager.java   
public FontData getFontDataConfigValue(String key){
    try{
        String value = getProperties().getValue(key);
        if(value != null){
            String[] values = value.trim().split(",");
            if(values != null && values.length == 3){
                try{
                    String name = values[0].trim();
                    int size = Integer.parseInt(values[1].trim());
                    int style = Integer.parseInt(values[2].trim());
                    return new FontData( (name == null ? "" : name),size,style);
                }catch(NumberFormatException e){
                    e.printStackTrace();
                }
            }
        }
    }catch(Throwable throwable){
        throwable.printStackTrace();
    }
    return new FontData();
}
项目:TuxGuitar-1.3.1-fork    文件:TGCommunityStartupScreen.java   
private void addTitle( Composite parent , String text ){
    Label label = new Label( parent , SWT.LEFT );
    label.setLayoutData(new GridData(SWT.FILL,SWT.TOP,true,true,2,1));
    label.setText(text);

    FontData[] fontDatas = label.getFont().getFontData();
    if(fontDatas.length > 0){
        int fHeight = (fontDatas[0].getHeight() + 2);
        int fStyle = (fontDatas[0].getStyle() | SWT.BOLD);
        final Font font = new Font(label.getDisplay(),fontDatas[0].getName(),fHeight, fStyle);
        label.setFont(font);
        label.addDisposeListener(new DisposeListener() {
            public void widgetDisposed(DisposeEvent arg0) {
                font.dispose();
            }
        });
    }
}
项目:ermasterr    文件:CompositeFactory.java   
public static Label createExampleLabel(final Composite composite, final String title, final int span) {
    final Label label = new Label(composite, SWT.NONE);
    label.setText(ResourceString.getResourceString(title));

    if (span > 0) {
        final GridData gridData = new GridData();
        gridData.horizontalSpan = span;
        label.setLayoutData(gridData);
    }

    final FontData fontData = Display.getCurrent().getSystemFont().getFontData()[0];
    final Font font = Resources.getFont(fontData.getName(), 8);
    label.setFont(font);

    return label;
}
项目:n4js    文件:OpenTypeSelectionDialog.java   
@Override
public Font get() {
    final Font font = getDialogArea().getFont();
    final FontData[] data = font.getFontData();
    for (int i = 0; i < data.length; i++) {
        data[i].setStyle(BOLD);
    }
    return new Font(font.getDevice(), data);
}
项目:eZooKeeper    文件:JmxDocFormText.java   
public static void initFormText(FormText formText) {

        formText.setWhitespaceNormalized(false);

        Font formTextFont = formText.getFont();
        FontData formTextFontData = formTextFont.getFontData()[0];

        FontData h1FontData = new FontData(formTextFontData.getName(), formTextFontData.getHeight() + 5, SWT.BOLD);
        final Font h1Font = new Font(formTextFont.getDevice(), h1FontData);
        formText.setFont(FONT_H1_KEY, h1Font);

        FontData h3FontData = new FontData(formTextFontData.getName(), formTextFontData.getHeight() + 3, SWT.BOLD);
        final Font h3Font = new Font(formTextFont.getDevice(), h3FontData);
        formText.setFont(FONT_H3_KEY, h3Font);

        Font codeFont = JFaceResources.getTextFont();
        formText.setFont(FONT_CODE_KEY, codeFont);

        formText.addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent e) {
                h1Font.dispose();
                h3Font.dispose();
            }
        });

        // Set fontKeySet = JFaceResources.getFontRegistry().getKeySet();
        // if (fontKeySet != null) {
        // for (Object fontKey : fontKeySet) {
        // System.out.println(fontKey);
        // }
        // }

    }
项目:neoscada    文件:TreeNodeLabelProvider.java   
public TreeNodeLabelProvider ( final TreeViewer viewer, final IObservableMap... attributeMaps )
{
    super ( attributeMaps );
    this.viewer = viewer;

    this.defaultFont = viewer.getControl ().getFont ();

    final FontData[] fds = this.viewer.getControl ().getFont ().getFontData ();
    for ( final FontData fd : fds )
    {
        fd.setStyle ( SWT.ITALIC );
    }
    this.font = new Font ( this.viewer.getControl ().getDisplay (), fds );
}
项目:tap17-muggl-javaee    文件:GeneratorSelectionComposite.java   
/**
 * Set the supplied text for the provider description text widget and make its font style
 * bold.
 * @param text The text for the provider description text widget.
 */
private void setProviderLoadingFailureText(String text) {
    this.providerDescriptionText.setText(text);
    Font font = this.providerDescriptionText.getFont();
    FontData[] fontData = font.getFontData();
    fontData[0].setStyle(SWT.BOLD);
    this.providerDescriptionText.setFont(new Font(this.display, fontData));
}
项目:tap17-muggl-javaee    文件:GeneratorSelectionComposite.java   
/**
 * Set the supplied text for the generator description text widget and make its font style
 * bold.
 * @param text The text for the generator description text widget.
 */
private void setGeneratorLoadingFailureText(String text) {
    this.generatorDescriptionText.setText(text);
    Font font = this.generatorDescriptionText.getFont();
    FontData[] fontData = font.getFontData();
    fontData[0].setStyle(SWT.BOLD);
    this.generatorDescriptionText.setFont(new Font(this.display, fontData));
}
项目:Hydrograph    文件:ParameterGridDialog.java   
private void attachNote(final Composite container) {
    Label lblParameterGridNote=new Label(container, SWT.NONE);
    FontData fontData = lblParameterGridNote.getFont().getFontData()[0];
    Font font = new Font(lblParameterGridNote.getDisplay(), new FontData(fontData.getName(), fontData
        .getHeight(), SWT.ITALIC));
    lblParameterGridNote.setText("Note - New parameters will be visible only after you save the job.");
    lblParameterGridNote.setFont(font);

    if(!visibleParameterGirdNote)
        lblParameterGridNote.setVisible(false);
}
项目:Hydrograph    文件:JobRunPreferenceComposite.java   
/**
 * Create console buffer widget
 * @param bufferSize
 */
private void createConsoleBufferWidget(String bufferSize){
    HydroGroup hydroGroup = new HydroGroup(this, SWT.NONE);

    hydroGroup.setHydroGroupText(Messages.HYDROGRAPH_CONSOLE_PREFERANCE_PAGE_GROUP_NAME);
    hydroGroup.setLayout(new GridLayout(1, false));
    hydroGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
    hydroGroup.getHydroGroupClientArea().setLayout(new GridLayout(2, false));

    Label label = new Label(hydroGroup.getHydroGroupClientArea(), SWT.NONE);

    label.setText(Messages.PREFERANCE_CONSOLE_BUFFER_SIZE);

    textWidget = new Text(hydroGroup.getHydroGroupClientArea(), SWT.BORDER);
    textWidget.setText(bufferSize);
    textWidget.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
    textWidget.setTextLimit(6);

    attachConsoleBufferValidator();

    Composite purgeComposite = new Composite(hydroGroup.getHydroGroupClientArea(), SWT.NONE);
    purgeComposite.setLayout(new GridLayout(2, false));
    purgeComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));

    Label lblNote = new Label(purgeComposite, SWT.TOP | SWT.WRAP);
    lblNote.setText(Messages.PREFERANCE_PAGE_NOTE);
    FontData fontData = lblNote.getFont().getFontData()[0];
    Font font = new Font(purgeComposite.getDisplay(), new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD));
    lblNote.setFont(font);
    Label lblmsg = new Label(purgeComposite, SWT.TOP | SWT.WRAP);
    lblmsg.setText(Messages.UI_PERFORMANCE_NOTE_IN_CASE_OF_CHANGE_IN_BUFFER_SIZE);

}
项目:parabuild-ci    文件:SWTGraphics2D.java   
/**
 * Returns the font in form of an awt font created 
 * with the parameters of the font of the swt graphic 
 * composite.
 * @see java.awt.Graphics#getFont()
 */
public Font getFont() {
    // retrieve the swt font description in an os indept way
    FontData[] fontData = gc.getFont().getFontData();
    // create a new awt font with the appropiate data
    return SWTUtils.toAwtFont(gc.getDevice(), fontData[0], true);
}
项目:BiglyBT    文件:SubscriptionWizard.java   
private void createFonts() {

        FontData[] fDatas = shell.getFont().getFontData();

        for(int i = 0 ; i < fDatas.length ; i++) {
            fDatas[i].setStyle(SWT.BOLD);
        }
        boldFont = new Font(display,fDatas);


        for(int i = 0 ; i < fDatas.length ; i++) {
            if(com.biglybt.core.util.Constants.isOSX) {
                fDatas[i].setHeight(12);
            } else {
                fDatas[i].setHeight(10);
            }
        }
        subTitleFont = new Font(display,fDatas);

        for(int i = 0 ; i < fDatas.length ; i++) {
            if(com.biglybt.core.util.Constants.isOSX) {
                fDatas[i].setHeight(17);
            } else {
                fDatas[i].setHeight(14);
            }
        }
        titleFont = new Font(display,fDatas);

        // When GTK3 can show a textbox without a border, we can remove the logic
        textInputFont = FontUtils.getFontWithHeight(shell.getFont(), null, Utils.isGTK3 ? 12 : 14);


    }
项目:openaudible    文件:FontShop.java   
private Font newStyledFont(int index, int style) {

        Font f = regFonts[index];
        if (isset(f)) {
            FontData[] fontData = f.getFontData();
            fontData[0].setStyle(style);
            fontData[0].setLocale(Translate.getLocale().toString());
            return new Font(Display.getDefault(), fontData);
        } else {
            Application.report("newBold failed. f=" + f);
        }
        return null;
    }
项目:maf    文件:SWTResourceManager.java   
/**
 * Returns a bold version of the given {@link Font}.
 * 
 * @param baseFont
 *            the {@link Font} for which a bold version is desired
 * @return the bold version of the given {@link Font}
 */
public static Font getBoldFont(Font baseFont) {
    Font font = m_fontToBoldFontMap.get(baseFont);
    if (font == null) {
        FontData fontDatas[] = baseFont.getFontData();
        FontData data = fontDatas[0];
        font = new Font(Display.getCurrent(), data.getName(), data.getHeight(), SWT.BOLD);
        m_fontToBoldFontMap.put(baseFont, font);
    }
    return font;
}
项目:ARXPlugin    文件:ComponentTitledSeparator.java   
/**
 * Constructs a new instance of this class given its parent and a style
 * value describing its behavior and appearance.
 * <p>
 * The style value is either one of the style constants defined in class
 * <code>SWT</code> which is applicable to instances of this class, or must
 * be built by <em>bitwise OR</em>'ing together (that is, using the
 * <code>int</code> "|" operator) two or more of those <code>SWT</code>
 * style constants. The class description lists the style constants that are
 * applicable to the class. Style bits are also inherited from superclasses.
 * </p>
 * 
 * @param parent a composite control which will be the parent of the new
 *            instance (cannot be null)
 * @param style the style of control to construct
 * 
 * @exception IllegalArgumentException <ul>
 *                <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
 *                </ul>
 * @exception SWTException <ul>
 *                <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
 *                thread that created the parent</li>
 *                </ul>
 * 
 */
public ComponentTitledSeparator(final Composite parent, final int style) {
        super(parent, style);
        this.alignment = SWT.LEFT;

        final Color originalColor = new Color(getDisplay(), 0, 88, 150);
        setForeground(originalColor);

        final Font originalFont;
        final FontData[] fontData = getFont().getFontData();
        if (fontData != null && fontData.length > 0) {
                final FontData fd = fontData[0];
                fd.setStyle(SWT.BOLD);
                originalFont = new Font(getDisplay(), fd);
                setFont(originalFont);
        } else {
                originalFont = null;
        }

        this.addListener(SWT.Resize, new Listener() {

                public void handleEvent(final Event event) {
                        redrawComposite();
                }
        });

        this.addDisposeListener(new DisposeListener() {


            public void widgetDisposed(DisposeEvent arg0) {
                if (originalColor != null && !originalColor.isDisposed()) {
                    originalColor.dispose();
                }
                if (originalFont != null && !originalFont.isDisposed()) {
                    originalFont.dispose();
                }
            }

        });
}
项目:ccu-historian    文件:SWTUtils.java   
/**
 * Create an awt font by converting as much information
 * as possible from the provided swt <code>FontData</code>.
 * <p>Generally speaking, given a font size, an swt font will
 * display differently on the screen than the corresponding awt
 * one. Because the SWT toolkit use native graphical ressources whenever
 * it is possible, this fact is platform dependent. To address
 * this issue, it is possible to enforce the method to return
 * an awt font with the same height as the swt one.
 *
 * @param device The swt device being drawn on (display or gc device).
 * @param fontData The swt font to convert.
 * @param ensureSameSize A boolean used to enforce the same size
 * (in pixels) between the swt font and the newly created awt font.
 * @return An awt font converted from the provided swt font.
 */
public static java.awt.Font toAwtFont(Device device, FontData fontData,
        boolean ensureSameSize) {
    int height = (int) Math.round(fontData.getHeight() * device.getDPI().y
            / 72.0);
    // hack to ensure the newly created awt fonts will be rendered with the
    // same height as the swt one
    if (ensureSameSize) {
        GC tmpGC = new GC(device);
        Font tmpFont = new Font(device, fontData);
        tmpGC.setFont(tmpFont);
        JPanel DUMMY_PANEL = new JPanel();
        java.awt.Font tmpAwtFont = new java.awt.Font(fontData.getName(),
                fontData.getStyle(), height);
        if (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az)
                > tmpGC.textExtent(Az).x) {
            while (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az)
                    > tmpGC.textExtent(Az).x) {
                height--;
                tmpAwtFont = new java.awt.Font(fontData.getName(),
                        fontData.getStyle(), height);
            }
        }
        else if (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az)
                < tmpGC.textExtent(Az).x) {
            while (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az)
                    < tmpGC.textExtent(Az).x) {
                height++;
                tmpAwtFont = new java.awt.Font(fontData.getName(),
                        fontData.getStyle(), height);
            }
        }
        tmpFont.dispose();
        tmpGC.dispose();
    }
    return new java.awt.Font(fontData.getName(), fontData.getStyle(),
            height);
}
项目:TranskribusSwtGui    文件:Fonts.java   
public static Font createFontWithHeight(Font f, int height) {
    if (f.getFontData().length > 0) {
        FontData fd = f.getFontData()[0];
        fd.setHeight(height);
        return createFont(fd);
    }
    return null;
}
项目:codegen-ecore    文件:SWTResourceManager.java   
/**
 * Returns a {@link Font} based on its name, height and style. Windows-specific strikeout and underline
 * flags are also supported.
 * 
 * @param name
 *            the name of the font
 * @param size
 *            the size of the font
 * @param style
 *            the style of the font
 * @param strikeout
 *            the strikeout flag (warning: Windows only)
 * @param underline
 *            the underline flag (warning: Windows only)
 * @return {@link Font} The font matching the name, height, style, strikeout and underline
 */
public static Font getFont(String name, int size, int style, boolean strikeout, boolean underline) {
    String fontName = name + '|' + size + '|' + style + '|' + strikeout + '|' + underline;
    Font font = m_fontMap.get(fontName);
    if (font == null) {
        FontData fontData = new FontData(name, size, style);
        if (strikeout || underline) {
            try {
                Class<?> logFontClass = Class.forName("org.eclipse.swt.internal.win32.LOGFONT"); //$NON-NLS-1$
                Object logFont = FontData.class.getField("data").get(fontData); //$NON-NLS-1$
                if (logFont != null && logFontClass != null) {
                    if (strikeout) {
                        logFontClass.getField("lfStrikeOut").set(logFont, Byte.valueOf((byte) 1)); //$NON-NLS-1$
                    }
                    if (underline) {
                        logFontClass.getField("lfUnderline").set(logFont, Byte.valueOf((byte) 1)); //$NON-NLS-1$
                    }
                }
            } catch (Throwable e) {
                System.err.println("Unable to set underline or strikeout" + " (probably on a non-Windows platform). " + e); //$NON-NLS-1$ //$NON-NLS-2$
            }
        }
        font = new Font(Display.getCurrent(), fontData);
        m_fontMap.put(fontName, font);
    }
    return font;
}
项目:codegen-ecore    文件:SWTResourceManager.java   
/**
 * Returns a bold version of the given {@link Font}.
 * 
 * @param baseFont
 *            the {@link Font} for which a bold version is desired
 * @return the bold version of the given {@link Font}
 */
public static Font getBoldFont(Font baseFont) {
    Font font = m_fontToBoldFontMap.get(baseFont);
    if (font == null) {
        FontData fontDatas[] = baseFont.getFontData();
        FontData data = fontDatas[0];
        font = new Font(Display.getCurrent(), data.getName(), data.getHeight(), SWT.BOLD);
        m_fontToBoldFontMap.put(baseFont, font);
    }
    return font;
}
项目:code    文件:ArchitecturalLabelDecoratorBase.java   
private static FontData[] getModifiedFontData(int style) {
    FontData[] styleData = new FontData[ArchitecturalLabelDecoratorBase.baseData.length];
    for (int i = 0; i < styleData.length; i++) {
        FontData base = ArchitecturalLabelDecoratorBase.baseData[i];
        styleData[i] = new FontData(base.getName(), base.getHeight(), base.getStyle() | style);
    }
    return styleData;
}