Logo Search packages:      
Sourcecode: pango-graphite version File versions  Download package

const void * gr::FreetypeFont::getTable ( fontTableId32  tableID,
size_t *  pcbSize 
) [virtual, inherited]

Returns a pointer to the start of a table in the font. The ftblid32 type is a 32-bit unsigned integer. If the Font class cannot easily determine the length of the table, it may set 0 as the length (while returning a non-NULL pointer to the table). This means that certain kinds of error checking cannot be done by the Graphite engine. Throws an exception if there is some other error in reading the table, or if the table asked for is not one of the expected ones (cmap, head, name, Sile, Silf, Feat, Gloc, Glat). [If we want to be able to read “non-standard” tables, then the caller needs to be responsible for freeing the memory.]

Definition at line 95 of file FreetypeFont.cpp.

{
  *pcbSize = 0;

  TableMap::const_iterator table_itr = m_tables.find(tableID);
  if (table_itr != m_tables.end())
  {
    // We have already loaded the table so use it.
    *pcbSize = table_itr->second.second;
    return table_itr->second.first;
  }
  else
  {
   // First find out how large the table is.
    FT_ULong tableBufferSz = 0;
    FT_Load_Sfnt_Table(m_ftFace, tableID, 0, 0, &tableBufferSz);
    if (tableBufferSz == 0)
      // We couldn't load the table for some reason so return 0;
      return 0;
    
    // Allocate a buffer and load the table.
    FT_Byte *pTable = new gr::byte[tableBufferSz];
    FT_Load_Sfnt_Table(m_ftFace, tableID, 0, pTable, 0);
    
    // record the table buffer and size into a record.  Note that we use the
    //  table ID as passed to this method, not the one passed to
    //  FT_Load_Sfnt_Table.
    m_tables[tableID] = std::make_pair(pTable, tableBufferSz);
    *pcbSize = tableBufferSz;
    return pTable;
  }
}


Generated by  Doxygen 1.6.0   Back to index