浏览代码

Allow command line interface to accept glyph 0 as input (#149)

Todd York 3 年之前
父节点
当前提交
3300ab6869
共有 3 个文件被更改,包括 5 次插入7 次删除
  1. 0 4
      ext/import-font.cpp
  2. 0 1
      ext/import-font.h
  3. 5 2
      main.cpp

+ 0 - 4
ext/import-font.cpp

@@ -88,10 +88,6 @@ unsigned GlyphIndex::getIndex() const {
     return index;
     return index;
 }
 }
 
 
-bool GlyphIndex::operator!() const {
-    return index == 0;
-}
-
 FreetypeHandle * initializeFreetype() {
 FreetypeHandle * initializeFreetype() {
     FreetypeHandle *handle = new FreetypeHandle;
     FreetypeHandle *handle = new FreetypeHandle;
     FT_Error error = FT_Init_FreeType(&handle->library);
     FT_Error error = FT_Init_FreeType(&handle->library);

+ 0 - 1
ext/import-font.h

@@ -17,7 +17,6 @@ class GlyphIndex {
 public:
 public:
     explicit GlyphIndex(unsigned index = 0);
     explicit GlyphIndex(unsigned index = 0);
     unsigned getIndex() const;
     unsigned getIndex() const;
-    bool operator!() const;
 
 
 private:
 private:
     unsigned index;
     unsigned index;

+ 5 - 2
main.cpp

@@ -442,6 +442,7 @@ int main(int argc, const char * const *argv) {
     const char *testRender = NULL;
     const char *testRender = NULL;
     const char *testRenderMulti = NULL;
     const char *testRenderMulti = NULL;
     bool outputSpecified = false;
     bool outputSpecified = false;
+    bool glyphIndexSpecified = false;
     GlyphIndex glyphIndex;
     GlyphIndex glyphIndex;
     unicode_t unicode = 0;
     unicode_t unicode = 0;
     int svgPathIndex = 0;
     int svgPathIndex = 0;
@@ -502,8 +503,10 @@ int main(int argc, const char * const *argv) {
             unsigned gi;
             unsigned gi;
             switch (charArg[0]) {
             switch (charArg[0]) {
                 case 'G': case 'g':
                 case 'G': case 'g':
-                    if (parseUnsignedDecOrHex(gi, charArg+1))
+                    if (parseUnsignedDecOrHex(gi, charArg+1)) {
                         glyphIndex = GlyphIndex(gi);
                         glyphIndex = GlyphIndex(gi);
+                        glyphIndexSpecified = true;
+                    }
                     break;
                     break;
                 case 'U': case 'u':
                 case 'U': case 'u':
                     ++charArg;
                     ++charArg;
@@ -838,7 +841,7 @@ int main(int argc, const char * const *argv) {
             break;
             break;
         }
         }
         case FONT: {
         case FONT: {
-            if (!glyphIndex && !unicode)
+            if (!glyphIndexSpecified && !unicode)
                 ABORT("No character specified! Use -font <file.ttf/otf> <character code>. Character code can be a Unicode index (65, 0x41), a character in apostrophes ('A'), or a glyph index prefixed by g (g36, g0x24).");
                 ABORT("No character specified! Use -font <file.ttf/otf> <character code>. Character code can be a Unicode index (65, 0x41), a character in apostrophes ('A'), or a glyph index prefixed by g (g36, g0x24).");
             FreetypeHandle *ft = initializeFreetype();
             FreetypeHandle *ft = initializeFreetype();
             if (!ft) return -1;
             if (!ft) return -1;