1 29 30 package com.caucho.quercus.lib.pdf; 31 32 35 public class Font { 36 private String _fontName; 37 private String _weight; 38 39 private double _llxBBox; 40 private double _llyBBox; 41 private double _urxBBox; 42 private double _uryBBox; 43 44 private double _capHeight; 45 private double _xHeight; 46 private double _ascender; 47 private double _descender; 48 49 private double _underlinePosition; 50 private double _underlineThickness; 51 private double _italicAngle; 52 53 private FontChar []_chars = new FontChar[256]; 54 55 public String getFontName() 56 { 57 return _fontName; 58 } 59 60 void setFontName(String name) 61 { 62 _fontName = name; 63 } 64 65 public String getWeight() 66 { 67 return _weight; 68 } 69 70 void setWeight(String weight) 71 { 72 _weight = weight; 73 } 74 75 void setBBox(double llx, double lly, double urx, double ury) 76 { 77 _llxBBox = llx; 78 _llyBBox = lly; 79 _urxBBox = urx; 80 _uryBBox = ury; 81 } 82 83 public double getCapHeight() 84 { 85 return _capHeight; 86 } 87 88 void setCapHeight(double height) 89 { 90 _capHeight = height; 91 } 92 93 public double getXHeight() 94 { 95 return _xHeight; 96 } 97 98 void setXHeight(double height) 99 { 100 _xHeight = height; 101 } 102 103 public double getAscender() 104 { 105 return _ascender; 106 } 107 108 void setAscender(double ascender) 109 { 110 _ascender = ascender; 111 } 112 113 public double getDescender() 114 { 115 return _descender; 116 } 117 118 void setDescender(double descender) 119 { 120 _descender = descender; 121 } 122 123 public double getUnderlinePosition() 124 { 125 return _underlinePosition; 126 } 127 128 void setUnderlinePosition(double underlinePosition) 129 { 130 _underlinePosition = underlinePosition; 131 } 132 133 public double getUnderlineThickness() 134 { 135 return _underlineThickness; 136 } 137 138 void setUnderlineThickness(double underlineThickness) 139 { 140 _underlineThickness = underlineThickness; 141 } 142 143 public double getItalicAngle() 144 { 145 return _italicAngle; 146 } 147 148 void setItalicAngle(double italicAngle) 149 { 150 _italicAngle = italicAngle; 151 } 152 153 void addChar(FontChar fontChar) 154 { 155 int code = fontChar.getCode(); 156 157 if (code >= 0 && code < _chars.length) 158 _chars[code] = fontChar; 159 } 160 161 public double stringWidth(String text) 162 { 163 double width = 0; 164 165 int len = text.length(); 166 char prevChar = 0; 167 168 for (int i = 0; i < len; i++) { 169 char ch = text.charAt(i); 170 171 if (ch >= 256) 172 continue; 173 174 FontChar fontChar = _chars[ch]; 175 176 if (fontChar == null) 177 continue; 178 179 width += fontChar.getWidth(); 180 181 183 prevChar = ch; 184 } 185 186 return width; 187 } 188 } 189 | Popular Tags |