1 /*
   2  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   3  *
   4  * This code is free software; you can redistribute it and/or modify it
   5  * under the terms of the GNU General Public License version 2 only, as
   6  * published by the Free Software Foundation.  Oracle designates this
   7  * particular file as subject to the "Classpath" exception as provided
   8  * by Oracle in the LICENSE file that accompanied this code.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  */
  24 
  25 // This file is available under and governed by the GNU General Public
  26 // License version 2 only, as published by the Free Software Foundation.
  27 // However, the following notice accompanied the original version of this
  28 // file:
  29 //
  30 /*
  31  * Copyright © 2007,2008,2009  Red Hat, Inc.
  32  *
  33  *  This is part of HarfBuzz, a text shaping library.
  34  *
  35  * Permission is hereby granted, without written agreement and without
  36  * license or royalty fees, to use, copy, modify, and distribute this
  37  * software and its documentation for any purpose, provided that the
  38  * above copyright notice and the following two paragraphs appear in
  39  * all copies of this software.
  40  *
  41  * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
  42  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
  43  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
  44  * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
  45  * DAMAGE.
  46  *
  47  * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
  48  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  49  * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  50  * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
  51  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  52  *
  53  * Red Hat Author(s): Behdad Esfahbod
  54  */
  55 
  56 #ifndef HB_OT_H_IN
  57 #error "Include <hb-ot.h> instead."
  58 #endif
  59 
  60 #ifndef HB_OT_LAYOUT_H
  61 #define HB_OT_LAYOUT_H
  62 
  63 #include "hb.h"
  64 
  65 #include "hb-ot-tag.h"
  66 
  67 HB_BEGIN_DECLS
  68 
  69 
  70 #define HB_OT_TAG_GDEF HB_TAG('G','D','E','F')
  71 #define HB_OT_TAG_GSUB HB_TAG('G','S','U','B')
  72 #define HB_OT_TAG_GPOS HB_TAG('G','P','O','S')
  73 #define HB_OT_TAG_JSTF HB_TAG('J','S','T','F')
  74 
  75 
  76 /*
  77  * GDEF
  78  */
  79 
  80 hb_bool_t
  81 hb_ot_layout_has_glyph_classes (hb_face_t *face);
  82 
  83 typedef enum {
  84   HB_OT_LAYOUT_GLYPH_CLASS_UNCLASSIFIED = 0,
  85   HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH   = 1,
  86   HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE     = 2,
  87   HB_OT_LAYOUT_GLYPH_CLASS_MARK         = 3,
  88   HB_OT_LAYOUT_GLYPH_CLASS_COMPONENT    = 4
  89 } hb_ot_layout_glyph_class_t;
  90 
  91 hb_ot_layout_glyph_class_t
  92 hb_ot_layout_get_glyph_class (hb_face_t      *face,
  93                               hb_codepoint_t  glyph);
  94 
  95 void
  96 hb_ot_layout_get_glyphs_in_class (hb_face_t                  *face,
  97                                   hb_ot_layout_glyph_class_t  klass,
  98                                   hb_set_t                   *glyphs /* OUT */);
  99 
 100 
 101 /* Not that useful.  Provides list of attach points for a glyph that a
 102  * client may want to cache */
 103 unsigned int
 104 hb_ot_layout_get_attach_points (hb_face_t      *face,
 105                                 hb_codepoint_t  glyph,
 106                                 unsigned int    start_offset,
 107                                 unsigned int   *point_count /* IN/OUT */,
 108                                 unsigned int   *point_array /* OUT */);
 109 
 110 /* Ligature caret positions */
 111 unsigned int
 112 hb_ot_layout_get_ligature_carets (hb_font_t      *font,
 113                                   hb_direction_t  direction,
 114                                   hb_codepoint_t  glyph,
 115                                   unsigned int    start_offset,
 116                                   unsigned int   *caret_count /* IN/OUT */,
 117                                   hb_position_t  *caret_array /* OUT */);
 118 
 119 
 120 /*
 121  * GSUB/GPOS feature query and enumeration interface
 122  */
 123 
 124 #define HB_OT_LAYOUT_NO_SCRIPT_INDEX            0xFFFFu
 125 #define HB_OT_LAYOUT_NO_FEATURE_INDEX           0xFFFFu
 126 #define HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX     0xFFFFu
 127 
 128 unsigned int
 129 hb_ot_layout_table_get_script_tags (hb_face_t    *face,
 130                                     hb_tag_t      table_tag,
 131                                     unsigned int  start_offset,
 132                                     unsigned int *script_count /* IN/OUT */,
 133                                     hb_tag_t     *script_tags /* OUT */);
 134 
 135 hb_bool_t
 136 hb_ot_layout_table_find_script (hb_face_t    *face,
 137                                 hb_tag_t      table_tag,
 138                                 hb_tag_t      script_tag,
 139                                 unsigned int *script_index);
 140 
 141 /* Like find_script, but takes zero-terminated array of scripts to test */
 142 hb_bool_t
 143 hb_ot_layout_table_choose_script (hb_face_t      *face,
 144                                   hb_tag_t        table_tag,
 145                                   const hb_tag_t *script_tags,
 146                                   unsigned int   *script_index,
 147                                   hb_tag_t       *chosen_script);
 148 
 149 unsigned int
 150 hb_ot_layout_table_get_feature_tags (hb_face_t    *face,
 151                                      hb_tag_t      table_tag,
 152                                      unsigned int  start_offset,
 153                                      unsigned int *feature_count /* IN/OUT */,
 154                                      hb_tag_t     *feature_tags /* OUT */);
 155 
 156 unsigned int
 157 hb_ot_layout_script_get_language_tags (hb_face_t    *face,
 158                                        hb_tag_t      table_tag,
 159                                        unsigned int  script_index,
 160                                        unsigned int  start_offset,
 161                                        unsigned int *language_count /* IN/OUT */,
 162                                        hb_tag_t     *language_tags /* OUT */);
 163 
 164 hb_bool_t
 165 hb_ot_layout_script_find_language (hb_face_t    *face,
 166                                    hb_tag_t      table_tag,
 167                                    unsigned int  script_index,
 168                                    hb_tag_t      language_tag,
 169                                    unsigned int *language_index);
 170 
 171 hb_bool_t
 172 hb_ot_layout_language_get_required_feature_index (hb_face_t    *face,
 173                                                   hb_tag_t      table_tag,
 174                                                   unsigned int  script_index,
 175                                                   unsigned int  language_index,
 176                                                   unsigned int *feature_index);
 177 
 178 hb_bool_t
 179 hb_ot_layout_language_get_required_feature (hb_face_t    *face,
 180                                             hb_tag_t      table_tag,
 181                                             unsigned int  script_index,
 182                                             unsigned int  language_index,
 183                                             unsigned int *feature_index,
 184                                             hb_tag_t     *feature_tag);
 185 
 186 unsigned int
 187 hb_ot_layout_language_get_feature_indexes (hb_face_t    *face,
 188                                            hb_tag_t      table_tag,
 189                                            unsigned int  script_index,
 190                                            unsigned int  language_index,
 191                                            unsigned int  start_offset,
 192                                            unsigned int *feature_count /* IN/OUT */,
 193                                            unsigned int *feature_indexes /* OUT */);
 194 
 195 unsigned int
 196 hb_ot_layout_language_get_feature_tags (hb_face_t    *face,
 197                                         hb_tag_t      table_tag,
 198                                         unsigned int  script_index,
 199                                         unsigned int  language_index,
 200                                         unsigned int  start_offset,
 201                                         unsigned int *feature_count /* IN/OUT */,
 202                                         hb_tag_t     *feature_tags /* OUT */);
 203 
 204 hb_bool_t
 205 hb_ot_layout_language_find_feature (hb_face_t    *face,
 206                                     hb_tag_t      table_tag,
 207                                     unsigned int  script_index,
 208                                     unsigned int  language_index,
 209                                     hb_tag_t      feature_tag,
 210                                     unsigned int *feature_index);
 211 
 212 unsigned int
 213 hb_ot_layout_feature_get_lookups (hb_face_t    *face,
 214                                   hb_tag_t      table_tag,
 215                                   unsigned int  feature_index,
 216                                   unsigned int  start_offset,
 217                                   unsigned int *lookup_count /* IN/OUT */,
 218                                   unsigned int *lookup_indexes /* OUT */);
 219 
 220 unsigned int
 221 hb_ot_layout_table_get_lookup_count (hb_face_t    *face,
 222                                      hb_tag_t      table_tag);
 223 
 224 
 225 void
 226 hb_ot_layout_collect_lookups (hb_face_t      *face,
 227                               hb_tag_t        table_tag,
 228                               const hb_tag_t *scripts,
 229                               const hb_tag_t *languages,
 230                               const hb_tag_t *features,
 231                               hb_set_t       *lookup_indexes /* OUT */);
 232 
 233 void
 234 hb_ot_layout_lookup_collect_glyphs (hb_face_t    *face,
 235                                     hb_tag_t      table_tag,
 236                                     unsigned int  lookup_index,
 237                                     hb_set_t     *glyphs_before, /* OUT. May be NULL */
 238                                     hb_set_t     *glyphs_input,  /* OUT. May be NULL */
 239                                     hb_set_t     *glyphs_after,  /* OUT. May be NULL */
 240                                     hb_set_t     *glyphs_output  /* OUT. May be NULL */);
 241 
 242 #ifdef HB_NOT_IMPLEMENTED
 243 typedef struct
 244 {
 245   const hb_codepoint_t *before,
 246   unsigned int          before_length,
 247   const hb_codepoint_t *input,
 248   unsigned int          input_length,
 249   const hb_codepoint_t *after,
 250   unsigned int          after_length,
 251 } hb_ot_layout_glyph_sequence_t;
 252 
 253 typedef hb_bool_t
 254 (*hb_ot_layout_glyph_sequence_func_t) (hb_font_t    *font,
 255                                        hb_tag_t      table_tag,
 256                                        unsigned int  lookup_index,
 257                                        const hb_ot_layout_glyph_sequence_t *sequence,
 258                                        void         *user_data);
 259 
 260 void
 261 Xhb_ot_layout_lookup_enumerate_sequences (hb_face_t    *face,
 262                                          hb_tag_t      table_tag,
 263                                          unsigned int  lookup_index,
 264                                          hb_ot_layout_glyph_sequence_func_t callback,
 265                                          void         *user_data);
 266 #endif
 267 
 268 
 269 /*
 270  * GSUB
 271  */
 272 
 273 hb_bool_t
 274 hb_ot_layout_has_substitution (hb_face_t *face);
 275 
 276 hb_bool_t
 277 hb_ot_layout_lookup_would_substitute (hb_face_t            *face,
 278                                       unsigned int          lookup_index,
 279                                       const hb_codepoint_t *glyphs,
 280                                       unsigned int          glyphs_length,
 281                                       hb_bool_t             zero_context);
 282 
 283 void
 284 hb_ot_layout_lookup_substitute_closure (hb_face_t    *face,
 285                                         unsigned int  lookup_index,
 286                                         hb_set_t     *glyphs
 287                                         /*TODO , hb_bool_t  inclusive */);
 288 
 289 #ifdef HB_NOT_IMPLEMENTED
 290 /* Note: You better have GDEF when using this API, or marks won't do much. */
 291 hb_bool_t
 292 Xhb_ot_layout_lookup_substitute (hb_font_t            *font,
 293                                 unsigned int          lookup_index,
 294                                 const hb_ot_layout_glyph_sequence_t *sequence,
 295                                 unsigned int          out_size,
 296                                 hb_codepoint_t       *glyphs_out,   /* OUT */
 297                                 unsigned int         *clusters_out, /* OUT */
 298                                 unsigned int         *out_length    /* OUT */);
 299 #endif
 300 
 301 
 302 /*
 303  * GPOS
 304  */
 305 
 306 hb_bool_t
 307 hb_ot_layout_has_positioning (hb_face_t *face);
 308 
 309 #ifdef HB_NOT_IMPLEMENTED
 310 /* Note: You better have GDEF when using this API, or marks won't do much. */
 311 hb_bool_t
 312 Xhb_ot_layout_lookup_position (hb_font_t            *font,
 313                               unsigned int          lookup_index,
 314                               const hb_ot_layout_glyph_sequence_t *sequence,
 315                               hb_glyph_position_t  *positions /* IN / OUT */);
 316 #endif
 317 
 318 /* Optical 'size' feature info.  Returns true if found.
 319  * http://www.microsoft.com/typography/otspec/features_pt.htm#size */
 320 hb_bool_t
 321 hb_ot_layout_get_size_params (hb_face_t    *face,
 322                               unsigned int *design_size,       /* OUT.  May be NULL */
 323                               unsigned int *subfamily_id,      /* OUT.  May be NULL */
 324                               unsigned int *subfamily_name_id, /* OUT.  May be NULL */
 325                               unsigned int *range_start,       /* OUT.  May be NULL */
 326                               unsigned int *range_end          /* OUT.  May be NULL */);
 327 
 328 
 329 HB_END_DECLS
 330 
 331 #endif /* HB_OT_LAYOUT_H */