Use CamelCaseTags.

This commit is contained in:
Behdad Esfahbod 2006-12-25 06:22:08 -05:00
parent 808dbe283c
commit c81efca149
1 changed files with 14 additions and 15 deletions

View File

@ -256,9 +256,9 @@ struct TTCHeader {
typedef struct OpenTypeFontFile { typedef struct OpenTypeFontFile {
DEFINE_NOT_INSTANTIABLE(OpenTypeFontFile); DEFINE_NOT_INSTANTIABLE(OpenTypeFontFile);
static const hb_tag_t truetype_tag = HB_TAG ( 0 , 1 , 0 , 0 ); static const hb_tag_t TrueTypeTag = HB_TAG ( 0 , 1 , 0 , 0 );
static const hb_tag_t cff_tag = HB_TAG ('O','T','T','O'); static const hb_tag_t CFFTag = HB_TAG ('O','T','T','O');
static const hb_tag_t ttc_tag = HB_TAG ('t','t','c','f'); static const hb_tag_t TTCTag = HB_TAG ('t','t','c','f');
/* Factory: ::get(font_data) /* Factory: ::get(font_data)
* This is how you get a handle to one of these * This is how you get a handle to one of these
@ -274,22 +274,22 @@ typedef struct OpenTypeFontFile {
inline unsigned int get_len (void) const { inline unsigned int get_len (void) const {
switch (tag) { switch (tag) {
default: return 0; default: return 0;
case truetype_tag: case cff_tag: return 1; case TrueTypeTag: case CFFTag: return 1;
case ttc_tag: return ((const TTCHeader&)*this).get_len(); case TTCTag: return ((const TTCHeader&)*this).get_len();
} }
} }
inline const OpenTypeFont& operator[] (unsigned int i) const { inline const OpenTypeFont& operator[] (unsigned int i) const {
assert (i < get_len ()); assert (i < get_len ());
switch (tag) { switch (tag) {
default: case truetype_tag: case cff_tag: return (const OffsetTable&)*this; default: case TrueTypeTag: case CFFTag: return (const OffsetTable&)*this;
case ttc_tag: return ((const TTCHeader&)*this)[i]; case TTCTag: return ((const TTCHeader&)*this)[i];
} }
} }
inline OpenTypeFont& operator[] (unsigned int i) { inline OpenTypeFont& operator[] (unsigned int i) {
assert (i < get_len ()); assert (i < get_len ());
switch (tag) { switch (tag) {
default: case truetype_tag: case cff_tag: return (OffsetTable&)*this; default: case TrueTypeTag: case CFFTag: return (OffsetTable&)*this;
case ttc_tag: return ((TTCHeader&)*this)[i]; case TTCTag: return ((TTCHeader&)*this)[i];
} }
} }
@ -363,18 +363,17 @@ main (int argc, char **argv)
const OpenTypeFontFile &ot = OpenTypeFontFile::get (font_data); const OpenTypeFontFile &ot = OpenTypeFontFile::get (font_data);
switch (ot.tag) { switch (ot.tag) {
case HB_TAG (0,1,0,0): case OpenTypeFontFile::TrueTypeTag:
printf ("OpenType font with TrueType outlines\n"); printf ("OpenType font with TrueType outlines\n");
break; break;
case HB_TAG ('O','T','T','O'): case OpenTypeFontFile::CFFTag:
printf ("OpenType font with CFF (Type1) outlines\n"); printf ("OpenType font with CFF (Type1) outlines\n");
break; break;
case HB_TAG ('t','t','c','f'): case OpenTypeFontFile::TTCTag:
printf ("TrueType Collection of OpenType fonts\n"); printf ("TrueType Collection of OpenType fonts\n");
break; break;
default: default:
fprintf (stderr, "Unknown font format\n"); printf ("Unknown font format\n");
exit (1);
break; break;
} }
@ -382,7 +381,7 @@ main (int argc, char **argv)
printf ("%d font(s) found in file\n", num_fonts); printf ("%d font(s) found in file\n", num_fonts);
for (int n_font = 0; n_font < num_fonts; n_font++) { for (int n_font = 0; n_font < num_fonts; n_font++) {
const OpenTypeFont &font = ot[n_font]; const OpenTypeFont &font = ot[n_font];
printf ("Font %d of %d\n", n_font+1, num_fonts); printf ("Font %d of %d:\n", n_font+1, num_fonts);
int num_tables = font.get_len (); int num_tables = font.get_len ();
printf ("%d table(s) found in font\n", num_tables); printf ("%d table(s) found in font\n", num_tables);