001package org.vishia.gral.ifc; 002 003import java.util.Map; 004import java.util.TreeMap; 005 006public final class GralFont 007{ 008 /**Version, history and license. 009 * <ul> 010 * <li>2011-06-00 Hartmut created 011 * </ul> 012 * 013 * <b>Copyright/Copyleft</b>:<br> 014 * For this source the LGPL Lesser General Public License, 015 * published by the Free Software Foundation is valid. 016 * It means: 017 * <ol> 018 * <li> You can use this source without any restriction for any desired purpose. 019 * <li> You can redistribute copies of this source to everybody. 020 * <li> Every user of this source, also the user of redistribute copies 021 * with or without payment, must accept this license for further using. 022 * <li> But the LPGL is not appropriate for a whole software product, 023 * if this source is only a part of them. It means, the user 024 * must publish this part of source, 025 * but doesn't need to publish the whole source of the own product. 026 * <li> You can study and modify (improve) this source 027 * for own using or for redistribution, but you have to license the 028 * modified sources likewise under this LGPL Lesser General Public License. 029 * You mustn't delete this Copyright/Copyleft inscription in this source file. 030 * </ol> 031 * If you intent to use this source without publishing its usage, you can get 032 * a second license subscribing a special contract with the author. 033 * 034 * @author Hartmut Schorrig = hartmut.schorrig@vishia.de 035 */ 036 public static final int version = 20120303; 037 038 /**The font-instance for the implementation can be set from the implementation with the necessary type 039 * to minimize the effort in dynamic instances. */ 040 public Object fontImpl; 041 042 public static final String fontMonospacedSansSerif = "monospacedSansSerif"; 043 044 public static final String fontMonospacedSmall = "MonospacedSmall"; 045 046 public static final String fontMonospacedSerif = "monospacedSerif"; 047 048 public static final String fontSansSerif = "sansSerif"; 049 050 public static final String fontSerif = "serif"; 051 052 /**Some types of fonts.*/ 053 public static final char typeSmallMonospaced = 'm', typeMonospaced = 'M', 054 typeSansSerif = 'a', typeSerif = 't'; 055 056 public static final char styleNormal = 'n', styleItalic = 'i', styleBoldItalic = 'I', styleBold = 'b'; 057 058 public String fontName; 059 060 /**The size of the font in points.*/ 061 public int size; 062 063 /**The style of the font. 064 * <ul> 065 * <li>b bold 066 * <li>i italic 067 * <li> 068 * </ul> 069 */ 070 public char style; 071 072 073 private static Map<String, GralFont> fonts = new TreeMap<String, GralFont>(); 074 075 public GralFont(String fontName, int size, char style) 076 { this.fontName = fontName; 077 this.size = size; 078 this.style = style; 079 } 080 081 082 083 /**Not yet ready. Therefore protected yet. 084 * @param fontName 085 * @param size Use the grid size! 086 * @param style 087 * @return 088 */ 089 protected static GralFont getFont(String fontName, int size, char style){ 090 String key = fontName + "." + style + size; 091 GralFont ret = fonts.get(key); 092 if(ret == null){ 093 ret = new GralFont(fontName, size, style); 094 fonts.put(key, ret); 095 } 096 return ret; 097 } 098 099 100}