From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- .../hjp5/examples/Fontmetriken.inc | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Master/Reference Architectures and Patterns/hjp5/examples/Fontmetriken.inc (limited to 'Master/Reference Architectures and Patterns/hjp5/examples/Fontmetriken.inc') 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 -- cgit v1.2.3