diff options
Diffstat (limited to 'Master/Reference Architectures and Patterns/hjp5/examples/Fontmetriken.inc')
| -rw-r--r-- | Master/Reference Architectures and Patterns/hjp5/examples/Fontmetriken.inc | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Master/Reference Architectures and Patterns/hjp5/examples/Fontmetriken.inc b/Master/Reference Architectures and Patterns/hjp5/examples/Fontmetriken.inc new file mode 100644 index 0000000..708333a --- /dev/null +++ b/Master/Reference Architectures and Patterns/hjp5/examples/Fontmetriken.inc @@ -0,0 +1,33 @@ +/* Fontmetriken.inc */
+
+public void paint(Graphics g)
+{
+ Font font = new Font("TimesRoman",Font.PLAIN,72);
+
+ //---Linien
+ g.setColor(Color.blue);
+ for (int x = 10; x <= 260; x += 10) {
+ g.drawLine(x,30,x,130);
+ }
+ for (int y = 30; y <= 130; y += 10) {
+ g.drawLine(10,y,260,y);
+ }
+ //---Schrift
+ g.setColor(Color.black);
+ g.drawLine(0,100,270,100);
+ g.setFont(font);
+ g.drawString("mgdAW",10,100);
+ //---Font-Metriken
+ FontMetrics fm = getFontMetrics(font);
+ System.out.println("Oberlänge = " + fm.getAscent());
+ System.out.println("Unterlänge = " + fm.getDescent());
+ System.out.println("Höhe = " + fm.getHeight());
+ System.out.println("Zeilenabstand = " + fm.getLeading());
+ System.out.println("---");
+ System.out.println("Breite(m) = " + fm.charWidth('m'));
+ System.out.println("Breite(g) = " + fm.charWidth('g'));
+ System.out.println("Breite(d) = " + fm.charWidth('d'));
+ System.out.println("Breite(A) = " + fm.charWidth('A'));
+ System.out.println("Breite(W) = " + fm.charWidth('W'));
+ System.out.println("---");
+}
\ No newline at end of file |
