< prev index next >

src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-cbdt-table.hh

Print this page




 199   inline bool get_extents (hb_glyph_extents_t *extents) const
 200   {
 201     return (this+offsetToSubtable).get_extents (extents);
 202   }
 203 
 204   bool get_image_data (unsigned int gid,
 205                        unsigned int *offset,
 206                        unsigned int *length,
 207                        unsigned int *format) const
 208   {
 209     if (gid < firstGlyphIndex || gid > lastGlyphIndex)
 210     {
 211       return false;
 212     }
 213     return (this+offsetToSubtable).get_image_data (gid - firstGlyphIndex,
 214                                                    offset, length, format);
 215   }
 216 
 217   USHORT firstGlyphIndex;
 218   USHORT lastGlyphIndex;
 219   OffsetTo<IndexSubtable, ULONG> offsetToSubtable;
 220 
 221   DEFINE_SIZE_STATIC(8);
 222 };
 223 
 224 struct IndexSubtableArray
 225 {
 226   inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const
 227   {
 228     TRACE_SANITIZE (this);
 229     if (unlikely (!c->check_array (&indexSubtablesZ, indexSubtablesZ[0].static_size, count)))
 230       return_trace (false);
 231     for (unsigned int i = 0; i < count; i++)
 232       if (unlikely (!indexSubtablesZ[i].sanitize (c, this)))
 233         return_trace (false);
 234     return_trace (true);
 235   }
 236 
 237   public:
 238   const IndexSubtableRecord* find_table (hb_codepoint_t glyph, unsigned int numTables) const
 239   {
 240     for (unsigned int i = 0; i < numTables; ++i)
 241     {
 242       unsigned int firstGlyphIndex = indexSubtablesZ[i].firstGlyphIndex;
 243       unsigned int lastGlyphIndex = indexSubtablesZ[i].lastGlyphIndex;
 244       if (firstGlyphIndex <= glyph && glyph <= lastGlyphIndex) {
 245         return &indexSubtablesZ[i];
 246       }
 247     }
 248     return NULL;
 249   }
 250 
 251   protected:
 252   IndexSubtableRecord indexSubtablesZ[VAR];
 253 
 254   public:
 255   DEFINE_SIZE_ARRAY(0, indexSubtablesZ);
 256 };
 257 
 258 struct BitmapSizeTable
 259 {
 260   friend struct CBLC;
 261 
 262   inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
 263   {
 264     TRACE_SANITIZE (this);
 265     return_trace (c->check_struct (this) &&
 266                   indexSubtableArrayOffset.sanitize (c, base, numberOfIndexSubtables) &&
 267                   c->check_range (&(base+indexSubtableArrayOffset), indexTablesSize) &&
 268                   horizontal.sanitize (c) &&
 269                   vertical.sanitize (c));
 270   }
 271 
 272   const IndexSubtableRecord *find_table (hb_codepoint_t glyph, const void *base) const
 273   {
 274     return (base+indexSubtableArrayOffset).find_table (glyph, numberOfIndexSubtables);
 275   }
 276 
 277   protected:
 278   OffsetTo<IndexSubtableArray, ULONG> indexSubtableArrayOffset;
 279   ULONG indexTablesSize;
 280   ULONG numberOfIndexSubtables;
 281   ULONG colorRef;
 282   SBitLineMetrics horizontal;
 283   SBitLineMetrics vertical;
 284   USHORT startGlyphIndex;
 285   USHORT endGlyphIndex;
 286   BYTE ppemX;
 287   BYTE ppemY;
 288   BYTE bitDepth;
 289   CHAR flags;
 290 
 291 public:
 292   DEFINE_SIZE_STATIC(48);
 293 };
 294 
 295 
 296 /*
 297  * Glyph Bitmap Data Formats.
 298  */


 327 
 328   public:
 329   const IndexSubtableRecord *find_table (hb_codepoint_t glyph,
 330                                          unsigned int *x_ppem, unsigned int *y_ppem) const
 331   {
 332     /* TODO: Make it possible to select strike. */
 333 
 334     unsigned int count = sizeTables.len;
 335     for (uint32_t i = 0; i < count; ++i)
 336     {
 337       unsigned int startGlyphIndex = sizeTables.array[i].startGlyphIndex;
 338       unsigned int endGlyphIndex = sizeTables.array[i].endGlyphIndex;
 339       if (startGlyphIndex <= glyph && glyph <= endGlyphIndex)
 340       {
 341         *x_ppem = sizeTables[i].ppemX;
 342         *y_ppem = sizeTables[i].ppemY;
 343         return sizeTables[i].find_table (glyph, this);
 344       }
 345     }
 346 
 347     return NULL;
 348   }
 349 
 350   protected:
 351   FixedVersion<>version;
 352   ArrayOf<BitmapSizeTable, ULONG> sizeTables;
 353 
 354   public:
 355   DEFINE_SIZE_ARRAY(8, sizeTables);
 356 };
 357 
 358 /*
 359  * CBDT -- Color Bitmap Data Table
 360  */
 361 #define HB_OT_TAG_CBDT HB_TAG('C','B','D','T')
 362 
 363 struct CBDT
 364 {
 365   static const hb_tag_t tableTag = HB_OT_TAG_CBDT;
 366 
 367   inline bool sanitize (hb_sanitize_context_t *c) const
 368   {
 369     TRACE_SANITIZE (this);
 370     return_trace (c->check_struct (this) &&
 371                   likely (version.major == 2 || version.major == 3));
 372   }


 199   inline bool get_extents (hb_glyph_extents_t *extents) const
 200   {
 201     return (this+offsetToSubtable).get_extents (extents);
 202   }
 203 
 204   bool get_image_data (unsigned int gid,
 205                        unsigned int *offset,
 206                        unsigned int *length,
 207                        unsigned int *format) const
 208   {
 209     if (gid < firstGlyphIndex || gid > lastGlyphIndex)
 210     {
 211       return false;
 212     }
 213     return (this+offsetToSubtable).get_image_data (gid - firstGlyphIndex,
 214                                                    offset, length, format);
 215   }
 216 
 217   USHORT firstGlyphIndex;
 218   USHORT lastGlyphIndex;
 219   LOffsetTo<IndexSubtable> offsetToSubtable;
 220 
 221   DEFINE_SIZE_STATIC(8);
 222 };
 223 
 224 struct IndexSubtableArray
 225 {
 226   inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const
 227   {
 228     TRACE_SANITIZE (this);
 229     if (unlikely (!c->check_array (&indexSubtablesZ, indexSubtablesZ[0].static_size, count)))
 230       return_trace (false);
 231     for (unsigned int i = 0; i < count; i++)
 232       if (unlikely (!indexSubtablesZ[i].sanitize (c, this)))
 233         return_trace (false);
 234     return_trace (true);
 235   }
 236 
 237   public:
 238   const IndexSubtableRecord* find_table (hb_codepoint_t glyph, unsigned int numTables) const
 239   {
 240     for (unsigned int i = 0; i < numTables; ++i)
 241     {
 242       unsigned int firstGlyphIndex = indexSubtablesZ[i].firstGlyphIndex;
 243       unsigned int lastGlyphIndex = indexSubtablesZ[i].lastGlyphIndex;
 244       if (firstGlyphIndex <= glyph && glyph <= lastGlyphIndex) {
 245         return &indexSubtablesZ[i];
 246       }
 247     }
 248     return nullptr;
 249   }
 250 
 251   protected:
 252   IndexSubtableRecord indexSubtablesZ[VAR];
 253 
 254   public:
 255   DEFINE_SIZE_ARRAY(0, indexSubtablesZ);
 256 };
 257 
 258 struct BitmapSizeTable
 259 {
 260   friend struct CBLC;
 261 
 262   inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
 263   {
 264     TRACE_SANITIZE (this);
 265     return_trace (c->check_struct (this) &&
 266                   indexSubtableArrayOffset.sanitize (c, base, numberOfIndexSubtables) &&
 267                   c->check_range (&(base+indexSubtableArrayOffset), indexTablesSize) &&
 268                   horizontal.sanitize (c) &&
 269                   vertical.sanitize (c));
 270   }
 271 
 272   const IndexSubtableRecord *find_table (hb_codepoint_t glyph, const void *base) const
 273   {
 274     return (base+indexSubtableArrayOffset).find_table (glyph, numberOfIndexSubtables);
 275   }
 276 
 277   protected:
 278   LOffsetTo<IndexSubtableArray> indexSubtableArrayOffset;
 279   ULONG indexTablesSize;
 280   ULONG numberOfIndexSubtables;
 281   ULONG colorRef;
 282   SBitLineMetrics horizontal;
 283   SBitLineMetrics vertical;
 284   USHORT startGlyphIndex;
 285   USHORT endGlyphIndex;
 286   BYTE ppemX;
 287   BYTE ppemY;
 288   BYTE bitDepth;
 289   CHAR flags;
 290 
 291 public:
 292   DEFINE_SIZE_STATIC(48);
 293 };
 294 
 295 
 296 /*
 297  * Glyph Bitmap Data Formats.
 298  */


 327 
 328   public:
 329   const IndexSubtableRecord *find_table (hb_codepoint_t glyph,
 330                                          unsigned int *x_ppem, unsigned int *y_ppem) const
 331   {
 332     /* TODO: Make it possible to select strike. */
 333 
 334     unsigned int count = sizeTables.len;
 335     for (uint32_t i = 0; i < count; ++i)
 336     {
 337       unsigned int startGlyphIndex = sizeTables.array[i].startGlyphIndex;
 338       unsigned int endGlyphIndex = sizeTables.array[i].endGlyphIndex;
 339       if (startGlyphIndex <= glyph && glyph <= endGlyphIndex)
 340       {
 341         *x_ppem = sizeTables[i].ppemX;
 342         *y_ppem = sizeTables[i].ppemY;
 343         return sizeTables[i].find_table (glyph, this);
 344       }
 345     }
 346 
 347     return nullptr;
 348   }
 349 
 350   protected:
 351   FixedVersion<>                version;
 352   LArrayOf<BitmapSizeTable>     sizeTables;
 353 
 354   public:
 355   DEFINE_SIZE_ARRAY(8, sizeTables);
 356 };
 357 
 358 /*
 359  * CBDT -- Color Bitmap Data Table
 360  */
 361 #define HB_OT_TAG_CBDT HB_TAG('C','B','D','T')
 362 
 363 struct CBDT
 364 {
 365   static const hb_tag_t tableTag = HB_OT_TAG_CBDT;
 366 
 367   inline bool sanitize (hb_sanitize_context_t *c) const
 368   {
 369     TRACE_SANITIZE (this);
 370     return_trace (c->check_struct (this) &&
 371                   likely (version.major == 2 || version.major == 3));
 372   }
< prev index next >