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

Julien Nabet (via logerrit) logerrit at kemper.freedesktop.org
Sun Oct 13 10:29:09 UTC 2019


 vcl/inc/sft.hxx                |   29 +++++++++++++++++++++++++++--
 vcl/source/fontsubset/sft.cxx  |   22 +++++++++++-----------
 vcl/source/fontsubset/ttcr.cxx |   16 ++++++++--------
 3 files changed, 46 insertions(+), 21 deletions(-)

New commits:
commit 9e4cbac83094c13ffbfd117f534d4275cc1ffb16
Author:     Julien Nabet <serval2412 at yahoo.fr>
AuthorDate: Sun Oct 13 09:37:16 2019 +0200
Commit:     Julien Nabet <serval2412 at yahoo.fr>
CommitDate: Sun Oct 13 12:28:31 2019 +0200

    Add glyf constants + remove "offset" pattern for length var (vcl)
    
    Change-Id: I35bf0cda789cbbaa5272b78b30a58fa8c4d8c08a
    Reviewed-on: https://gerrit.libreoffice.org/80726
    Tested-by: Jenkins
    Reviewed-by: Julien Nabet <serval2412 at yahoo.fr>

diff --git a/vcl/inc/sft.hxx b/vcl/inc/sft.hxx
index 39bc2ecfd421..27a5093e61e7 100644
--- a/vcl/inc/sft.hxx
+++ b/vcl/inc/sft.hxx
@@ -357,7 +357,7 @@ static const int POST_isFixedPitch_offset = 12;
 
   => length head table = 54 bytes
 */
-static const int HEAD_Length_offset = 54;
+static const int HEAD_Length = 54;
 
 static const int HEAD_majorVersion_offset = 0;
 static const int HEAD_fontRevision_offset = 4;
@@ -393,7 +393,7 @@ static const int HEAD_glyphDataFormat_offset = 52;
   ...
 
 */
-static const int MAXP_Version1Length_offset = 32;
+static const int MAXP_Version1Length = 32;
 
 static const int MAXP_numGlyphs_offset = 4;
 static const int MAXP_maxPoints_offset = 6;
@@ -401,6 +401,31 @@ static const int MAXP_maxContours_offset = 8;
 static const int MAXP_maxCompositePoints_offset = 10;
 static const int MAXP_maxCompositeContours_offset = 12;
 
+/*
+  Some table glyf consts
+  cf https://docs.microsoft.com/fr-fr/typography/opentype/spec/glyf
+  For 0.5 version
+  TYPE       NAME                       FROM BYTE
+  int16      numberOfContours           0
+  int16      xMin                       2
+  int16      yMin                       4
+  int16      xMax                       6
+  int16      yMax                       8
+
+  END                                  10
+
+  => length glyf table = 10 bytes
+
+*/
+static const int GLYF_Length = 10;
+
+static const int GLYF_numberOfContours_offset = 0;
+static const int GLYF_xMin_offset = 2;
+static const int GLYF_yMin_offset = 4;
+static const int GLYF_xMax_offset = 6;
+static const int GLYF_yMax_offset = 8;
+
+
 /**
  * @defgroup sft Sun Font Tools Exported Functions
  */
diff --git a/vcl/source/fontsubset/sft.cxx b/vcl/source/fontsubset/sft.cxx
index 9da262cf4a42..7c527887dc65 100644
--- a/vcl/source/fontsubset/sft.cxx
+++ b/vcl/source/fontsubset/sft.cxx
@@ -386,15 +386,15 @@ static int GetSimpleTTOutline(TrueTypeFont const *ttf, sal_uInt32 glyphID, Contr
     if( glyphID >= ttf->nglyphs )           /*- glyph is not present in the font */
         return 0;
     const sal_uInt8* ptr = table + ttf->goffsets[glyphID];
-    const sal_Int16 numberOfContours = GetInt16(ptr, 0);
+    const sal_Int16 numberOfContours = GetInt16(ptr, GLYF_numberOfContours_offset);
     if( numberOfContours <= 0 )             /*- glyph is not simple */
         return 0;
 
     if (metrics) {                                                    /*- GetCompoundTTOutline() calls this function with NULL metrics -*/
-        metrics->xMin = GetInt16(ptr, 2);
-        metrics->yMin = GetInt16(ptr, 4);
-        metrics->xMax = GetInt16(ptr, 6);
-        metrics->yMax = GetInt16(ptr, 8);
+        metrics->xMin = GetInt16(ptr, GLYF_xMin_offset);
+        metrics->yMin = GetInt16(ptr, GLYF_yMin_offset);
+        metrics->xMax = GetInt16(ptr, GLYF_xMax_offset);
+        metrics->yMax = GetInt16(ptr, GLYF_yMax_offset);
         GetMetrics(ttf, glyphID, metrics);
     }
 
@@ -516,14 +516,14 @@ static int GetCompoundTTOutline(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPo
         return 0;
 
     const sal_uInt8* ptr = table + ttf->goffsets[glyphID];
-    if (GetInt16(ptr, 0) != -1)   /* number of contours - glyph is not compound */
+    if (GetInt16(ptr, GLYF_numberOfContours_offset) != -1)   /* number of contours - glyph is not compound */
         return 0;
 
     if (metrics) {
-        metrics->xMin = GetInt16(ptr, 2);
-        metrics->yMin = GetInt16(ptr, 4);
-        metrics->xMax = GetInt16(ptr, 6);
-        metrics->yMax = GetInt16(ptr, 8);
+        metrics->xMin = GetInt16(ptr, GLYF_xMin_offset);
+        metrics->yMin = GetInt16(ptr, GLYF_yMin_offset);
+        metrics->xMax = GetInt16(ptr, GLYF_xMax_offset);
+        metrics->yMax = GetInt16(ptr, GLYF_yMax_offset);
         GetMetrics(ttf, glyphID, metrics);
     }
 
@@ -1639,7 +1639,7 @@ static SFErrCodes doOpenTTFont( sal_uInt32 facenum, TrueTypeFont* t )
 
     table = getTable(t, O_head);
     table_size = getTableSize(t, O_head);
-    if (table_size < HEAD_Length_offset) {
+    if (table_size < HEAD_Length) {
         return SFErrCodes::TtFormat;
     }
     t->unitsPerEm = GetUInt16(table, HEAD_unitsPerEm_offset);
diff --git a/vcl/source/fontsubset/ttcr.cxx b/vcl/source/fontsubset/ttcr.cxx
index a52f8fda08b0..f6d78ef5520c 100644
--- a/vcl/source/fontsubset/ttcr.cxx
+++ b/vcl/source/fontsubset/ttcr.cxx
@@ -303,10 +303,10 @@ SFErrCodes StreamToFile(TrueTypeCreator *_this, const char* fname)
 /*    Table         data points to
  * --------------------------------------------
  *    generic       tdata_generic struct
- *    'head'        HEAD_Length_offset bytes of memory
+ *    'head'        HEAD_Length bytes of memory
  *    'hhea'        HHEA_Length bytes of memory
  *    'loca'        tdata_loca struct
- *    'maxp'        MAXP_Version1Length_offset bytes of memory
+ *    'maxp'        MAXP_Version1Length bytes of memory
  *    'glyf'        list of GlyphData structs (defined in sft.h)
  *    'name'        list of NameRecord structs (defined in sft.h)
  *    'post'        tdata_post struct
@@ -503,7 +503,7 @@ static int GetRawData_generic(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32
 
 static int GetRawData_head(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *len, sal_uInt32 *tag)
 {
-    *len = HEAD_Length_offset;
+    *len = HEAD_Length;
     *ptr = static_cast<sal_uInt8 *>(_this->data);
     *tag = T_head;
 
@@ -538,7 +538,7 @@ static int GetRawData_loca(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *le
 
 static int GetRawData_maxp(TrueTypeTable *_this, sal_uInt8 **ptr, sal_uInt32 *len, sal_uInt32 *tag)
 {
-    *len = MAXP_Version1Length_offset;
+    *len = MAXP_Version1Length;
     *ptr = static_cast<sal_uInt8 *>(_this->data);
     *tag = T_maxp;
 
@@ -858,7 +858,7 @@ TrueTypeTable *TrueTypeTableNew_head(sal_uInt32 fontRevision,
     assert(created != nullptr);
 
     TrueTypeTable* table  = static_cast<TrueTypeTable*>(smalloc(sizeof(TrueTypeTable)));
-    sal_uInt8* ptr = ttmalloc(HEAD_Length_offset);
+    sal_uInt8* ptr = ttmalloc(HEAD_Length);
 
     PutUInt32(0x00010000, ptr, 0);             /* version */
     PutUInt32(fontRevision, ptr, 4);
@@ -925,10 +925,10 @@ TrueTypeTable *TrueTypeTableNew_loca()
 TrueTypeTable *TrueTypeTableNew_maxp( const sal_uInt8* maxp, int size)
 {
     TrueTypeTable* table = static_cast<TrueTypeTable*>(smalloc(sizeof(TrueTypeTable)));
-    table->data = ttmalloc(MAXP_Version1Length_offset);
+    table->data = ttmalloc(MAXP_Version1Length);
 
-    if (maxp && size == MAXP_Version1Length_offset) {
-        memcpy(table->data, maxp, MAXP_Version1Length_offset);
+    if (maxp && size == MAXP_Version1Length) {
+        memcpy(table->data, maxp, MAXP_Version1Length);
     }
 
     table->tag = T_maxp;


More information about the Libreoffice-commits mailing list