[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] gzz/gzz/util ScalableFont.java
From: |
Asko Soukka |
Subject: |
[Gzz-commits] gzz/gzz/util ScalableFont.java |
Date: |
Thu, 21 Nov 2002 08:15:05 -0500 |
CVSROOT: /cvsroot/gzz
Module name: gzz
Changes by: Asko Soukka <address@hidden> 02/11/21 08:15:05
Modified files:
gzz/util : ScalableFont.java
Log message:
Dummy implementation for getScaleByHeight.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gzz/gzz/gzz/util/ScalableFont.java.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
Patches:
Index: gzz/gzz/util/ScalableFont.java
diff -u gzz/gzz/util/ScalableFont.java:1.2 gzz/gzz/util/ScalableFont.java:1.3
--- gzz/gzz/util/ScalableFont.java:1.2 Tue Nov 12 03:53:11 2002
+++ gzz/gzz/util/ScalableFont.java Thu Nov 21 08:15:05 2002
@@ -32,7 +32,7 @@
*/
public final class ScalableFont {
- public static final String rcsid = "$Id: ScalableFont.java,v 1.2
2002/11/12 08:53:11 humppake Exp $";
+ public static final String rcsid = "$Id: ScalableFont.java,v 1.3
2002/11/21 13:15:05 humppake Exp $";
public static boolean dbg=false;
private static final void p(String s) { if(dbg) System.out.println(s); }
@@ -151,10 +151,15 @@
/** Get the scale for the point size which is nearest the given height.
* XXX does not work
*/
- public int getScale(float height) {
+ public float getScale(float height) {
+ double start = 1;
+ while (getFontMetrics((float)start).getHeight() < height) start += 1;
+
+ for (double scale = start; scale > start -1; scale -= 0.01)
+ if (getFontMetrics((float)scale).getHeight() <= height)
+ return (float)(scale);
return 1;
}
-
}