1 /***************************************************************************/
   2 /*                                                                         */
   3 /*  ftcid.c                                                                */
   4 /*                                                                         */
   5 /*    FreeType API for accessing CID font information.                     */
   6 /*                                                                         */
   7 /*  Copyright 2007-2018 by                                                 */
   8 /*  Derek Clegg and Michael Toftdal.                                       */
   9 /*                                                                         */
  10 /*  This file is part of the FreeType project, and may only be used,       */
  11 /*  modified, and distributed under the terms of the FreeType project      */
  12 /*  license, LICENSE.TXT.  By continuing to use, modify, or distribute     */
  13 /*  this file you indicate that you have read the license and              */
  14 /*  understand and accept it fully.                                        */
  15 /*                                                                         */
  16 /***************************************************************************/
  17 
  18 
  19 #include <ft2build.h>
  20 #include FT_CID_H
  21 #include FT_INTERNAL_OBJECTS_H
  22 #include FT_SERVICE_CID_H
  23 
  24 
  25   /* documentation is in ftcid.h */
  26 
  27   FT_EXPORT_DEF( FT_Error )
  28   FT_Get_CID_Registry_Ordering_Supplement( FT_Face       face,
  29                                            const char*  *registry,
  30                                            const char*  *ordering,
  31                                            FT_Int       *supplement)
  32   {
  33     FT_Error     error;
  34     const char*  r = NULL;
  35     const char*  o = NULL;
  36     FT_Int       s = 0;
  37 
  38 
  39     error = FT_ERR( Invalid_Argument );
  40 
  41     if ( face )
  42     {
  43       FT_Service_CID  service;
  44 
  45 
  46       FT_FACE_FIND_SERVICE( face, service, CID );
  47 
  48       if ( service && service->get_ros )
  49         error = service->get_ros( face, &r, &o, &s );
  50     }
  51 
  52     if ( registry )
  53       *registry = r;
  54 
  55     if ( ordering )
  56       *ordering = o;
  57 
  58     if ( supplement )
  59       *supplement = s;
  60 
  61     return error;
  62   }
  63 
  64 
  65   FT_EXPORT_DEF( FT_Error )
  66   FT_Get_CID_Is_Internally_CID_Keyed( FT_Face   face,
  67                                       FT_Bool  *is_cid )
  68   {
  69     FT_Error  error = FT_ERR( Invalid_Argument );
  70     FT_Bool   ic = 0;
  71 
  72 
  73     if ( face )
  74     {
  75       FT_Service_CID  service;
  76 
  77 
  78       FT_FACE_FIND_SERVICE( face, service, CID );
  79 
  80       if ( service && service->get_is_cid )
  81         error = service->get_is_cid( face, &ic);
  82     }
  83 
  84     if ( is_cid )
  85       *is_cid = ic;
  86 
  87     return error;
  88   }
  89 
  90 
  91   FT_EXPORT_DEF( FT_Error )
  92   FT_Get_CID_From_Glyph_Index( FT_Face   face,
  93                                FT_UInt   glyph_index,
  94                                FT_UInt  *cid )
  95   {
  96     FT_Error  error = FT_ERR( Invalid_Argument );
  97     FT_UInt   c = 0;
  98 
  99 
 100     if ( face )
 101     {
 102       FT_Service_CID  service;
 103 
 104 
 105       FT_FACE_FIND_SERVICE( face, service, CID );
 106 
 107       if ( service && service->get_cid_from_glyph_index )
 108         error = service->get_cid_from_glyph_index( face, glyph_index, &c);
 109     }
 110 
 111     if ( cid )
 112       *cid = c;
 113 
 114     return error;
 115   }
 116 
 117 
 118 /* END */