• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2018  Ebrahim Byagowi
3  *
4  *  This is part of HarfBuzz, a text shaping library.
5  *
6  * Permission is hereby granted, without written agreement and without
7  * license or royalty fees, to use, copy, modify, and distribute this
8  * software and its documentation for any purpose, provided that the
9  * above copyright notice and the following two paragraphs appear in
10  * all copies of this software.
11  *
12  * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
13  * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
14  * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
15  * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
16  * DAMAGE.
17  *
18  * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
19  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
21  * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
22  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
23  */
24 
25 #ifndef HB_AAT_FDSC_TABLE_HH
26 #define HB_AAT_FDSC_TABLE_HH
27 
28 #include "hb-aat-layout-common.hh"
29 #include "hb-open-type.hh"
30 
31 /*
32  * fdsc -- Font descriptors
33  * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6fdsc.html
34  */
35 #define HB_AAT_TAG_fdsc HB_TAG('f','d','s','c')
36 
37 
38 namespace AAT {
39 
40 
41 struct FontDescriptor
42 {
has_dataAAT::FontDescriptor43   bool has_data () const { return tag; }
44 
cmpAAT::FontDescriptor45   int cmp (hb_tag_t a) const { return tag.cmp (a); }
46 
get_valueAAT::FontDescriptor47   float get_value () const { return u.value.to_float (); }
48 
49   enum non_alphabetic_value_t {
50     Alphabetic		= 0,
51     Dingbats		= 1,
52     PiCharacters	= 2,
53     Fleurons		= 3,
54     DecorativeBorders	= 4,
55     InternationalSymbols= 5,
56     MathSymbols		= 6
57   };
58 
sanitizeAAT::FontDescriptor59   bool sanitize (hb_sanitize_context_t *c) const
60   {
61     TRACE_SANITIZE (this);
62     return_trace (c->check_struct (this));
63   }
64 
65   protected:
66   Tag		tag;		/* The 4-byte table tag name. */
67   union {
68   Fixed		value;		/* The value for the descriptor tag. */
69   HBUINT32	nalfType;	/* If the tag is `nalf`, see non_alphabetic_value_t */
70   } u;
71   public:
72   DEFINE_SIZE_STATIC (8);
73 };
74 
75 struct fdsc
76 {
77   enum { tableTag = HB_AAT_TAG_fdsc };
78 
79   enum {
80     Weight	 = HB_TAG ('w','g','h','t'),
81 				/* Percent weight relative to regular weight.
82 				 * (defaul value: 1.0) */
83     Width 	 = HB_TAG ('w','d','t','h'),
84 				/* Percent width relative to regular width.
85 				 * (default value: 1.0) */
86     Slant 	 = HB_TAG ('s','l','n','t'),
87 				/* Angle of slant in degrees, where positive
88 				 * is clockwise from straight up.
89 				 * (default value: 0.0) */
90     OpticalSize  = HB_TAG ('o','p','s','z'),
91 				/* Point size the font was designed for.
92 				 * (default value: 12.0) */
93     NonAlphabetic= HB_TAG ('n','a','l','f')
94 				/* These values are treated as integers,
95 				 * not fixed32s. 0 means alphabetic, and greater
96 				 * integers mean the font is non-alphabetic (e.g. symbols).
97 				 * (default value: 0) */
98   };
99 
get_descriptorAAT::fdsc100   const FontDescriptor &get_descriptor (hb_tag_t style) const
101   { return descriptors.lsearch (style); }
102 
sanitizeAAT::fdsc103   bool sanitize (hb_sanitize_context_t *c) const
104   {
105     TRACE_SANITIZE (this);
106     return_trace (c->check_struct (this) &&
107 		  descriptors.sanitize (c));
108   }
109 
110   protected:
111   Fixed		version;	/* Version number of the font descriptors
112 				 * table (0x00010000 for the current version). */
113   LArrayOf<FontDescriptor>
114 		descriptors;	/* List of tagged-coordinate pairs style descriptors
115 				 * that will be included to characterize this font.
116 				 * Each descriptor consists of a <tag, value> pair.
117 				 * These pairs are located in the gxFontDescriptor
118 				 * array that follows. */
119   public:
120   DEFINE_SIZE_ARRAY (8, descriptors);
121 };
122 
123 } /* namespace AAT */
124 
125 
126 #endif /* HB_AAT_FDSC_TABLE_HH */
127