1 16 17 package org.apache.poi.hssf.usermodel; 18 19 import junit.framework.TestCase; 20 21 import java.util.Properties ; 22 23 28 public class TestFontDetails extends TestCase 29 { 30 private Properties properties; 31 private FontDetails fontDetails; 32 33 protected void setUp() throws Exception 34 { 35 properties = new Properties (); 36 properties.setProperty("font.Arial.height", "13"); 37 properties.setProperty("font.Arial.characters", "a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, "); 38 properties.setProperty("font.Arial.widths", "6, 6, 6, 6, 6, 3, 6, 6, 3, 4, 6, 3, 9, 6, 6, 6, 6, 4, 6, 3, 6, 7, 9, 6, 5, 5, 7, 7, 7, 7, 7, 6, 8, 7, 3, 6, 7, 6, 9, 7, 8, 7, 8, 7, 7, 5, 7, 7, 9, 7, 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, "); 39 fontDetails = FontDetails.create("Arial", properties); 40 41 } 42 43 public void testCreate() throws Exception 44 { 45 assertEquals(13, fontDetails.getHeight()); 46 assertEquals(6, fontDetails.getCharWidth('a')); 47 assertEquals(3, fontDetails.getCharWidth('f')); 48 } 49 50 public void testGetStringWidth() throws Exception 51 { 52 assertEquals(9, fontDetails.getStringWidth("af")); 53 } 54 55 public void testGetCharWidth() throws Exception 56 { 57 assertEquals(6, fontDetails.getCharWidth('a')); 58 assertEquals(9, fontDetails.getCharWidth('=')); 59 } 60 61 } 62 | Popular Tags |