Apply non-controversial parts of ot-style (#1464)
authorEbrahim Byagowi <ebrahim@gnu.org>
Sat, 8 Dec 2018 06:50:25 +0000 (10:20 +0330)
committerGitHub <noreply@github.com>
Sat, 8 Dec 2018 06:50:25 +0000 (10:20 +0330)
Things to be used in https://github.com/harfbuzz/harfbuzz/pull/1459

src/hb-aat-fdsc-table.hh
src/hb-aat-layout-common.hh
src/hb-ot-head-table.hh
src/hb-ot-os2-table.hh
src/hb-ot-stat-table.hh

index 136172c..c3bc1d5 100644 (file)
@@ -26,6 +26,7 @@
 #define HB_AAT_FDSC_TABLE_HH
 
 #include "hb-aat-layout-common.hh"
+#include "hb-open-type.hh"
 
 /*
  * fdsc -- Font descriptors
 namespace AAT {
 
 
-struct GXFontDescriptor
+struct FontDescriptor
 {
+  inline bool has_data () const { return tag; }
+
+  inline int cmp (hb_tag_t a) const { return tag.cmp (a); }
+
+  inline float get_value () const { return u.value.to_float (); }
+
+  enum non_alphabetic_value_t {
+    Alphabetic         = 0,
+    Dingbats           = 1,
+    PiCharacters       = 2,
+    Fleurons           = 3,
+    DecorativeBorders  = 4,
+    InternationalSymbols= 5,
+    MathSymbols                = 6
+  };
+
   inline bool sanitize (hb_sanitize_context_t *c) const
   {
     TRACE_SANITIZE (this);
     return_trace (c->check_struct (this));
   }
 
-  public:
+  protected:
   Tag          tag;            /* The 4-byte table tag name. */
+  union {
   Fixed                value;          /* The value for the descriptor tag. */
+  HBUINT32     nalfType;       /* If the tag is `nalf`, see non_alphabetic_value_t */
+  } u;
   public:
   DEFINE_SIZE_STATIC (8);
 };
@@ -77,6 +97,9 @@ struct fdsc
                                 * (default value: 0) */
   };
 
+  inline const FontDescriptor &get_descriptor (hb_tag_t style) const
+  { return descriptors.lsearch (style); }
+
   inline bool sanitize (hb_sanitize_context_t *c) const
   {
     TRACE_SANITIZE (this);
@@ -87,7 +110,7 @@ struct fdsc
   protected:
   Fixed                version;        /* Version number of the font descriptors
                                 * table (0x00010000 for the current version). */
-  LArrayOf<GXFontDescriptor>
+  LArrayOf<FontDescriptor>
                descriptors;    /* List of tagged-coordinate pairs style descriptors
                                 * that will be included to characterize this font.
                                 * Each descriptor consists of a <tag, value> pair.
index 57228c4..74c70de 100644 (file)
@@ -28,6 +28,7 @@
 #define HB_AAT_LAYOUT_COMMON_HH
 
 #include "hb-aat-layout.hh"
+#include "hb-open-type.hh"
 
 
 namespace AAT {
index 931ccd4..85867db 100644 (file)
@@ -54,6 +54,19 @@ struct head
     return 16 <= upem && upem <= 16384 ? upem : 1000;
   }
 
+  enum mac_style_flag_t {
+    BOLD       = 1u<<0,
+    ITALIC     = 1u<<1,
+    UNDERLINE  = 1u<<2,
+    OUTLINE    = 1u<<3,
+    SHADOW     = 1u<<4,
+    CONDENSED  = 1u<<5
+  };
+
+  inline bool is_bold (void) const      { return macStyle & BOLD; }
+  inline bool is_italic (void) const    { return macStyle & ITALIC; }
+  inline bool is_condensed (void) const { return macStyle & CONDENSED; }
+
   inline bool sanitize (hb_sanitize_context_t *c) const
   {
     TRACE_SANITIZE (this);
index 46e8b70..e06ed57 100644 (file)
@@ -93,10 +93,56 @@ struct OS2
 {
   enum { tableTag = HB_OT_TAG_OS2 };
 
+  inline bool has_data () const { return this != &Null (OS2); }
+
   inline const OS2V1Tail &v1 (void) const { return version >= 1 ? v1X : Null (OS2V1Tail); }
   inline const OS2V2Tail &v2 (void) const { return version >= 2 ? v2X : Null (OS2V2Tail); }
   inline const OS2V5Tail &v5 (void) const { return version >= 5 ? v5X : Null (OS2V5Tail); }
 
+  enum fs_selection_flag_t {
+    ITALIC             = 1u<<0,
+    UNDERSCORE         = 1u<<1,
+    NEGATIVE           = 1u<<2,
+    OUTLINED           = 1u<<3,
+    STRIKEOUT          = 1u<<4,
+    BOLD               = 1u<<5,
+    REGULAR            = 1u<<6,
+    USE_TYPO_METRICS   = 1u<<7,
+    WWS                        = 1u<<8,
+    OBLIQUE            = 1u<<9
+  };
+
+  inline bool is_italic (void) const  { return fsSelection & ITALIC; }
+  inline bool is_oblique (void) const { return fsSelection & OBLIQUE; }
+
+  enum us_width_class_t {
+    FWIDTH_ULTRA_CONDENSED     = 1, /* 50% */
+    FWIDTH_EXTRA_CONDENSED     = 2, /* 62.5% */
+    FWIDTH_CONDENSED           = 3, /* 75% */
+    FWIDTH_SEMI_CONDENSED      = 4, /* 87.5% */
+    FWIDTH_NORMAL              = 5, /* 100% */
+    FWIDTH_SEMI_EXPANDED       = 6, /* 112.5% */
+    FWIDTH_EXPANDED            = 7, /* 125% */
+    FWIDTH_EXTRA_EXPANDED      = 8, /* 150% */
+    FWIDTH_ULTRA_EXPANDED      = 9  /* 200% */
+  };
+
+  inline float get_width () const
+  {
+    switch (usWidthClass) {
+    case FWIDTH_ULTRA_CONDENSED:return 50.f;
+    case FWIDTH_EXTRA_CONDENSED:return 62.5f;
+    case FWIDTH_CONDENSED:     return 75.f;
+    case FWIDTH_SEMI_CONDENSED:        return 87.5f;
+    default:
+    case FWIDTH_NORMAL:                return 100.f;
+    case FWIDTH_SEMI_EXPANDED: return 112.5f;
+    case FWIDTH_EXPANDED:      return 125.f;
+    case FWIDTH_EXTRA_EXPANDED:        return 150.f;
+    case FWIDTH_ULTRA_EXPANDED:        return 200.f;
+    }
+  }
+
   inline bool subset (hb_subset_plan_t *plan) const
   {
     hb_blob_t *os2_blob = hb_sanitize_context_t ().reference_table<OS2> (plan->source);
index 7ad45db..e18ff1e 100644 (file)
@@ -57,25 +57,6 @@ enum
   // Reserved = 0xFFFC                         /* Reserved for future use — set to zero. */
 };
 
-struct StatAxisRecord
-{
-  inline bool sanitize (hb_sanitize_context_t *c) const
-  {
-    TRACE_SANITIZE (this);
-    return_trace (likely (c->check_struct (this)));
-  }
-
-  protected:
-  Tag          axisTag;        /* A tag identifying the axis of design variation. */
-  NameID       axisNameID;     /* The name ID for entries in the 'name' table that
-                                * provide a display string for this axis. */
-  HBUINT16     axisOrdering;   /* A value that applications can use to determine
-                                * primary sorting of face names, or for ordering
-                                * of descriptors when composing family or face names. */
-  public:
-  DEFINE_SIZE_STATIC (8);
-};
-
 struct AxisValueFormat1
 {
   inline bool sanitize (hb_sanitize_context_t *c) const
@@ -223,6 +204,25 @@ struct AxisValue
   DEFINE_SIZE_UNION (2, format);
 };
 
+struct StatAxisRecord
+{
+  inline bool sanitize (hb_sanitize_context_t *c) const
+  {
+    TRACE_SANITIZE (this);
+    return_trace (likely (c->check_struct (this)));
+  }
+
+  protected:
+  Tag          tag;            /* A tag identifying the axis of design variation. */
+  NameID       nameID;         /* The name ID for entries in the 'name' table that
+                                * provide a display string for this axis. */
+  HBUINT16     ordering;       /* A value that applications can use to determine
+                                * primary sorting of face names, or for ordering
+                                * of descriptors when composing family or face names. */
+  public:
+  DEFINE_SIZE_STATIC (8);
+};
+
 struct STAT
 {
   enum { tableTag = HB_OT_TAG_STAT };