double height = ascent > 14 ? ascent : ascent + (15 - ascent) / 3; DialogBaseUnits dialogBaseUnits = new DialogBaseUnits(averageCharWidth, height); if (LOGGER.isLoggable(Level.CONFIG)) { LOGGER.config(
/** * Computes and returns the horizontal dialog base units. * Honors the font, font size and resolution.<p> * * Implementation Note: 14dluY map to 22 pixel for 8pt Tahoma on 96 dpi. * I could not yet manage to compute the Microsoft compliant font height. * Therefore this method adds a correction value that seems to work * well with the vast majority of desktops.<p> * * TODO: Revise the computation of vertical base units as soon as * there are more information about the original computation * in Microsoft environments. * * @param metrics the FontMetrics used to measure the dialog font * @return the horizontal and vertical dialog base units */ private DialogBaseUnits computeDialogBaseUnits(FontMetrics metrics) { double averageCharWidth = computeAverageCharWidth(metrics, averageCharWidthTestString); int ascent = metrics.getAscent(); double height = ascent > 14 ? ascent : ascent + (15 - ascent) / 3; DialogBaseUnits dialogBaseUnits = new DialogBaseUnits(averageCharWidth, height); LOGGER.config( "Computed dialog base units " + dialogBaseUnits + " for: " + metrics.getFont()); return dialogBaseUnits; }
/** * Computes and returns the horizontal dialog base units. Honors the font, * font size and resolution. * <p> * * Implementation Note: 14dluY map to 22 pixel for 8pt Tahoma on 96 dpi. I * could not yet manage to compute the Microsoft compliant font height. * Therefore this method adds a correction value that seems to work well * with the vast majority of desktops. * <p> * * TODO: revise the computation of vertical base untis, as soon as there are * more information about the original computation in Microsoft * environments. * * @param metrics * the FontMetrics used to measure the dialog font * @return the horizontal and vertical dialog base units */ private DialogBaseUnits computeDialogBaseUnits(FontMetrics metrics) { double averageCharWidth = computeAverageCharWidth(metrics, averageCharWidthTestString); int ascent = metrics.getAscent(); double height = ascent > 14 ? ascent : ascent + (15 - ascent) / 3; DialogBaseUnits dialogBaseUnits = new DialogBaseUnits(averageCharWidth, height); logInfo("Computed dialog base units " + dialogBaseUnits + " for: " + metrics.getFont()); return dialogBaseUnits; }