Home | History | Annotate | Download | only in src
      1 /*
      2  * Copyright  2009  Red Hat, Inc.
      3  * Copyright  2011  Google, Inc.
      4  *
      5  *  This is part of HarfBuzz, a text shaping library.
      6  *
      7  * Permission is hereby granted, without written agreement and without
      8  * license or royalty fees, to use, copy, modify, and distribute this
      9  * software and its documentation for any purpose, provided that the
     10  * above copyright notice and the following two paragraphs appear in
     11  * all copies of this software.
     12  *
     13  * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
     14  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
     15  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
     16  * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
     17  * DAMAGE.
     18  *
     19  * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
     20  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
     21  * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
     22  * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
     23  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
     24  *
     25  * Red Hat Author(s): Behdad Esfahbod
     26  * Google Author(s): Behdad Esfahbod
     27  */
     28 
     29 #ifndef HB_FACE_PRIVATE_HH
     30 #define HB_FACE_PRIVATE_HH
     31 
     32 #include "hb-private.hh"
     33 
     34 #include "hb-font.h"
     35 #include "hb-object-private.hh"
     36 #include "hb-shaper-private.hh"
     37 #include "hb-shape-plan-private.hh"
     38 
     39 
     40 /*
     41  * hb_face_t
     42  */
     43 
     44 struct hb_face_t {
     45   hb_object_header_t header;
     46   ASSERT_POD ();
     47 
     48   hb_bool_t immutable;
     49 
     50   hb_reference_table_func_t  reference_table_func;
     51   void                      *user_data;
     52   hb_destroy_func_t          destroy;
     53 
     54   unsigned int index;
     55   mutable unsigned int upem;
     56   mutable unsigned int num_glyphs;
     57 
     58   struct hb_shaper_data_t shaper_data;
     59 
     60   struct plan_node_t {
     61     hb_shape_plan_t *shape_plan;
     62     plan_node_t *next;
     63   } *shape_plans;
     64 
     65 
     66   inline hb_blob_t *reference_table (hb_tag_t tag) const
     67   {
     68     hb_blob_t *blob;
     69 
     70     if (unlikely (!this || !reference_table_func))
     71       return hb_blob_get_empty ();
     72 
     73     blob = reference_table_func (/*XXX*/const_cast<hb_face_t *> (this), tag, user_data);
     74     if (unlikely (!blob))
     75       return hb_blob_get_empty ();
     76 
     77     return blob;
     78   }
     79 
     80   inline HB_PURE_FUNC unsigned int get_upem (void) const
     81   {
     82     if (unlikely (!upem))
     83       load_upem ();
     84     return upem;
     85   }
     86 
     87   inline unsigned int get_num_glyphs (void) const
     88   {
     89     if (unlikely (num_glyphs == (unsigned int) -1))
     90       load_num_glyphs ();
     91     return num_glyphs;
     92   }
     93 
     94   private:
     95   HB_INTERNAL void load_upem (void) const;
     96   HB_INTERNAL void load_num_glyphs (void) const;
     97 };
     98 
     99 extern HB_INTERNAL const hb_face_t _hb_face_nil;
    100 
    101 #define HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS
    102 #define HB_SHAPER_IMPLEMENT(shaper) HB_SHAPER_DATA_PROTOTYPE(shaper, face);
    103 #include "hb-shaper-list.hh"
    104 #undef HB_SHAPER_IMPLEMENT
    105 #undef HB_SHAPER_DATA_CREATE_FUNC_EXTRA_ARGS
    106 
    107 
    108 #endif /* HB_FACE_PRIVATE_HH */
    109