You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Font.java 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.ss.usermodel;
  16. import org.apache.poi.util.Removal;
  17. public interface Font {
  18. // TODO: refactor and unify Font & FontFormatting in POI 5.0.0
  19. // TODO: refactor the constants to enums in POI 5.0.0
  20. /**
  21. * normal type of black color.
  22. */
  23. short COLOR_NORMAL = 0x7fff;
  24. /**
  25. * Dark Red color
  26. */
  27. short COLOR_RED = 0xa;
  28. /**
  29. * no type offsetting (not super or subscript)
  30. */
  31. short SS_NONE = 0;
  32. /**
  33. * superscript
  34. */
  35. short SS_SUPER = 1;
  36. /**
  37. * subscript
  38. */
  39. short SS_SUB = 2;
  40. /**
  41. * not underlined
  42. */
  43. byte U_NONE = 0;
  44. /**
  45. * single (normal) underline
  46. */
  47. byte U_SINGLE = 1;
  48. /**
  49. * double underlined
  50. */
  51. byte U_DOUBLE = 2;
  52. /**
  53. * accounting style single underline
  54. */
  55. byte U_SINGLE_ACCOUNTING = 0x21;
  56. /**
  57. * accounting style double underline
  58. */
  59. byte U_DOUBLE_ACCOUNTING = 0x22;
  60. /**
  61. * ANSI character set
  62. */
  63. byte ANSI_CHARSET = 0;
  64. /**
  65. * Default character set.
  66. */
  67. byte DEFAULT_CHARSET = 1;
  68. /**
  69. * Symbol character set
  70. */
  71. byte SYMBOL_CHARSET = 2;
  72. /**
  73. * Font height is handled in points and 1/20th of points so
  74. * this is the constant used to convert between those two units.
  75. */
  76. int TWIPS_PER_POINT = 20;
  77. /**
  78. * set the name for the font (i.e. Arial)
  79. * @param name String representing the name of the font to use
  80. */
  81. void setFontName(String name);
  82. /**
  83. * get the name for the font (i.e. Arial)
  84. * @return String representing the name of the font to use
  85. */
  86. String getFontName();
  87. /**
  88. * set the font height in unit's of 1/20th of a point. Maybe you might want to
  89. * use the setFontHeightInPoints which matches to the familiar 10, 12, 14 etc..
  90. * @param height height in 1/20ths of a point
  91. * @see #setFontHeightInPoints(short)
  92. */
  93. void setFontHeight(short height);
  94. /**
  95. * set the font height
  96. * @param height height in the familiar unit of measure - points
  97. * @see #setFontHeight(short)
  98. */
  99. void setFontHeightInPoints(short height);
  100. /**
  101. * Get the font height in unit's of 1/20th of a point.
  102. * <p>
  103. * For many users, the related {@link #getFontHeightInPoints()}
  104. * will be more helpful, as that returns font heights in the
  105. * more familiar points units, eg 10, 12, 14.
  106. * @return short - height in 1/20ths of a point
  107. * @see #getFontHeightInPoints()
  108. */
  109. short getFontHeight();
  110. /**
  111. * Get the font height in points.
  112. * <p>
  113. * This will return the same font height that is shown in Excel,
  114. * such as 10 or 14 or 28.
  115. * @return short - height in the familiar unit of measure - points
  116. * @see #getFontHeight()
  117. */
  118. short getFontHeightInPoints();
  119. /**
  120. * set whether to use italics or not
  121. * @param italic italics or not
  122. */
  123. void setItalic(boolean italic);
  124. /**
  125. * get whether to use italics or not
  126. * @return italics or not
  127. */
  128. boolean getItalic();
  129. /**
  130. * set whether to use a strikeout horizontal line through the text or not
  131. * @param strikeout or not
  132. */
  133. void setStrikeout(boolean strikeout);
  134. /**
  135. * get whether to use a strikeout horizontal line through the text or not
  136. * @return strikeout or not
  137. */
  138. boolean getStrikeout();
  139. /**
  140. * set the color for the font
  141. * @param color to use
  142. * @see #COLOR_NORMAL Note: Use this rather than HSSFColor.AUTOMATIC for default font color
  143. * @see #COLOR_RED
  144. */
  145. void setColor(short color);
  146. /**
  147. * get the color for the font
  148. * @return color to use
  149. * @see #COLOR_NORMAL
  150. * @see #COLOR_RED
  151. * @see org.apache.poi.hssf.usermodel.HSSFPalette#getColor(short)
  152. */
  153. short getColor();
  154. /**
  155. * set normal,super or subscript.
  156. * @param offset type to use (none,super,sub)
  157. * @see #SS_NONE
  158. * @see #SS_SUPER
  159. * @see #SS_SUB
  160. */
  161. void setTypeOffset(short offset);
  162. /**
  163. * get normal,super or subscript.
  164. * @return offset type to use (none,super,sub)
  165. * @see #SS_NONE
  166. * @see #SS_SUPER
  167. * @see #SS_SUB
  168. */
  169. short getTypeOffset();
  170. /**
  171. * set type of text underlining to use
  172. * @param underline type
  173. * @see #U_NONE
  174. * @see #U_SINGLE
  175. * @see #U_DOUBLE
  176. * @see #U_SINGLE_ACCOUNTING
  177. * @see #U_DOUBLE_ACCOUNTING
  178. */
  179. void setUnderline(byte underline);
  180. /**
  181. * get type of text underlining to use
  182. * @return underlining type
  183. * @see #U_NONE
  184. * @see #U_SINGLE
  185. * @see #U_DOUBLE
  186. * @see #U_SINGLE_ACCOUNTING
  187. * @see #U_DOUBLE_ACCOUNTING
  188. */
  189. byte getUnderline();
  190. /**
  191. * get character-set to use.
  192. * @return character-set
  193. * @see #ANSI_CHARSET
  194. * @see #DEFAULT_CHARSET
  195. * @see #SYMBOL_CHARSET
  196. */
  197. int getCharSet();
  198. /**
  199. * set character-set to use.
  200. * @see #ANSI_CHARSET
  201. * @see #DEFAULT_CHARSET
  202. * @see #SYMBOL_CHARSET
  203. */
  204. void setCharSet(byte charset);
  205. /**
  206. * set character-set to use.
  207. * @see #ANSI_CHARSET
  208. * @see #DEFAULT_CHARSET
  209. * @see #SYMBOL_CHARSET
  210. */
  211. void setCharSet(int charset);
  212. /**
  213. * get the index within the XSSFWorkbook (sequence within the collection of Font objects)
  214. *
  215. * @return unique index number of the underlying record this Font represents (probably you don't care
  216. * unless you're comparing which one is which)
  217. * @since 5.0.0 (used to return a short)
  218. */
  219. int getIndex();
  220. /**
  221. * get the index within the XSSFWorkbook (sequence within the collection of Font objects)
  222. *
  223. * @deprecated use {@link #getIndex()} instead
  224. * @return unique index number of the underlying record this Font represents (probably you don't care
  225. * unless you're comparing which one is which)
  226. * @since 4.0.0
  227. */
  228. @Deprecated
  229. @Removal(version = "6.0.0")
  230. int getIndexAsInt();
  231. void setBold(boolean bold);
  232. boolean getBold();
  233. }