1:
37:
38: package ;
39:
40: import ;
41: import ;
42: import ;
43: import ;
44: import ;
45: import ;
46: import ;
47: import ;
48: import ;
49: import ;
50:
51: import ;
52:
53: public class QtFontPeer extends ClasspathFontPeer
54: {
55:
56: private long nativeObject;
57: private QtFontMetrics metrics;
58:
59:
60: public QtFontPeer (String name, int style)
61: {
62: this(name, style, 12);
63: }
64:
65: public QtFontPeer (String name, int style, int size)
66: {
67: super(name, style, size);
68: init();
69: }
70:
71: public QtFontPeer (String name, Map attributes)
72: {
73: super(name, attributes);
74: init();
75: }
76:
77: public void init()
78: {
79: if(this.familyName == null)
80: throw new IllegalArgumentException("null family name");
81: if(this.familyName.equals("Helvetica"))
82: this.familyName = "sans serif";
83: if(this.familyName.equals("Dialog"))
84: this.familyName = "sans serif";
85: create(this.familyName, this.style, (int)this.size);
86: metrics = new QtFontMetrics(this);
87: }
88:
89:
92: private native void create(String name, int style, int size);
93:
94:
97: public native void dispose();
98:
99:
100:
101:
102: public boolean canDisplay (Font font, char c)
103: {
104: return metrics.canDisplay( c );
105: }
106:
107: public int canDisplayUpTo (Font font, CharacterIterator i,
108: int start, int limit)
109: {
110: int index = start;
111: char c = i.setIndex( index );
112: while( index <= limit )
113: {
114: if(!canDisplay(font, c))
115: return index;
116: index++;
117: c = i.next();
118: }
119: return -1;
120: }
121:
122: public String getSubFamilyName (Font font, Locale locale)
123: {
124: throw new UnsupportedOperationException();
125: }
126:
127: public String getPostScriptName (Font font)
128: {
129: throw new UnsupportedOperationException();
130: }
131:
132: public int getNumGlyphs (Font font)
133: {
134: throw new UnsupportedOperationException();
135: }
136:
137: public int getMissingGlyphCode (Font font)
138: {
139: throw new UnsupportedOperationException();
140: }
141:
142: public byte getBaselineFor (Font font, char c)
143: {
144: throw new UnsupportedOperationException();
145: }
146:
147: public String getGlyphName (Font font, int glyphIndex)
148: {
149: throw new UnsupportedOperationException();
150: }
151:
152: public GlyphVector createGlyphVector (Font font,
153: FontRenderContext frc,
154: CharacterIterator ci)
155: {
156: throw new UnsupportedOperationException();
157: }
158:
159: public GlyphVector createGlyphVector (Font font,
160: FontRenderContext ctx,
161: int[] glyphCodes)
162: {
163: throw new UnsupportedOperationException();
164: }
165:
166: public GlyphVector layoutGlyphVector (Font font,
167: FontRenderContext frc,
168: char[] chars, int start,
169: int limit, int flags)
170: {
171: throw new UnsupportedOperationException();
172: }
173:
174: public FontMetrics getFontMetrics (Font font)
175: {
176: return new QtFontMetrics( this );
177: }
178:
179: public boolean hasUniformLineMetrics (Font font)
180: {
181: throw new UnsupportedOperationException();
182: }
183:
184: public LineMetrics getLineMetrics (Font font,
185: CharacterIterator ci,
186: int begin, int limit,
187: FontRenderContext rc)
188: {
189: throw new UnsupportedOperationException();
190: }
191:
192: public Rectangle2D getMaxCharBounds (Font font,
193: FontRenderContext rc)
194: {
195: throw new UnsupportedOperationException();
196: }
197:
198: public Rectangle2D getStringBounds (Font font,
199: CharacterIterator ci,
200: int begin, int limit,
201: FontRenderContext frc)
202: {
203: int index = begin;
204: String s = "" + ci.setIndex( index );
205: while( index++ <= limit )
206: s = s + ci.next();
207: return metrics.getStringBounds(s);
208: }
209: }