diff options
author | Glen Stampoultzis <glens@apache.org> | 2004-04-09 11:45:38 +0000 |
---|---|---|
committer | Glen Stampoultzis <glens@apache.org> | 2004-04-09 11:45:38 +0000 |
commit | b6ea214cc1e42332b7198954c63a783935b4bdf4 (patch) | |
tree | 9ffdd5aea352c9c258ed2df5fa1a4deb4d63792e /src/contrib | |
parent | 0873a633af2dc09fd9eab9ee1b2d5835e0d7fc2d (diff) | |
download | poi-b6ea214cc1e42332b7198954c63a783935b4bdf4.tar.gz poi-b6ea214cc1e42332b7198954c63a783935b4bdf4.zip |
Ported the drawing stuff from the rel_2_branch. Given the effort this took I'm really really wanting to move to subversion.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@353542 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/contrib')
-rw-r--r-- | src/contrib/src/org/apache/poi/contrib/metrics/FontMetricsDumper.java | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/contrib/src/org/apache/poi/contrib/metrics/FontMetricsDumper.java b/src/contrib/src/org/apache/poi/contrib/metrics/FontMetricsDumper.java new file mode 100644 index 0000000000..2a02ae9fbf --- /dev/null +++ b/src/contrib/src/org/apache/poi/contrib/metrics/FontMetricsDumper.java @@ -0,0 +1,65 @@ +package org.apache.poi.contrib.metrics; + +import java.awt.*; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Properties; + +public class FontMetricsDumper +{ + public static void main( String[] args ) throws IOException + { + + Properties props = new Properties(); + + Font[] allFonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts(); + for ( int i = 0; i < allFonts.length; i++ ) + { + String fontName = allFonts[i].getFontName(); + + Font font = new Font(fontName, Font.BOLD, 10); + FontMetrics fontMetrics = Toolkit.getDefaultToolkit().getFontMetrics(font); + int fontHeight = fontMetrics.getHeight(); + + props.setProperty("font." + fontName + ".height", fontHeight+""); + StringBuffer characters = new StringBuffer(); + for (char c = 'a'; c <= 'z'; c++) + { + characters.append( c + ", " ); + } + for (char c = 'A'; c <= 'Z'; c++) + { + characters.append( c + ", " ); + } + for (char c = '0'; c <= '9'; c++) + { + characters.append( c + ", " ); + } + StringBuffer widths = new StringBuffer(); + for (char c = 'a'; c <= 'z'; c++) + { + widths.append( fontMetrics.getWidths()[c] + ", " ); + } + for (char c = 'A'; c <= 'Z'; c++) + { + widths.append( fontMetrics.getWidths()[c] + ", " ); + } + for (char c = '0'; c <= '9'; c++) + { + widths.append( fontMetrics.getWidths()[c] + ", " ); + } + props.setProperty("font." + fontName + ".characters", characters.toString()); + props.setProperty("font." + fontName + ".widths", widths.toString()); + } + + FileOutputStream fileOut = new FileOutputStream("font_metrics.properties"); + try + { + props.store(fileOut, "Font Metrics"); + } + finally + { + fileOut.close(); + } + } +} |