[Libreoffice-commits] core.git: vcl/inc vcl/source

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Mon Jun 10 06:34:10 UTC 2019


 vcl/inc/sft.hxx               |   44 +++++++++++++++++++++---------------------
 vcl/source/fontsubset/sft.cxx |    7 ------
 2 files changed, 23 insertions(+), 28 deletions(-)

New commits:
commit ec905d131374f0860bac77c52873eed984b1966f
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Sun Jun 9 19:10:35 2019 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Jun 10 08:33:30 2019 +0200

    use std::array in TrueTypeFont
    
    Change-Id: Ib19e907a9b6fcce3a3938c5dee29ff658b12e9c4
    Reviewed-on: https://gerrit.libreoffice.org/73735
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

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 <vcl/fontcapabilities.hxx>
 #include <i18nlangtag/lang.h>
 
+#include <array>
 #include <memory>
 #include <vector>
 #include <cstdint>
@@ -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<const sal_uInt8 *, NUM_TAGS> tables;                  /* array of pointers to raw subtables in SFNT file                    */
+        std::array<sal_uInt32, NUM_TAGS>  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<const sal_uInt8**>(calloc(NUM_TAGS, sizeof(sal_uInt8 *)));
-    assert(t->tables != nullptr);
-    t->tlens = static_cast<sal_uInt32*>(calloc(NUM_TAGS, sizeof(sal_uInt32)));
-    assert(t->tlens != nullptr);
-
     /* parse the tables */
     for (i=0; i<static_cast<int>(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);
 }


More information about the Libreoffice-commits mailing list