From ec905d131374f0860bac77c52873eed984b1966f Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Sun, 9 Jun 2019 19:10:35 +0200 Subject: use std::array in TrueTypeFont Change-Id: Ib19e907a9b6fcce3a3938c5dee29ff658b12e9c4 Reviewed-on: https://gerrit.libreoffice.org/73735 Tested-by: Jenkins Reviewed-by: Noel Grandin --- vcl/inc/sft.hxx | 44 ++++++++++++++++++++++--------------------- vcl/source/fontsubset/sft.cxx | 7 ------- 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx index 95fbcadb0d8d..52207bb48d02 100644 --- a/vcl/inc/sft.hxx +++ b/vcl/inc/sft.hxx @@ -49,6 +49,7 @@ #include #include +#include #include #include #include @@ -440,6 +441,26 @@ namespace vcl /*- private definitions */ +/* indexes into TrueTypeFont::tables[] and TrueTypeFont::tlens[] */ +#define O_maxp 0 /* 'maxp' */ +#define O_glyf 1 /* 'glyf' */ +#define O_head 2 /* 'head' */ +#define O_loca 3 /* 'loca' */ +#define O_name 4 /* 'name' */ +#define O_hhea 5 /* 'hhea' */ +#define O_hmtx 6 /* 'hmtx' */ +#define O_cmap 7 /* 'cmap' */ +#define O_vhea 8 /* 'vhea' */ +#define O_vmtx 9 /* 'vmtx' */ +#define O_OS2 10 /* 'OS/2' */ +#define O_post 11 /* 'post' */ +#define O_cvt 13 /* 'cvt_' - only used in TT->TT generation */ +#define O_prep 14 /* 'prep' - only used in TT->TT generation */ +#define O_fpgm 15 /* 'fpgm' - only used in TT->TT generation */ +#define O_gsub 16 /* 'GSUB' */ +#define O_CFF 17 /* 'CFF' */ +#define NUM_TAGS 18 + struct TrueTypeFont { char *fname; sal_Int32 fsize; @@ -460,29 +481,10 @@ namespace vcl const sal_uInt8* cmap; int cmapType; sal_uInt32 (*mapper)(const sal_uInt8 *, sal_uInt32, sal_uInt32); /* character to glyphID translation function */ - const sal_uInt8 **tables; /* array of pointers to raw subtables in SFNT file */ - sal_uInt32 *tlens; /* array of table lengths */ + std::array tables; /* array of pointers to raw subtables in SFNT file */ + std::array tlens; /* array of table lengths */ }; -/* indexes into TrueTypeFont::tables[] and TrueTypeFont::tlens[] */ -#define O_maxp 0 /* 'maxp' */ -#define O_glyf 1 /* 'glyf' */ -#define O_head 2 /* 'head' */ -#define O_loca 3 /* 'loca' */ -#define O_name 4 /* 'name' */ -#define O_hhea 5 /* 'hhea' */ -#define O_hmtx 6 /* 'hmtx' */ -#define O_cmap 7 /* 'cmap' */ -#define O_vhea 8 /* 'vhea' */ -#define O_vmtx 9 /* 'vmtx' */ -#define O_OS2 10 /* 'OS/2' */ -#define O_post 11 /* 'post' */ -#define O_cvt 13 /* 'cvt_' - only used in TT->TT generation */ -#define O_prep 14 /* 'prep' - only used in TT->TT generation */ -#define O_fpgm 15 /* 'fpgm' - only used in TT->TT generation */ -#define O_gsub 16 /* 'GSUB' */ -#define O_CFF 17 /* 'CFF' */ -#define NUM_TAGS 18 } // namespace vcl diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx index 2ad41691f1ef..74fa748d0ebf 100644 --- a/vcl/source/fontsubset/sft.cxx +++ b/vcl/source/fontsubset/sft.cxx @@ -1523,11 +1523,6 @@ static SFErrCodes doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t ) return SFErrCodes::TtFormat; } - t->tables = static_cast(calloc(NUM_TAGS, sizeof(sal_uInt8 *))); - assert(t->tables != nullptr); - t->tlens = static_cast(calloc(NUM_TAGS, sizeof(sal_uInt32))); - assert(t->tlens != nullptr); - /* parse the tables */ for (i=0; i(t->ntables); i++) { int nIndex; @@ -1702,8 +1697,6 @@ void CloseTTFont(TrueTypeFont *ttf) free(ttf->subfamily); if( ttf->usubfamily ) free( ttf->usubfamily ); - free(ttf->tables); - free(ttf->tlens); free(ttf); } -- cgit v1.2.3