aboutsummaryrefslogtreecommitdiff
path: root/libjava/java/awt/FontMetrics.java
blob: 560481d482d3230cffe51f6d07f4c554de0cca0d (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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/* Copyright (C) 2000  Free Software Foundation

   This file is part of libgcj.

This software is copyrighted work licensed under the terms of the
Libgcj License.  Please consult the file "LIBGCJ_LICENSE" for
details.  */

package java.awt;

/**
 * Status:  Stubbed; A very incomplete implementation.
 */

public class FontMetrics implements java.io.Serializable
{
  protected Font font;
  
  protected FontMetrics(Font font)
  {
    this.font = font;
  }

  public Font getFont()
  {
    return font;
  }

  public int getLeading()
  {
    // FIXME??
    return getHeight() - (getDescent() + getAscent());
  }

  public int getAscent()
  {
    // FIXME??
    return getHeight() - (getDescent() + getLeading());
  }

  public int getDescent()
  {
    // FIXME??
    return getHeight() - getDescent();
  }

  public int getHeight()
  {
    // FIXME??
    return getLeading() + getAscent() + getDescent();
  }

  public int getMaxAscent()
  {
    // FIXME
    return 0;
  }

  public int getMaxDescent()
  {
    // FIXME
    return 0;
  }

  /* @deprecated Use getMaxDescent() instead. */
  public int getMaxDecent()
  {
    return getMaxDescent();
  }

  public int getMaxAdvance()
  {
    // FIXME
    return 0;
  }

  public int charWidth(int ch)
  {
    // FIXME
    return 0;
  }

  public int charWidth(char ch)
  {
    // FIXME
    return 0;
  }

  public int stringWidth(String str)
  {
    return charsWidth(str.toCharArray(), 0, str.length());
  }

  public int charsWidth(char[] data, int off, int len)
  {
    // FIXME
    return -1;
  }

  public int bytesWidth(byte[] data, int off, int len)
  {
    // FIXME?
    return -1;
  }

  public int[] getWidths()
  {
    // FIXME
    return new int[0];
  }

  public boolean hasUniformLineMetrics()
  {
    // FIXME
    return false;
  }

  // Don't have LineMetrics yet...
  /*
  public LineMetrics getLineMetrics(String str, Graphics context)

  public LineMetrics getLineMetrics(String str, int beginIndex, int limit,
                                    Graphics context)

  public LineMetrics getLineMetrics(char[] chars, int beginIndex, int limit,
                                    Graphics context)

  public LineMetrics getLineMetrics(CharacterIterator ci, int beginIndex,
				    int limit, Graphics context)
  */

  // Don't have Java2D yet.
  /*
  public Rectangle2D getStringBounds(String str, Graphics context)

  public Rectangle2D getStringBounds(String str, int beginIndex, int limit,
                                     Graphics context)

  public Rectangle2D getStringBounds(char[] chars, int beginIndex, int limit,
                                     Graphics context)

  public Rectangle2D getStringBounds(CharacterIterator ci, int beginIndex,
                                     int limit, Graphics context)

  public Rectangle2D getMaxCharBounds(Graphics context)
  */

  public String toString()
  {
    return this.getClass() + "[font=" + font + ",ascent=" + getAscent() 
	   + ",descent=" + getDescent() + ",height=" + getHeight() + "]";
  }
}