Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Mar 5th, 2012  |  syntax: Groovy  |  size: 1.16 KB  |  hits: 65  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /**
  2.  * Web safe fonts
  3.  */
  4. public enum Font {
  5.   ARIAL("Arial","Arial, Helvetica, sans-serif"),
  6.   ARIAL_BLACK("Arial Black","Arial Black, Gadget, sans-serif"),
  7.   COMIC_SANS_MS("Comic","\"Comic Sans MS\", cursive, sans-serif"),
  8.   COURIER_NEW("Courier", "\"Courier New\", Courier, monospace"),
  9.   GEORGIA("Georgia", "Georgia, serif"),
  10.   IMPACT("Impact", "Impact, Charcoal, sans-serif"),
  11.   TIMES_NEW_ROMAN("Times", "\"Times New Roman\", Times, serif"),
  12.   TREBUCHET_MS("Trebuchet", "\"Trebuchet MS\", Helvetica, sans-serif"),
  13.   VERDANA("Verdana", "Verdana, Geneva, sans-serif");
  14.  
  15.   private final String label, css;
  16.  
  17.   Font( String label, String css ){
  18.       this.label = label;
  19.       this.css = css;
  20.   }
  21.    
  22.   public Font( String name ){
  23.       Font font = Font.valueOf( name );
  24.       this.label = font.label;
  25.       this.css = font.css;
  26.   }
  27.  
  28.   public String getLabel(){
  29.       return label;
  30.   }
  31.  
  32.   public String getCss(){
  33.       return css;
  34.   }
  35.  
  36.   public String getKey(){
  37.       return name();
  38.   }
  39.  
  40.   public String toString(){
  41.       return name();
  42.   }
  43.  
  44.   public static get(int id) {
  45.     def items = Font.values();
  46.     return items[id].name();
  47.   }
  48. }