summaryrefslogtreecommitdiffstats
path: root/Master/Reference Architectures and Patterns/hjp5/examples/Fontmetriken.inc
blob: 708333af6bb75e095f3d5a70180aae9ac2410484 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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("---");
}