Merge from the pain train
[official-gcc.git] / libjava / gnu / java / awt / peer / gtk / GtkFontPeer.java
blobe0f070368c52c009eddf892099ff79c7bf376d1a
1 /* GtkFontPeer.java -- Implements FontPeer with GTK+
2 Copyright (C) 1999, 2004, 2005 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING. If not, write to the
18 Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library. Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module. An independent module is a module which is not derived from
33 or based on this library. If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so. If you do not wish to do so, delete this
36 exception statement from your version. */
39 package gnu.java.awt.peer.gtk;
41 import gnu.java.awt.peer.ClasspathFontPeer;
43 import java.awt.Font;
44 import java.awt.FontMetrics;
45 import java.awt.font.FontRenderContext;
46 import java.awt.font.GlyphVector;
47 import java.awt.font.LineMetrics;
48 import java.awt.geom.Rectangle2D;
49 import java.text.CharacterIterator;
50 import java.util.Locale;
51 import java.util.MissingResourceException;
52 import java.util.ResourceBundle;
54 public class GtkFontPeer extends ClasspathFontPeer
56 private static ResourceBundle bundle;
58 static
60 try
62 bundle = ResourceBundle.getBundle ("gnu.java.awt.peer.gtk.font");
64 catch (Throwable ignored)
66 bundle = null;
70 private final String Xname;
72 public GtkFontPeer (String name, int style)
74 // All fonts get a default size of 12 if size is not specified.
75 this(name, style, 12);
78 public GtkFontPeer (String name, int style, int size)
80 super(name, style, size);
82 String Xname = null;
83 if (bundle != null)
85 try
87 Xname = bundle.getString (name.toLowerCase () + "." + style);
89 catch (MissingResourceException mre)
91 // ignored
95 if (Xname == null)
97 String weight;
98 String slant;
99 String spacing;
101 if (style == Font.ITALIC || (style == (Font.BOLD+Font.ITALIC)))
102 slant = "i";
103 else
104 slant = "r";
105 if (style == Font.BOLD || (style == (Font.BOLD+Font.ITALIC)))
106 weight = "bold";
107 else
108 weight = "medium";
109 if (name.equals("Serif") || name.equals("SansSerif")
110 || name.equals("Helvetica") || name.equals("Times"))
111 spacing = "p";
112 else
113 spacing = "c";
115 Xname = "-*-*-" + weight + "-" + slant + "-normal-*-*-" + size + "-*-*-" + spacing + "-*-*-*";
118 this.Xname = Xname;
121 public String getXLFD ()
123 return Xname;
127 /* remaining methods are for static compatibility with the newer
128 ClasspathFontPeer superclass; none of these methods ever existed or
129 worked on the older FontPeer interface, but we need to pretend to
130 support them anyways. */
132 public boolean canDisplay (Font font, char c)
134 throw new UnsupportedOperationException();
137 public int canDisplayUpTo (Font font, CharacterIterator i, int start, int limit)
139 throw new UnsupportedOperationException();
142 public String getSubFamilyName (Font font, Locale locale)
144 throw new UnsupportedOperationException();
147 public String getPostScriptName (Font font)
149 throw new UnsupportedOperationException();
152 public int getNumGlyphs (Font font)
154 throw new UnsupportedOperationException();
157 public int getMissingGlyphCode (Font font)
159 throw new UnsupportedOperationException();
162 public byte getBaselineFor (Font font, char c)
164 throw new UnsupportedOperationException();
167 public String getGlyphName (Font font, int glyphIndex)
169 throw new UnsupportedOperationException();
172 public GlyphVector createGlyphVector (Font font,
173 FontRenderContext frc,
174 CharacterIterator ci)
176 throw new UnsupportedOperationException();
179 public GlyphVector createGlyphVector (Font font,
180 FontRenderContext ctx,
181 int[] glyphCodes)
183 throw new UnsupportedOperationException();
186 public GlyphVector layoutGlyphVector (Font font,
187 FontRenderContext frc,
188 char[] chars, int start,
189 int limit, int flags)
191 throw new UnsupportedOperationException();
194 public FontMetrics getFontMetrics (Font font)
196 throw new UnsupportedOperationException();
199 public boolean hasUniformLineMetrics (Font font)
201 throw new UnsupportedOperationException();
204 public LineMetrics getLineMetrics (Font font,
205 CharacterIterator ci,
206 int begin, int limit,
207 FontRenderContext rc)
209 throw new UnsupportedOperationException();
212 public Rectangle2D getMaxCharBounds (Font font,
213 FontRenderContext rc)
215 throw new UnsupportedOperationException();
218 public Rectangle2D getStringBounds (Font font,
219 CharacterIterator ci,
220 int begin, int limit,
221 FontRenderContext frc)
223 throw new UnsupportedOperationException();