Home | History | Annotate | Download | only in font
      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  *
      9  *     http://www.apache.org/licenses/LICENSE-2.0
     10  *
     11  *  Unless required by applicable law or agreed to in writing, software
     12  *  distributed under the License is distributed on an "AS IS" BASIS,
     13  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     14  *  See the License for the specific language governing permissions and
     15  *  limitations under the License.
     16  */
     17 /**
     18  * @author Ilya S. Okomin
     19  * @version $Revision$
     20  */
     21 
     22 package org.apache.harmony.awt.gl.font;
     23 
     24 
     25 /**
     26  * Class containing font property information. This information can be found
     27  * in font.property files. See API documentation, logical fonts description part.
     28  *
     29  */
     30 public class FontProperty {
     31 
     32     // font file name
     33     String fileName = null;
     34 
     35     // name of the encoding to be used
     36     String encoding = null;
     37 
     38     // array of exclusion ranges (pairs of low and high unicode exclusion bounds)
     39     int[] exclRange = null;
     40 
     41     // font face name
     42     String name = null;
     43 
     44     // font style
     45     int style = -1;
     46 
     47     /**
     48      * Returns font style of this font property.
     49      */
     50     public int getStyle(){
     51         return this.style;
     52     }
     53 
     54     /**
     55      * Returns font name of this font property.
     56      */
     57     public String getName(){
     58         return this.name;
     59     }
     60 
     61     /**
     62      * Returns encoding used in this font property.
     63      */
     64     public String getEncoding(){
     65         return this.encoding;
     66     }
     67 
     68     /**
     69      * Returns an array of exclusion ranges. This array contain pairs of
     70      * low and high bounds of the intervals of characters to ignore in
     71      * total Unicode characters range.
     72      */
     73     public int[] getExclusionRange(){
     74         return this.exclRange;
     75     }
     76 
     77     /**
     78      * Returns file name of the font that is described by this font property.
     79      */
     80     public String getFileName(){
     81         return this.fileName;
     82     }
     83 
     84     /**
     85      * Returns true if specified character covered by exclusion ranges of this
     86      * font property, false otherwise.
     87      *
     88      * @param ch specified char to check
     89      */
     90     public boolean isCharExcluded(char ch){
     91         if (exclRange == null ){
     92             return false;
     93         }
     94 
     95         for (int i = 0; i < exclRange.length;){
     96             int lb = exclRange[i++];
     97             int hb = exclRange[i++];
     98 
     99             if (ch >= lb && ch <= hb){
    100                 return true;
    101             }
    102         }
    103 
    104         return false;
    105     }
    106 }
    107