1 package org.apache.maven.doxia.module.rtf;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 class FontMetrics
26 {
27 boolean fixedPitch;
28
29 short ascent;
30
31 short descent;
32
33 CharMetrics bounds;
34
35 CharMetrics[] charMetrics;
36
37 FontMetrics( boolean fixedPitch, int ascent, int descent, CharMetrics bounds, CharMetrics[] metrics )
38 {
39 this.fixedPitch = fixedPitch;
40 this.ascent = (short) ascent;
41 this.descent = (short) descent;
42 this.bounds = bounds;
43 this.charMetrics = metrics;
44 }
45
46 static FontMetrics find( int style )
47 throws Exception
48 {
49 String s = FontMetrics.class.getName();
50 String packageName = s.substring( 0, s.lastIndexOf( '.' ) );
51
52 StringBuffer buf = new StringBuffer( packageName + "." );
53
54 switch ( style )
55 {
56 case RtfSink.STYLE_ROMAN:
57 default:
58 buf.append( "Serif" );
59 break;
60 case RtfSink.STYLE_ITALIC:
61 buf.append( "SerifItalic" );
62 break;
63 case RtfSink.STYLE_BOLD:
64 buf.append( "SerifBold" );
65 break;
66 case RtfSink.STYLE_TYPEWRITER:
67 buf.append( "Monospace" );
68 break;
69 }
70
71 String className = buf.toString();
72 Class<?> classObject = Class.forName( className );
73 return (FontMetrics) classObject.newInstance();
74 }
75
76 static class CharMetrics
77 {
78
79 short wx;
80
81 short wy;
82
83 short llx;
84
85 short lly;
86
87 short urx;
88
89 short ury;
90
91 CharMetrics( int wx, int wy, int llx, int lly, int urx, int ury )
92 {
93 this.wx = (short) wx;
94 this.wy = (short) wy;
95 this.llx = (short) llx;
96 this.lly = (short) lly;
97 this.urx = (short) urx;
98 this.ury = (short) ury;
99 }
100
101 }
102 }