From d5fbac1d2c44a7c5241ab7db64c0868478fff796 Mon Sep 17 00:00:00 2001 From: Skef Iterum Date: Fri, 31 May 2024 00:51:19 -0700 Subject: [PATCH] (Mostly) sort through and separate "CID" font concept into distinct concepts (has a ROS, has an FDSelect). Eliminate Adobe.Identity ROS from CFF2 --- c/addfeatures/cb.cpp | 6 +- c/addfeatures/hotconv/FeatCtx.cpp | 8 +-- c/addfeatures/hotconv/cmap.cpp | 4 +- c/addfeatures/hotconv/common.h | 6 +- c/addfeatures/hotconv/glyphmetrics.cpp | 21 +++--- c/addfeatures/hotconv/glyphmetrics.h | 9 +-- c/addfeatures/hotconv/hot.cpp | 18 +++-- c/addfeatures/hotconv/map.cpp | 52 +++++++-------- c/addfeatures/hotconv/vmtx.cpp | 6 +- c/addfeatures/include/hotconv.h | 2 +- c/mergefonts/mergeFonts.cpp | 24 +++---- c/shared/absfont/absfont.cpp | 2 +- c/shared/absfont/absfont_afm.cpp | 4 +- c/shared/absfont/absfont_compare.cpp | 4 +- c/shared/absfont/absfont_draw.cpp | 4 +- c/shared/absfont/absfont_dump.cpp | 6 +- c/shared/cfembed.cpp | 8 +-- c/shared/cffread_abs.cpp | 31 ++++----- c/shared/cffwrite/cffwrite.cpp | 20 ++++-- c/shared/cffwrite/cffwrite_dict.cpp | 10 +-- c/shared/include/absfont.h | 36 ++++++---- c/shared/pdfwrite.cpp | 6 +- c/shared/svgwrite.cpp | 2 +- c/shared/t1read.cpp | 4 +- c/shared/t1write/t1write.cpp | 12 ++-- c/shared/tx_shared.cpp | 39 +++++------ c/shared/uforead.cpp | 19 +++--- c/shared/ufowrite.cpp | 10 +-- .../expected_output/CFF2-serif-sub.cff2.txt | 4 +- .../expected_output/bug437/dump-cidfont.txt | 4 +- tests/tx_data/expected_output/bug897.cff.dcf | 66 ++++++------------- .../expected_output/cid_roundtrip/testCID.txt | 4 +- .../expected_output/fdselect4.otf.dump | 21 +++--- .../fontinfo.plist | 21 ++++++ .../pfa-start-pt-with-float.ufo/groups.plist | 12 ---- 35 files changed, 247 insertions(+), 258 deletions(-) delete mode 100644 tests/tx_data/expected_output/pfa-start-pt-with-float.ufo/groups.plist diff --git a/c/addfeatures/cb.cpp b/c/addfeatures/cb.cpp index 412f1c825..e306a159e 100644 --- a/c/addfeatures/cb.cpp +++ b/c/addfeatures/cb.cpp @@ -670,7 +670,7 @@ void cbConvert(cbCtx h, int flags, const char *clientVers, const char *infile, char outpath[FILENAME_MAX + 1]; int freeFeatName = 0; unsigned long hotConvertFlags = 0; - bool isCID; + bool isROS; if (otherflags & OTHERFLAGS_DO_ID2_GSUB_CHAIN_CONXT) { hotConvertFlags |= HOT_ID2_CHAIN_CONTXT3; @@ -727,7 +727,7 @@ void cbConvert(cbCtx h, int flags, const char *clientVers, const char *infile, /* Read in font file */ sFileOpen(&h->in.file, inpath, "rb"); - FontName = hotReadFont(h->hot.ctx, flags, isCID); + FontName = hotReadFont(h->hot.ctx, flags, isROS); if (uvsFile != NULL) { hotAddUVSMap(h->hot.ctx, uvsFile); @@ -736,7 +736,7 @@ void cbConvert(cbCtx h, int flags, const char *clientVers, const char *infile, /* Determine dir that feature file's in */ h->feat.mainFile = featurefile; - if (isCID) { + if (isROS) { if (hcmapfile == NULL) { cbFatal(h, "no CMaps specified [%s]\n", inpath); } diff --git a/c/addfeatures/hotconv/FeatCtx.cpp b/c/addfeatures/hotconv/FeatCtx.cpp index c4a745924..1d159c475 100644 --- a/c/addfeatures/hotconv/FeatCtx.cpp +++ b/c/addfeatures/hotconv/FeatCtx.cpp @@ -232,7 +232,7 @@ GID FeatCtx::mapGName2GID(const char *gname, bool allowNotdef) { GID gid; const char *realname; - // if (IS_CID(g)) { + // if (IS_ROS(g)) { // zzerr("glyph name specified for a CID font"); // } if ( gname[0] == '\\' ) @@ -258,7 +258,7 @@ GID FeatCtx::mapGName2GID(const char *gname, bool allowNotdef) { GID FeatCtx::cid2gid(const std::string &cidstr) { GID gid = 0; /* Suppress optimizer warning */ - if (!IS_CID(g)) { + if (!IS_ROS(g)) { featMsg(sERROR, "CID specified for a non-CID font"); } else { int t = strtoll(cidstr.c_str() + 1, NULL, 10); /* Skip initial '\' */ @@ -416,7 +416,7 @@ void FeatCtx::addRangeToCurrentGC(GID first, GID last, const std::string &firstN const std::string &lastName) { #define INVALID_RANGE featMsg(sFATAL, "Invalid glyph range [%s-%s]", \ firstName.c_str(), lastName.c_str()) - if (IS_CID(g)) { + if (IS_ROS(g)) { if (first <= last) { for (GID i = first; i <= last; i++) { addGlyphToCurrentGC(i); @@ -514,7 +514,7 @@ bool FeatCtx::compareGlyphClassCount(int targc, int replc, bool isSubrule) { void FeatCtx::dumpGlyph(GID gid, int ch, bool print) { char msg[512]; int len; - if (IS_CID(g)) { + if (IS_ROS(g)) { len = snprintf(msg, sizeof(msg), "\\%hd", mapGID2CID(gid)); } else { mapGID2Name(g, gid, msg, sizeof(msg)); diff --git a/c/addfeatures/hotconv/cmap.cpp b/c/addfeatures/hotconv/cmap.cpp index 3f3b57252..8ef2d2ccd 100644 --- a/c/addfeatures/hotconv/cmap.cpp +++ b/c/addfeatures/hotconv/cmap.cpp @@ -280,7 +280,7 @@ void cmapBeginEncoding(hotCtx g, unsigned platformId, unsigned scriptId, h->mapping.cnt = 0; h->codespace.cnt = 0; - if (h->platformId == cmap_MAC && !IS_CID(g)) { + if (h->platformId == cmap_MAC && !IS_ROS(g)) { addMacControlChars(g, h); } } @@ -1104,7 +1104,7 @@ int cmapEndEncoding(hotCtx g) { if (h->platformId == cmap_MAC) { /* Mac cmap is required; the space wasn't present, so: */ cmapAddMapping(g, 0, GID_NOTDEF, 1); - } else if (!((IS_CID(g)) && (h->platformId == cmap_MS) && (h->scriptId == cmap_MS_UGL))) { + } else if (!((IS_ROS(g)) && (h->platformId == cmap_MS) && (h->scriptId == cmap_MS_UGL))) { /* Ms cmap is required; the space wasn't present, so: */ return 0; } diff --git a/c/addfeatures/hotconv/common.h b/c/addfeatures/hotconv/common.h index 9d4a7cb45..a1fcff249 100644 --- a/c/addfeatures/hotconv/common.h +++ b/c/addfeatures/hotconv/common.h @@ -261,7 +261,7 @@ struct FontInfo_ { /* Font information */ unsigned short flags; #define FI_MISC_FLAGS_MASK 0x01ff /* Flags from client via hotAddMiscData()*/ #define FI_FIXED_PITCH (1 << 13) /* Fixed pitch font */ -#define FI_CID (1 << 15) /* CID font */ +#define FI_ROS (1 << 15) /* ROS font */ std::string FontName; std::string Notice; std::string FamilyName; @@ -321,7 +321,7 @@ struct FontInfo_ { /* Font information */ dnaDCL(short, values); /* [nPairs] */ } kern; dnaDCL(CharName, unenc); /* Unencoded chars */ - struct { /* --- CID-specific data */ + struct { /* --- ROS-specific data */ std::string registry; std::string ordering; unsigned short supplement; @@ -332,7 +332,7 @@ struct FontInfo_ { /* Font information */ /* The Mac pollutes my namespace with FontInfo already, hence the underscore */ /* Convenience macros */ -#define IS_CID(g) ((g)->font.flags & FI_CID) +#define IS_ROS(g) ((g)->font.flags & FI_ROS) /* -------------------------------- Contexts ------------------------------- */ typedef struct mapCtx_ *mapCtx; diff --git a/c/addfeatures/hotconv/glyphmetrics.cpp b/c/addfeatures/hotconv/glyphmetrics.cpp index c86ffac02..af13cdacf 100644 --- a/c/addfeatures/hotconv/glyphmetrics.cpp +++ b/c/addfeatures/hotconv/glyphmetrics.cpp @@ -4,6 +4,9 @@ #include "glyphmetrics.h" +#include +#include + #include "common.h" std::vector &GlyphMetrics::getLocationScalars(uint32_t location) { @@ -64,20 +67,20 @@ void GlyphMetrics::beginGlyph(abfGlyphInfo *info) { getLocationScalars(0); if (hctxptr != nullptr) { auto &glyph = hctxptr->glyphs[currentGID]; - + if (info->gname.ptr != NULL) glyph.gname = info->gname.ptr; - if (IS_CID(hctxptr)) + if (IS_ROS(hctxptr)) glyph.id = info->cid; else glyph.id = info->gname.impl; // The SID (when CFF 1) - + glyph.code = info->encoding.code; abfEncoding *e = info->encoding.next; - while (e != NULL) { + while (e != NULL) { glyph.sup.push_back(e->code); e = e->next; - } + } } } for (auto l : neededLocations) { @@ -249,14 +252,14 @@ void GlyphMetrics::finishInstanceState(uint16_t gid, size_t i) { if (im.left < hctxptr->font.minBearing.left) hctxptr->font.minBearing.left = im.left; - auto hAdv = hctxptr->glyphs[gid].hAdv; + auto hAdv = hctxptr->glyphs[gid].hAdv; if (hAdv - im.right < hctxptr->font.minBearing.right) hctxptr->font.minBearing.right = hAdv - im.right; - + if (im.right > hctxptr->font.maxExtent.h) hctxptr->font.maxExtent.h = im.right; - } -} + } +} void GlyphMetrics::initialProcessingRun(hotCtx g) { neededLocations.clear(); diff --git a/c/addfeatures/hotconv/glyphmetrics.h b/c/addfeatures/hotconv/glyphmetrics.h index b4758ef72..f69591fc5 100644 --- a/c/addfeatures/hotconv/glyphmetrics.h +++ b/c/addfeatures/hotconv/glyphmetrics.h @@ -1,7 +1,8 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ +/* Copyright 2024 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. + This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -#ifndef ADDFEATURES_HOTCONV_VARMETRICS_H_ -#define ADDFEATURES_HOTCONV_VARMETRICS_H_ +#ifndef ADDFEATURES_HOTCONV_GLYPHMETRICS_H_ +#define ADDFEATURES_HOTCONV_GLYPHMETRICS_H_ #include #include @@ -95,4 +96,4 @@ class GlyphMetrics { itemVariationStore scratchIvs; }; -#endif // ADDFEATURES_HOTCONV_VARMETRICS_H_ +#endif // ADDFEATURES_HOTCONV_GLYPHMETRICS_H_ diff --git a/c/addfeatures/hotconv/hot.cpp b/c/addfeatures/hotconv/hot.cpp index c3fb8a66e..f7f272823 100644 --- a/c/addfeatures/hotconv/hot.cpp +++ b/c/addfeatures/hotconv/hot.cpp @@ -342,7 +342,7 @@ static void hotReadTables(hotCtx g) { } /* Convert PostScript font to CFF and read result */ -const char *hotReadFont(hotCtx g, int flags, bool &isCID) { +const char *hotReadFont(hotCtx g, int flags, bool &isROS) { abfTopDict *top; hotReadTables(g); @@ -366,7 +366,7 @@ const char *hotReadFont(hotCtx g, int flags, bool &isCID) { g->ctx.gm = new GlyphMetrics(g->ctx.cfr, *g->ctx.locMap, g->logger); /* Create and copy font strings */ - if ((top->sup.flags & ABF_CID_FONT) && top->cid.CIDFontName.ptr) { + if ((top->sup.flags & ABF_ROS_FONT) && top->cid.CIDFontName.ptr) { g->font.FontName = top->cid.CIDFontName.ptr; } else if (top->FDArray.cnt > 0 && top->FDArray.array[0].FontName.ptr) { // XXX what about CID? @@ -402,16 +402,14 @@ const char *hotReadFont(hotCtx g, int flags, bool &isCID) { g->font.UnderlinePosition = top->UnderlinePosition; g->font.UnderlineThickness = top->UnderlineThickness; - if (top->sup.flags & ABF_CID_FONT) { + if (top->sup.flags & ABF_ROS_FONT) { /* Copy CIDFont data */ if (top->cid.Registry.ptr) g->font.cid.registry = top->cid.Registry.ptr; if (top->cid.Ordering.ptr) g->font.cid.ordering = top->cid.Ordering.ptr; g->font.cid.supplement = top->cid.Supplement; - if (!(g->font.cid.registry == "Adobe" && - g->font.cid.ordering == "Identity")) - g->font.flags |= FI_CID; + g->font.flags |= FI_ROS; } g->font.unitsPerEm = top->sup.UnitsPerEm; @@ -435,7 +433,7 @@ const char *hotReadFont(hotCtx g, int flags, bool &isCID) { setVendId(g); - isCID = IS_CID(g); + isROS = IS_ROS(g); return g->font.FontName.c_str(); } @@ -490,7 +488,7 @@ void hotAddVertAdvanceY(hotCtx g, GID gid, VarValueRecord &vvr) { /* Check if encoded on platform; else use WinANSI */ static UV pfmChar2UV(hotCtx g, int code) { - hotGlyphInfo *gi = (IS_CID(g)) ? NULL : mapPlatEnc2Glyph(g, code); + hotGlyphInfo *gi = (IS_ROS(g)) ? NULL : mapPlatEnc2Glyph(g, code); if (gi != NULL && gi->uv != UV_UNDEF) { return gi->uv; @@ -612,7 +610,7 @@ static void prepWinData(hotCtx g) { } /* Set typo ascender/descender/linegap */ - if (IS_CID(g)) { + if (IS_ROS(g)) { if (!font->TypoAscender.isInitialized() || !font->TypoDescender.isInitialized()) { gid = mapUV2GID(g, UV_VERT_BOUNDS); if (gid != GID_UNDEF) @@ -665,7 +663,7 @@ static void prepWinData(hotCtx g) { } if (!font->TypoLineGap.isInitialized()) { - font->TypoLineGap.addValue(IS_CID(g) + font->TypoLineGap.addValue(IS_ROS(g) ? font->TypoAscender.getDefault() - font->TypoDescender.getDefault() : EM_SCALE(1200) - font->TypoAscender.getDefault() + font->TypoDescender.getDefault()); } diff --git a/c/addfeatures/hotconv/map.cpp b/c/addfeatures/hotconv/map.cpp index c2088bb48..e3cbb1d10 100644 --- a/c/addfeatures/hotconv/map.cpp +++ b/c/addfeatures/hotconv/map.cpp @@ -245,7 +245,7 @@ typedef struct { /* --------------------------- Context Definition -------------------------- */ struct mapCtx_ { - /* ---- CID ---- flagged by IS_CID(g) */ + /* ---- CID ---- flagged by IS_ROS(g) */ struct { psCtx ctx; /* PostScript parser context */ psBuf buf; /* PostScript input buffer */ @@ -369,7 +369,7 @@ hotGlyphInfo *mapCID2Glyph(hotCtx g, CID cid) { mapCtx h = g->ctx.map; hotGlyphInfo **found; - if (!IS_CID(g)) { + if (!IS_ROS(g)) { g->logger->log(sFATAL, "Not a CID font"); } found = @@ -428,7 +428,7 @@ hotGlyphInfo *mapName2Glyph(hotCtx g, const char *gname, const char **useAliasDB const char *realName = gname; hotGlyphInfo **found; - if (IS_CID(g) && useAliasDB == NULL) { + if (IS_ROS(g) && useAliasDB == NULL) { g->logger->log(sFATAL, "Not a non-CID font"); } @@ -440,7 +440,7 @@ hotGlyphInfo *mapName2Glyph(hotCtx g, const char *gname, const char **useAliasDB realName = *useAliasDB; } - if (IS_CID(g)) { + if (IS_ROS(g)) { CID cid = 0; sscanf(realName, "cid%hd", &cid); if (cid == 0) @@ -480,7 +480,7 @@ GID mapName2GID(hotCtx g, const char *gname, const char **useAliasDB) { static int mapName2UVOverrideName(hotCtx g, const char *gname, const char **uvOverrideName) { const char *uvName = NULL; - if (IS_CID(g)) { + if (IS_ROS(g)) { g->logger->log(sFATAL, "Not a non-CID font"); } @@ -574,7 +574,7 @@ GID mapWinANSI2GID(hotCtx g, int code) { hotGlyphInfo *mapPlatEnc2Glyph(hotCtx g, int code) { mapCtx h = g->ctx.map; - if (IS_CID(g)) { + if (IS_ROS(g)) { g->logger->log(sFATAL, "Not a non-CID font"); } return h->sort.platEnc[code]; @@ -1263,7 +1263,7 @@ void mapAddUVS(hotCtx g, const char *uvsName) { long lineLen = 0; UVSEntry *uvsEntry = NULL; mapCtx h = g->ctx.map; - int isCID = IS_CID(g); + int isROS = IS_ROS(g); dnaSET_CNT(h->uvs.entries, 0); g->cb.uvsOpen(g->cb.ctx, uvsName); /*jumps to fatal error if not opened successfully */ @@ -1327,7 +1327,7 @@ void mapAddUVS(hotCtx g, const char *uvsName) { glyphTag = p2 = p; p = gnameScan(g, glyphTag); if (p == NULL || !isspace(*p)) { - if (isCID) { + if (isROS) { gnameError(g, "For CID fonts, UVS file line must contain 'UV IVS; R-O-S; CID+'.", buf, "", lineno); continue; } else { @@ -2144,7 +2144,7 @@ static void makeUVScmap(hotCtx g) { uvsFlags |= UVS_IS_SUPPLEMENT; } - if (IS_CID(g)) { + if (IS_ROS(g)) { gi_id = mapCID2Glyph(g, uve->cid); if (gi_id == NULL) { g->logger->log(sWARNING, "Skipping UVS entry for CID '%d': not found in source font.", uve->cid); @@ -2215,7 +2215,7 @@ static void AFMPrintCharMetrics(hotCtx g) { mapCtx h = g->ctx.map; long i; - if (IS_CID(g)) { + if (IS_ROS(g)) { /* Print CID glyphs in CID order */ printf("StartCharMetrics %ld\n", h->sort.gname.cnt); @@ -2255,7 +2255,7 @@ static void AFMPrintCharMetrics(hotCtx g) { hotGlyphInfo *gi = afmchar->gi; printf("C %d ; WX %hd ; ", afmchar->code, gi->hAdv); - if (IS_CID(g)) { + if (IS_ROS(g)) { printf("N %hu ; ", gi->id); } else { printf("N %s ; ", gi->gname.c_str()); @@ -2301,7 +2301,7 @@ static void AFMPrintKernData(hotCtx g) { if (nPairs == 0) { return; - } else if (IS_CID(g)) { + } else if (IS_ROS(g)) { g->logger->log(sWARNING, "can't print AFM KernData for CID"); return; } @@ -2355,7 +2355,7 @@ void mapPrintAFM(hotCtx g) { printf("FontBBox %hd %hd %hd %hd\n", g->font.bbox.left, g->font.bbox.bottom, g->font.bbox.right, g->font.bbox.top); - if (IS_CID(g)) { + if (IS_ROS(g)) { printf("CharacterSet %s-%s-%hu\n", g->font.cid.registry.c_str(), g->font.cid.ordering.c_str(), g->font.cid.supplement); } @@ -2396,7 +2396,7 @@ static void dbgPrintInfo(hotCtx g) { uint32_t nGlyphs = g->glyphs.size(); #define SUBSET_MAX 1000 /* Heuristic for printing */ - if (!IS_CID(g)) { + if (!IS_ROS(g)) { fprintf(stderr, "dfCharSet = %02x (%d)\n", g->font.win.CharSet, g->font.win.CharSet); } @@ -2415,7 +2415,7 @@ static void dbgPrintInfo(hotCtx g) { /* dbgUniBlock(g); */ - if (IS_CID(h->g)) { + if (IS_ROS(h->g)) { fprintf(stderr, "------------------------------\n" "gid cid uv ... %s" @@ -2518,7 +2518,7 @@ static void CTL_CDECL dbgUse(int arg, ...) { int mapFill(hotCtx g) { mapCtx h = g->ctx.map; - if (IS_CID(g) && h->cid.hor.name == SINX_UNDEF) { + if (IS_ROS(g) && h->cid.hor.name == SINX_UNDEF) { g->logger->log(sFATAL, "H Unicode CMap not seen"); } @@ -2526,7 +2526,7 @@ int mapFill(hotCtx g) { makeUnicodecmaps(g); setOS_2Fields(g); - if (IS_CID(g)) { + if (IS_ROS(g)) { makeCIDMaccmap(g); /* will make a Mac cmap with only a not def, if Macintosh Adobe CMap is not provided.*/ if (h->cid.mac.name == SINX_UNDEF) { g->logger->log(sWARNING, "Macintosh Adobe CMap not seen"); @@ -2559,7 +2559,7 @@ static void initGlyphs(hotCtx g) { dnaSET_CNT(h->sort.gname, nGlyphs); /* Includes .notdef/CID 0 */ - if (!IS_CID(g)) { + if (!IS_ROS(g)) { for (i = 0; i < 256; i++) { h->sort.platEnc[i] = NULL; } @@ -2572,7 +2572,7 @@ static void initGlyphs(hotCtx g) { gi->uv = UV_UNDEF; h->sort.gname.array[i] = gi; /* Init sort ptrs to array elements */ - if (!IS_CID(g)) { + if (!IS_ROS(g)) { if (gi->code != ABF_GLYPH_UNENC) { h->sort.platEnc[gi->code] = gi; /* PS encoding */ for (auto code : gi->sup) { @@ -2582,7 +2582,7 @@ static void initGlyphs(hotCtx g) { } } - if (!IS_CID(g)) { + if (!IS_ROS(g)) { /* Store gnames as char * instead of SInx */ for (i = 0; i < nGlyphs; i++) { const char *srcName; @@ -2596,11 +2596,11 @@ static void initGlyphs(hotCtx g) { /* Sort by glyph name/CID */ qsort(h->sort.gname.array, h->sort.gname.cnt, sizeof(hotGlyphInfo *), - IS_CID(g) ? cmpCID : cmpGlyphName); + IS_ROS(g) ? cmpCID : cmpGlyphName); /* Make custom cmap, if applicable */ /* - if (!IS_CID(g) && g->font.Encoding != FI_STD_ENC) + if (!IS_ROS(g) && g->font.Encoding != FI_STD_ENC) makeCustomcmap(g); */ } @@ -2608,7 +2608,7 @@ static void initGlyphs(hotCtx g) { /* Initialize both CID and non-CID fonts */ static void mapInit(hotCtx g) { initGlyphs(g); - if (!IS_CID(g)) { + if (!IS_ROS(g)) { assignUVs(g); setCodePages(g); } @@ -2626,7 +2626,7 @@ void mapApplyReencoding(hotCtx g, hotEncoding *comEncoding, hotEncoding *reenc = NULL; int i; - if (IS_CID(g)) { + if (IS_ROS(g)) { return; } @@ -2667,7 +2667,7 @@ void mapReuse(hotCtx g) { unicodeBlock[i].numFound = unicodeBlock[i].isSupported = 0; } - if (IS_CID(g)) { + if (IS_ROS(g)) { h->ps.buf.cnt = 0; h->cid.hor.range.cnt = 0; h->cid.ver.map.cnt = 0; @@ -2702,7 +2702,7 @@ void mapFree(hotCtx g) { mapCtx h = g->ctx.map; /* Free da's, context */ - if (IS_CID(g)) { + if (IS_ROS(g)) { dnaFREE(h->ps.buf); dnaFREE(h->cid.hor.range); dnaFREE(h->cid.ver.map); diff --git a/c/addfeatures/hotconv/vmtx.cpp b/c/addfeatures/hotconv/vmtx.cpp index 4caeb39c6..0c8ea9ce1 100644 --- a/c/addfeatures/hotconv/vmtx.cpp +++ b/c/addfeatures/hotconv/vmtx.cpp @@ -21,7 +21,7 @@ int vmtxFill(hotCtx g) { auto &vmtx = *g->ctx.vmtx; - if ((!(g->convertFlags & HOT_SEEN_VERT_ORIGIN_OVERRIDE)) && (!IS_CID(g))) + if ((!(g->convertFlags & HOT_SEEN_VERT_ORIGIN_OVERRIDE)) && (!IS_ROS(g))) return vmtx.Fill(); uint32_t glyphCount = g->glyphs.size(); @@ -76,7 +76,7 @@ void vheaNew(hotCtx g) { } int vheaFill(hotCtx g) { if (g->ctx.vmtx == nullptr) { - if ((g->convertFlags & HOT_SEEN_VERT_ORIGIN_OVERRIDE) || IS_CID(g)) + if ((g->convertFlags & HOT_SEEN_VERT_ORIGIN_OVERRIDE) || IS_ROS(g)) g->ctx.vmtx = new var_vmtx(); else return 0; @@ -117,7 +117,7 @@ void vheaFree(hotCtx g) { } void VORGNew(hotCtx g) { } int VORGFill(hotCtx g) { - if ((!(g->convertFlags & HOT_SEEN_VERT_ORIGIN_OVERRIDE)) && (!IS_CID(g))) { + if ((!(g->convertFlags & HOT_SEEN_VERT_ORIGIN_OVERRIDE)) && (!IS_ROS(g))) { if (g->ctx.vmtx == nullptr) return 0; else diff --git a/c/addfeatures/include/hotconv.h b/c/addfeatures/include/hotconv.h index f1797b80c..174180dc9 100644 --- a/c/addfeatures/include/hotconv.h +++ b/c/addfeatures/include/hotconv.h @@ -221,7 +221,7 @@ struct hotCallbacks_ { void hotSetConvertFlags(hotCtx g, unsigned long hotConvFlags); // set flags before any hot unctions are called. -const char *hotReadFont(hotCtx g, int flags, bool &isCID); +const char *hotReadFont(hotCtx g, int flags, bool &isROS); /* hotReadFont() is called to read the input font. The flags argument debugging and font processing: */ diff --git a/c/mergefonts/mergeFonts.cpp b/c/mergefonts/mergeFonts.cpp index 53cb2ba62..c311f9b21 100644 --- a/c/mergefonts/mergeFonts.cpp +++ b/c/mergefonts/mergeFonts.cpp @@ -136,7 +136,7 @@ static bool applyCIDFontInfo(txCtx h, bool fontisCID) { MergeInfo *mergeInfo = (MergeInfo *)h->ext->extData; if (mergeInfo->cidinfo.CIDFontName[0] != 0) { // if the users has specified a cidfontinfo file, override the first font's cid info. fontisCID = 1; - h->top->sup.flags |= ABF_CID_FONT; + h->top->sup.flags |= ABF_ROS_FONT; h->top->cid.CIDFontName.ptr = mergeInfo->cidinfo.CIDFontName; h->top->FullName.ptr = mergeInfo->cidinfo.FullName; h->top->FamilyName.ptr = mergeInfo->cidinfo.FamilyName; @@ -296,7 +296,7 @@ static void t1rMergeFont(txCtx h, long origin, bool isFirstFont, sourceCtx *srcC if (t1rBegFont(h->t1r.ctx, h->t1r.flags, origin, &h->top, getUDV(h))) fatal(h, NULL); - parentIsCID = h->top->sup.flags & ABF_CID_FONT; + parentIsCID = h->top->sup.flags & ABF_ROS_FONT; if (mergeInfo->hintsOnly && parentIsCID) fatal(h, "Error. The -hints option cannot be used with CID fonts."); @@ -342,7 +342,7 @@ static void t1rMergeFont(txCtx h, long origin, bool isFirstFont, sourceCtx *srcC t1rCtx local_t1r_ctx; abfTopDict *local_top = NULL; bool localFontIsCID = 0; - parentIsCID = h->top->sup.flags & ABF_CID_FONT; + parentIsCID = h->top->sup.flags & ABF_ROS_FONT; local_t1r_ctx = t1rNew(&h->cb.mem, &h->cb.stm, T1R_CHECK_ARGS); @@ -361,7 +361,7 @@ static void t1rMergeFont(txCtx h, long origin, bool isFirstFont, sourceCtx *srcC if (t1rBegFont(local_t1r_ctx, h->t1r.flags, origin, &local_top, getUDV(h))) fatal(h, NULL); - localFontIsCID = local_top->sup.flags & ABF_CID_FONT; + localFontIsCID = local_top->sup.flags & ABF_ROS_FONT; if (mergeInfo->hintsOnly) { int k; if (fileIndex > 1) @@ -416,7 +416,7 @@ static void svrMergeFont(txCtx h, long origin, bool isFirstFont, sourceCtx *srcC else { svrCtx local_svr_ctx; abfTopDict *local_top = NULL; - bool parentIsCID = h->top->sup.flags & ABF_CID_FONT; + bool parentIsCID = h->top->sup.flags & ABF_ROS_FONT; bool localFontIsCID = 0; MergeInfo *mergeInfo = (MergeInfo *)h->ext->extData; @@ -433,7 +433,7 @@ static void svrMergeFont(txCtx h, long origin, bool isFirstFont, sourceCtx *srcC if (svrBegFont(local_svr_ctx, h->svr.flags, &local_top)) fatal(h, NULL); - localFontIsCID = local_top->sup.flags & ABF_CID_FONT; + localFontIsCID = local_top->sup.flags & ABF_ROS_FONT; /* If there is a glyph alias file for the first font, make sure it is the right type, or that both fonts are name keyed or CID. */ gaf = checkIFParentCIDCompatible(h, local_top, parentIsCID, localFontIsCID); @@ -493,7 +493,7 @@ static void ufoMergeFont(txCtx h, long origin, bool isFirstFont, sourceCtx *srcC if (ufoBegFont(h->ufr.ctx, h->ufr.flags, &h->top, h->ufr.altLayerDir)) fatal(h, NULL); - parentIsCID = h->top->sup.flags & ABF_CID_FONT; + parentIsCID = h->top->sup.flags & ABF_ROS_FONT; /* Apply the CIDFontInfo file, if one was specified. */ parentIsCID = applyCIDFontInfo(h, parentIsCID); /* can set parentIsCID true, if it was false */ @@ -533,7 +533,7 @@ static void ufoMergeFont(txCtx h, long origin, bool isFirstFont, sourceCtx *srcC } else { ufoCtx local_ufr_ctx; abfTopDict *local_top = NULL; - bool parentIsCID = h->top->sup.flags & ABF_CID_FONT; + bool parentIsCID = h->top->sup.flags & ABF_ROS_FONT; bool localFontIsCID; local_ufr_ctx = ufoNew(&h->cb.mem, &h->cb.stm, UFO_CHECK_ARGS); @@ -548,7 +548,7 @@ static void ufoMergeFont(txCtx h, long origin, bool isFirstFont, sourceCtx *srcC if (ufoBegFont(local_ufr_ctx, h->ufr.flags, &local_top, h->ufr.altLayerDir)) fatal(h, NULL); - localFontIsCID = local_top->sup.flags & ABF_CID_FONT; + localFontIsCID = local_top->sup.flags & ABF_ROS_FONT; /* If there is a glyph alias file for the first font, make sure it is the right type, or that both fonts are name keyed or CID. */ gaf = checkIFParentCIDCompatible(h, local_top, parentIsCID, localFontIsCID); @@ -616,7 +616,7 @@ static void cfrMergeFont(txCtx h, long origin, bool isFirstFont, sourceCtx *srcC if (cfrBegFont(h->cfr.ctx, h->cfr.flags, origin, 0, &h->top, NULL)) fatal(h, NULL); - parentIsCID = h->top->sup.flags & ABF_CID_FONT; + parentIsCID = h->top->sup.flags & ABF_ROS_FONT; /* Apply the CIDFontInfo file, if one was specified. */ parentIsCID = applyCIDFontInfo(h, parentIsCID); /* can set parentIsCID true, if it was false */ @@ -656,7 +656,7 @@ static void cfrMergeFont(txCtx h, long origin, bool isFirstFont, sourceCtx *srcC abfTopDict *local_top = NULL; bool localFontIsCID = 0; - parentIsCID = h->top->sup.flags & ABF_CID_FONT; + parentIsCID = h->top->sup.flags & ABF_ROS_FONT; local_cfr_ctx = cfrNew(&h->cb.mem, &h->cb.stm, CFR_CHECK_ARGS); if (local_cfr_ctx == NULL) fatal(h, "(cfr) can't init lib"); @@ -670,7 +670,7 @@ static void cfrMergeFont(txCtx h, long origin, bool isFirstFont, sourceCtx *srcC if (cfrBegFont(local_cfr_ctx, h->cfr.flags, origin, 0, &local_top, NULL)) fatal(h, NULL); - localFontIsCID = local_top->sup.flags & ABF_CID_FONT; + localFontIsCID = local_top->sup.flags & ABF_ROS_FONT; /* provide data for mergeGlyphBegin function, which is patched over the &h->cb.glyph.beg() function ptr */ diff --git a/c/shared/absfont/absfont.cpp b/c/shared/absfont/absfont.cpp index 6257c383d..29dea6c0f 100644 --- a/c/shared/absfont/absfont.cpp +++ b/c/shared/absfont/absfont.cpp @@ -155,7 +155,7 @@ static void checkTopDict(abfErrCallbacks *cb, abfTopDict *top) { /* Check UniqueID ranges */ checkUniqueID(cb, top->UniqueID, abfErrBadUniqueID); - if (top->sup.flags & ABF_CID_FONT) + if (top->sup.flags & ABF_ROS_FONT) checkUniqueID(cb, top->cid.UIDBase, abfErrBadUIDBase); /* Check UnderlinePosition and UnderlineThickness */ diff --git a/c/shared/absfont/absfont_afm.cpp b/c/shared/absfont/absfont_afm.cpp index 8361dc619..4a05b78bc 100644 --- a/c/shared/absfont/absfont_afm.cpp +++ b/c/shared/absfont/absfont_afm.cpp @@ -42,7 +42,7 @@ void abfAFMEndFont(abfAFMCtx h, abfTopDict *top) { top->FontBBox[2] = (float)h->font_bbox.right; top->FontBBox[3] = (float)h->font_bbox.top; - if (top->sup.flags & ABF_CID_FONT) + if (top->sup.flags & ABF_ROS_FONT) fprintf(h->fp, "StartFontMetrics 4.1\n"); else fprintf(h->fp, "StartFontMetrics 2.0\n"); @@ -59,7 +59,7 @@ void abfAFMEndFont(abfAFMCtx h, abfTopDict *top) { if (top->sup.UnitsPerEm != 1000) fprintf(h->fp, "Comment UnitsPerEm %ld\n", top->sup.UnitsPerEm); - if (top->sup.flags & ABF_CID_FONT) { + if (top->sup.flags & ABF_ROS_FONT) { /* Write header for cid-keyed font */ fprintf(h->fp, "MetricsSets 2\n"); writeString(h, "FontName", &top->cid.CIDFontName); diff --git a/c/shared/absfont/absfont_compare.cpp b/c/shared/absfont/absfont_compare.cpp index e31e22332..79a0359f6 100644 --- a/c/shared/absfont/absfont_compare.cpp +++ b/c/shared/absfont/absfont_compare.cpp @@ -126,8 +126,8 @@ static int comparePrivateDicts(const abfPrivateDict *private1, /* Compare two top dicts to see if they are similar enough to merge. Assume client has assured that they are valid before call. */ int abfCompareTopDicts(const abfTopDict *top1, const abfTopDict *top2) { - int firstIsCID = (top1->sup.flags & ABF_CID_FONT) != 0; - int secondIsCID = (top2->sup.flags & ABF_CID_FONT) != 0; + int firstIsCID = (top1->sup.flags & ABF_ROS_FONT) != 0; + int secondIsCID = (top2->sup.flags & ABF_ROS_FONT) != 0; if (firstIsCID != secondIsCID) return 1; diff --git a/c/shared/absfont/absfont_draw.cpp b/c/shared/absfont/absfont_draw.cpp index c786d4d15..9f63977e4 100644 --- a/c/shared/absfont/absfont_draw.cpp +++ b/c/shared/absfont/absfont_draw.cpp @@ -88,7 +88,7 @@ static void pageBeg(abfDrawCtx h, abfGlyphInfo *info) { float y; const char *fontname; - if (h->top->sup.flags & ABF_CID_FONT) + if (h->top->sup.flags & ABF_ROS_FONT) fontname = h->top->cid.CIDFontName.ptr; else fontname = h->top->FDArray.array[0].FontName.ptr; @@ -148,7 +148,7 @@ static void pageBeg(abfDrawCtx h, abfGlyphInfo *info) { fprintf(h->fp, "/%s findfont %g scalefont setfont\n", TILE_TEXT_FONT, TILE_TEXT_SIZE); - if (info->flags & ABF_CID_FONT) + if (info->flags & ABF_ROS_FONT) drawTile(h, (TILE_COLS - 3) * TILE_SIZE, PAGE_TOP, "tag,fd", "hAdv", "cid"); else diff --git a/c/shared/absfont/absfont_dump.cpp b/c/shared/absfont/absfont_dump.cpp index 352ec0a43..8ab6c68d6 100644 --- a/c/shared/absfont/absfont_dump.cpp +++ b/c/shared/absfont/absfont_dump.cpp @@ -196,8 +196,8 @@ static void dumpTopDict(abfDumpCtx h, abfTopDict *top) { FPRINTF_S(h->fp, "%sABF_SYN_FONT", sep); sep = ","; } - if (top->sup.flags & ABF_CID_FONT) { - FPRINTF_S(h->fp, "%sABF_CID_FONT", sep); + if (top->sup.flags & ABF_ROS_FONT) { + FPRINTF_S(h->fp, "%sABF_ROS_FONT", sep); sep = ","; } if (sep[0] == ',') @@ -345,7 +345,7 @@ void abfDumpBegFont(abfDumpCtx h, abfTopDict *top) { } /* Print glyph comment */ - if (top->sup.flags & ABF_CID_FONT) + if (top->sup.flags & ABF_ROS_FONT) /* UFO can store names even when CID-keyed */ if (top->sup.srcFontType == abfSrcFontTypeUFOCID) { FPRINTF_S(h->fp, "## glyph[tag] {name,cid,iFD"); diff --git a/c/shared/cfembed.cpp b/c/shared/cfembed.cpp index dd52a9544..e864d5014 100644 --- a/c/shared/cfembed.cpp +++ b/c/shared/cfembed.cpp @@ -1194,7 +1194,7 @@ static void t1Parse(cefCtx h) { T1R_UPDATE_OPS, h->src.origin, &h->top, h->spec->UDV)) fatal(h, cefErrT1Parse); - if (h->top->sup.flags & ABF_CID_FONT) { + if (h->top->sup.flags & ABF_ROS_FONT) { /* CID font; check name override */ if (h->spec->newFontName != NULL) h->top->cid.CIDFontName.ptr = h->spec->newFontName; @@ -1239,7 +1239,7 @@ static void cffParse(cefCtx h) { if (cfrBegFont(h->ctx.cfr, CFR_UPDATE_OPS, h->src.origin, 0, &h->top, NULL)) fatal(h, cefErrCFFParse); - if (h->top->sup.flags & ABF_CID_FONT) { + if (h->top->sup.flags & ABF_ROS_FONT) { /* CID font; check name override */ if (h->spec->newFontName != NULL) h->top->cid.CIDFontName.ptr = h->spec->newFontName; @@ -1312,7 +1312,7 @@ static void glyphmap(cfwMapCallback *cb, if (h->spec->subset.names == NULL) { /* Match cid or tag to subset id */ unsigned short key = - (info->flags & ABF_CID_FONT) ? info->cid : info->tag; + (info->flags & ABF_ROS_FONT) ? info->cid : info->tag; map = (GlyphMap *)bsearch(&key, h->subset.array, h->subset.cnt, sizeof(GlyphMap), matchId); } else @@ -1848,7 +1848,7 @@ static int svg_GlyphBeg(abfGlyphCallbacks *cb, abfGlyphInfo *info) { if (h->spec->subset.names == NULL) { /* Match cid or tag to subset id */ unsigned short key = - (info->flags & ABF_CID_FONT) ? info->cid : info->tag; + (info->flags & ABF_ROS_FONT) ? info->cid : info->tag; map = (GlyphMap *)bsearch(&key, h->subset.array, h->subset.cnt, sizeof(GlyphMap), matchId); } else diff --git a/c/shared/cffread_abs.cpp b/c/shared/cffread_abs.cpp index 48bc4f127..fcd6c3a30 100644 --- a/c/shared/cffread_abs.cpp +++ b/c/shared/cffread_abs.cpp @@ -110,7 +110,7 @@ typedef struct { // post table struct cfrCtx_ { // Context long flags; /* Status flags */ -#define CID_FONT (1UL << 31) /* CID Font */ +#define ROS_FONT (1UL << 31) /* CID-keyed Font */ #define FREE_ENCODINGS (1UL << 30) /* Return encoding nodes to free list */ #define CFR_SEEN_BLEND (1 << 29) #define CFR_IS_CFF2 (1 << 28) @@ -621,7 +621,7 @@ static void saveMatrix(cfrCtx h, int topdict) { array[4] = INDEX_REAL(4); array[5] = INDEX_REAL(5); - if (topdict && h->flags & CID_FONT) { + if (topdict && h->flags & ROS_FONT) { /* Top-level CIDFont matrix */ if (array[0] != 1.0 || array[1] != 0.0 || @@ -1273,9 +1273,7 @@ static void readDICT(cfrCtx h, ctlRegion *region, int topdict) { top->cid.Registry.ptr = sid2str(h, (SID)INDEX_INT(0)); top->cid.Ordering.ptr = sid2str(h, (SID)INDEX_INT(1)); top->cid.Supplement = INDEX_INT(2); - if (!(strcmp(top->cid.Registry.ptr, "Adobe") == 0 && - strcmp(top->cid.Ordering.ptr, "Identity") == 0)) - h->flags |= CID_FONT; + h->flags |= ROS_FONT; break; case cff_CIDFontVersion: CHKUFLOW(1); @@ -1825,7 +1823,7 @@ static void addID(cfrCtx h, long gid, unsigned short id) { if (gid >= h->glyphs.cnt) fatal(h, cfrErrNoGlyph); info = &h->glyphs.array[gid]; - if (h->flags & CID_FONT) + if (h->flags & ROS_FONT) /* Save CID */ info->cid = id; else { @@ -1940,7 +1938,7 @@ static void postRead(cfrCtx h) { h->post.minMemType1 = read4(h); h->post.maxMemType1 = read4(h); - if (h->flags & CID_FONT) + if (h->flags & ROS_FONT) return; /* Don't read glyph names for CID fonts */ if (h->post.format != 0x00020000) { @@ -2121,7 +2119,7 @@ static void readCharset(cfrCtx h) { postRead(h); if (h->cff2.mvar) MVARread(h); - if (!(h->flags & CID_FONT)) + if (!(h->flags & ROS_FONT)) readCharSetFromPost(h); else { long gid; @@ -2335,7 +2333,7 @@ static void readFDSelect(cfrCtx h) { uint32_t gid; if (h->region.FDSelect.begin == -1) - fatal(h, cfrErrNoFDSelect); + return; srcSeek(h, h->region.FDSelect.begin); switch (read1(h)) { @@ -2579,7 +2577,7 @@ static void makeupCFF2Info(cfrCtx h) { addString(h, &strPtrs, &h->fdicts.array[0].FontName, str.c_str()); /* Load CIDFontName from name table and make up CID font ROS */ - if (h->flags & CID_FONT) { + if (h->flags & ROS_FONT) { str = h->cff2.name->getASCIIName(nam_name::NAME_ID_CIDFONTNAME, 1); if (str.size() == 0) str = h->cff2.name->getASCIIName(nam_name::NAME_ID_POSTSCRIPT, 1); @@ -2778,7 +2776,7 @@ int cfrBegFont(cfrCtx h, long flags, long origin, int ttcIndex, abfTopDict **top } gi_flags = 0; - if (h->flags & CID_FONT) { + if (h->flags & ROS_FONT) { if (!(flags & CFR_SHALLOW_READ)) readFDArray(h); if (h->header.major == 1) @@ -2786,7 +2784,7 @@ int cfrBegFont(cfrCtx h, long flags, long origin, int ttcIndex, abfTopDict **top else makeupCFF2Info(h); h->top.sup.srcFontType = abfSrcFontTypeCFFCID; - h->top.sup.flags |= ABF_CID_FONT; + h->top.sup.flags |= ABF_ROS_FONT; gi_flags |= ABF_GLYPH_CID; } else { if (h->header.major == 1) { @@ -2819,9 +2817,8 @@ int cfrBegFont(cfrCtx h, long flags, long origin, int ttcIndex, abfTopDict **top /* Fill glyphs array */ if (!(flags & CFR_SHALLOW_READ)) { readCharset(h); - if (h->flags & CID_FONT) { - readFDSelect(h); - + readFDSelect(h); + if (h->flags & ROS_FONT) { /* Mark LanguageGroup 1 glyphs */ for (i = 0; i < h->glyphs.cnt; i++) { abfGlyphInfo *info = &h->glyphs.array[i]; @@ -2960,7 +2957,7 @@ static int CTL_CDECL matchName(const void *key, const void *value, void *ctx) { int cfrGetGlyphByName(cfrCtx h, const char *gname, abfGlyphCallbacks *glyph_cb) { size_t index; - if (h->flags & CID_FONT) + if (h->flags & ROS_FONT) return cfrErrNoGlyph; if (h->glyphsByName.cnt == 0) { @@ -3020,7 +3017,7 @@ int cfrGetGlyphByCID(cfrCtx h, unsigned short cid, abfGlyphCallbacks *glyph_cb) volatile unsigned short gid; /* volatile suppresses optimizer warning */ size_t index; - if (!(h->flags & CID_FONT)) + if (!(h->flags & ROS_FONT)) return cfrErrNoGlyph; if (h->glyphs.array[h->glyphs.cnt - 1].cid == h->glyphs.cnt - 1) { diff --git a/c/shared/cffwrite/cffwrite.cpp b/c/shared/cffwrite/cffwrite.cpp index 9c42e4eea..a4d03ccbc 100644 --- a/c/shared/cffwrite/cffwrite.cpp +++ b/c/shared/cffwrite/cffwrite.cpp @@ -525,7 +525,7 @@ void cfwAddGlyph(cfwCtx g, SeenGlyph *seenGlyph = NULL; long index = 0; - if (info->flags & ABF_CID_FONT) { + if (info->flags & ABF_GLYPH_CID) { /* CID-keyed font */ if (info->cid == 0) { /* Force CID 0 to GID 0 */ @@ -1683,16 +1683,23 @@ static void orderNameKeyedGlyphs(controlCtx h) { } } cfwCharsetBeg(g, 0); + if (h->_new->FDArray.cnt > 1) + cfwFdselectBeg(g); if (!predef) { cfwEncodingBeg(g); } + if (h->_new->FDArray.cnt > 1 && has_notdef) + cfwFdselectAddIndex(g, glyphs[0].iFD); for (i = 1; i < nGlyphs; i++) { abfGlyphInfo *info = glyphs[i].info; abfString *gname = &info->gname; /* Add glyph to charset */ cfwCharsetAddGlyph(g, (uint16_t)gname->impl); + if (h->_new->FDArray.cnt > 1) + cfwFdselectAddIndex(g, info->iFD); + if (!predef) { abfEncoding *enc = &info->encoding; @@ -1708,10 +1715,14 @@ static void orderNameKeyedGlyphs(controlCtx h) { } h->_new->iObject.charset = cfwCharsetEnd(g); + if (h->_new->FDArray.cnt > 1) + h->_new->iObject.FDSelect = cfwFdselectEnd(g); + else + h->_new->iObject.FDSelect = 0; + if (!predef) { h->_new->iObject.Encoding = cfwEncodingEnd(g); } - h->_new->iObject.FDSelect = 0; } /* Assign the default and nominal widths (see comment at head of file). */ @@ -1890,7 +1901,7 @@ int cfwEndFont(cfwCtx g, abfTopDict *top) { /* Set font-wide flags */ h->_new->flags = 0; - if (top->sup.flags & ABF_CID_FONT) { + if (top->sup.flags & ABF_ROS_FONT) { /* Validate CID data */ if (cfwSindexInvalidString(top->cid.Registry.ptr) || cfwSindexInvalidString(top->cid.Ordering.ptr) || @@ -1910,9 +1921,6 @@ int cfwEndFont(cfwCtx g, abfTopDict *top) { if (h->flags & SEEN_CID_KEYED_GLYPH) { return cfwErrGlyphType; } - if (top->FDArray.cnt != 1) { - return cfwErrBadFDArray; - } if (top->sup.flags & ABF_SYN_FONT) { h->_new->flags |= FONT_SYN; diff --git a/c/shared/cffwrite/cffwrite_dict.cpp b/c/shared/cffwrite/cffwrite_dict.cpp index f7cd69123..3c312c2d7 100644 --- a/c/shared/cffwrite/cffwrite_dict.cpp +++ b/c/shared/cffwrite/cffwrite_dict.cpp @@ -119,7 +119,7 @@ static void saveOrigFontType(cfwCtx g, abfTopDict *dst) { switch (dst->sup.srcFontType) { case abfSrcFontTypeType1Name: case abfSrcFontTypeCFFName: - if (!(dst->sup.flags & ABF_CID_FONT)) { + if (!(dst->sup.flags & ABF_ROS_FONT)) { return; /* Nothing to save */ } OrigFontType = "Type1"; /* Name-keyed to cid-keyed conversion */ @@ -127,7 +127,7 @@ static void saveOrigFontType(cfwCtx g, abfTopDict *dst) { case abfSrcFontTypeType1CID: case abfSrcFontTypeCFFCID: - if (dst->sup.flags & ABF_CID_FONT) { + if (dst->sup.flags & ABF_ROS_FONT) { return; /* Nothing to save */ } OrigFontType = "CID"; /* CID-keyed to name-keyed conversion */ @@ -478,7 +478,7 @@ void cfwDictFillTop(cfwCtx g, DICT *dst, return; } - if (top->sup.flags & ABF_CID_FONT) { + if (top->sup.flags & ABF_ROS_FONT) { /* FontMatrix; note default values are different from font dict */ abfFontMatrix *fm = &(top->cid.FontMatrix); if (fm->cnt != ABF_EMPTY_ARRAY && @@ -515,7 +515,7 @@ void cfwDictFillTop(cfwCtx g, DICT *dst, } /* ROS */ - if (top->sup.flags & ABF_CID_FONT) { + if (top->sup.flags & ABF_ROS_FONT) { cfwDictSaveInt(dst, cfwSindexAssignSID(g, (SRI)top->cid.Registry.impl)); cfwDictSaveInt(dst, @@ -618,7 +618,7 @@ void cfwDictFillTop(cfwCtx g, DICT *dst, cfwDictSaveRealOp(dst, top->StrokeWidth, cff_StrokeWidth); } - if (top->sup.flags & ABF_CID_FONT) { + if (top->sup.flags & ABF_ROS_FONT) { /* CIDFontVersion */ if (top->cid.CIDFontVersion != cff_DFLT_CIDFontVersion) { cfwDictSaveRealOp(dst, top->cid.CIDFontVersion, cff_CIDFontVersion); diff --git a/c/shared/include/absfont.h b/c/shared/include/absfont.h index 9a95eecfb..32d4c3bf7 100644 --- a/c/shared/include/absfont.h +++ b/c/shared/include/absfont.h @@ -68,7 +68,7 @@ enum { // srcFontType values typedef struct { long flags; /* 0 */ -#define ABF_CID_FONT (1 << 0) /* CID-keyed font */ +#define ABF_ROS_FONT (1 << 0) /* Font contains ROS */ #define ABF_SYN_FONT (1 << 1) /* Synthetic font */ #define ABF_SING_FONT (1 << 2) /* SING glyphlet font */ long srcFontType; /* ABF_UNSET_INT */ @@ -86,8 +86,8 @@ typedef struct { clients shouldn't rely on these values but are free to use these fields as they see fit. - CID-keyed fonts are indicated by setting the ABF_CID_FONT flag bit to 1 - and specifying CID-specific data via the abfTopDict.cid fields. + CID-keyed fonts are indicated by setting the ABF_ROS_FONT flag bit to 1 + and specifying the data via the abfTopDict.cid fields. Synthetic fonts are indicated by setting the ABF_SYN_FONT flag bit to 1 and the SynBaseFontName field records the FontName of the font that the @@ -243,6 +243,18 @@ struct abfFontDict_ { PostScript name-keyed C-struct name-keyed --------------------- ------------------- font dict abfTopDict fields (excluding cid fields) + + PostScript CID-keyed C-struct CID-keyed + -------------------- ------------------ + CIDFont dict abfTopDict fields (including cid fields) + + CID fonts always have FDArray and FDSelect structures, but as of + CFF2 non-CID fonts have these as well. When there is a single + private dictionary it is represnted as FDArray[0] with no FDSelect. + Otherwise there is an FDSelect and multiple FDArray entries: + + PostScript name-keyed C-struct name-keyed + --------------------- ------------------- FDArray[0].FontName FDArray[0].PaintType FDArray[0].FontMatrix @@ -250,7 +262,6 @@ struct abfFontDict_ { PostScript CID-keyed C-struct CID-keyed -------------------- ------------------ - CIDFont dict abfTopDict fields (including cid fields) FDArray[0] FDArray[0] font dict Private dict @@ -262,9 +273,7 @@ struct abfFontDict_ { font dict Private dict - It can be seen that there is a direct mapping for CID-keyed fonts but the - name-keyed fonts are represented using a single element FDArray whose font - dict fields are treated as an extension of the font dict. */ + */ void abfInitAllDicts(abfTopDict *top); void abfInitTopDict(abfTopDict *top); @@ -273,8 +282,8 @@ void abfInitFontDict(abfFontDict *font); /* The client is responsible for allocating the font dictionary data structures in memory and correctly initializing the abfTopDict.FDArray.cnt fields to specify the number of element allocated in the abfTopDict.FDArray.array. - This will be 1 for name-keyed fonts and >=1 (the number being dependent on - the complexity of the font) for CID-keyed fonts. Once this has been done + This will be 1 for fonts without FDSelect and >=1 (the number being dependent + on the complexity of the font) for fonts with FDSelect. Once this has been done abfInitAllDicts() may be called to initialize the entire data structure to the values shown in the comments. Alternatively, the abfInitTopDict() and abfInitFontDict() may be called to selectively initialize the top dictionary @@ -288,7 +297,7 @@ void abfInitFontDict(abfFontDict *font); top->FDArray.array = malloc(top->FDArray.cnt * sizeof(abfFontDict)); abfInitAllDicts(top); - CID fonts may be similarly handled except that the font dictionary array + FDSelect fonts may be similarly handled except that the font dictionary array will typically have more than one element. */ typedef struct abfErrCallbacks_ abfErrCallbacks; @@ -342,8 +351,7 @@ int abfCompareFontDicts(const abfFontDict *font1, const abfFontDict *font2); BlueValues. abfCompareFontDicts() is used in the destination font writing module to - compare FDArrays of fonts with more than one element in the FDArray, - CID fonts. */ + compare FDArrays of fonts with more than one element in the FDArray. */ /* ---------------------------- Glyph Callbacks ---------------------------- */ @@ -367,7 +375,7 @@ typedef struct { // Glyph information abfString gname; /* Name-keyed: glyph name */ abfEncoding encoding; /* Name-keyed: encoding list */ unsigned short cid; /* CID-keyed: CID */ - uint16_t iFD; /* CID-keyed: FD index */ + uint16_t iFD; /* FD index */ ctlRegion sup; /* Supplementary data */ struct { unsigned short vsindex; @@ -396,7 +404,7 @@ typedef struct { // Glyph information is updated or subset. If the font is CID-keyed the ABF_GLYPH_CID bit in the "flags" field is set - and the "cid" and "iFD" fields specify the CID and FD index, respectively. + and the "cid" field specifies the CID index. If the font is name-keyed the ABF_GLYPH_CID bit is clear and the "gname" and "encoding" fields specify the glyph name and encoding, respectively. The diff --git a/c/shared/pdfwrite.cpp b/c/shared/pdfwrite.cpp index b6cf7afde..bcbe18109 100644 --- a/c/shared/pdfwrite.cpp +++ b/c/shared/pdfwrite.cpp @@ -392,7 +392,7 @@ int pdwBegFont(pdwCtx h, long flags, long level, abfTopDict *top) { settime(h); /* Set FontName */ - if (h->top->sup.flags & ABF_CID_FONT) + if (h->top->sup.flags & ABF_ROS_FONT) h->FontName = h->top->cid.CIDFontName.ptr; else h->FontName = h->top->FDArray.array[0].FontName.ptr; @@ -1255,7 +1255,7 @@ static long writeInfoObj(pdwCtx h) { OBJ num; /* Make font version */ - if (h->top->sup.flags & ABF_CID_FONT) + if (h->top->sup.flags & ABF_ROS_FONT) snprintf(version, sizeof(version), "%g", h->top->cid.CIDFontVersion); else if (h->top->version.ptr != ABF_UNSET_PTR) { char format[20]; @@ -1349,7 +1349,7 @@ static long writeTileKeyObj(pdwCtx h) { float x = (TILE_COLS - 3) * TILE_SIZE; float y = PAGE_TOP; - if (h->top->sup.flags & ABF_CID_FONT) + if (h->top->sup.flags & ABF_ROS_FONT) drawTile(h, STM_MISC, x, y, "tag,fd", "hAdv", "cid"); else drawTile(h, STM_MISC, x, y, "tag,enc", "hAdv", "gname"); diff --git a/c/shared/svgwrite.cpp b/c/shared/svgwrite.cpp index 24e6a0049..11f359373 100644 --- a/c/shared/svgwrite.cpp +++ b/c/shared/svgwrite.cpp @@ -429,7 +429,7 @@ int svwEndFont(svwCtx h, abfTopDict *top) { } writeStr(h, "top->sup.flags & ABF_CID_FONT) { + if (h->top->sup.flags & ABF_ROS_FONT) { if (h->top->cid.CIDFontName.ptr == NULL) { fatal(h, svwErrFontName); } else { diff --git a/c/shared/t1read.cpp b/c/shared/t1read.cpp index afa01c615..b161d9fa1 100644 --- a/c/shared/t1read.cpp +++ b/c/shared/t1read.cpp @@ -2985,7 +2985,7 @@ static void prepClientData(t1rCtx h) { if (h->flags & CID_FONT) { /* CID-keyed font */ - h->top.sup.flags |= ABF_CID_FONT; + h->top.sup.flags |= ABF_ROS_FONT; h->top.sup.srcFontType = abfSrcFontTypeType1CID; /* We pre-multiplied the FontMatrix's in the FDArray with the one in @@ -3334,7 +3334,7 @@ int t1rResetGlyphs(t1rCtx h) { for (i = 0; i < h->chars.index.cnt; i++) h->chars.index.array[i].flags &= ~ABF_GLYPH_SEEN; - if (h->top.sup.flags & ABF_CID_FONT) { + if (h->top.sup.flags & ABF_ROS_FONT) { /* If the font is a Type1 CID font, the charstrings must be read when building a subset, in order to get the FD index. When a CID charstring is read, it is decrypted in place in the src buffer. diff --git a/c/shared/t1write/t1write.cpp b/c/shared/t1write/t1write.cpp index e435be9b8..82d01abaf 100644 --- a/c/shared/t1write/t1write.cpp +++ b/c/shared/t1write/t1write.cpp @@ -498,7 +498,7 @@ static void writeCstr(t1wCtx h, int col, Cstr *cstr, int put) { if (h->arg.flags & (T1W_ENCODE_BINARY | T1W_TYPE_HOST)) { /* Write binary charstring */ - if (h->top->sup.flags & ABF_CID_FONT) + if (h->top->sup.flags & ABF_ROS_FONT) writeFmt(h, " %ld : ", length); else writeFmt(h, " %ld -| ", length); @@ -774,13 +774,13 @@ static const char *getOrigFontTypeValue(t1wCtx h) { switch (h->top->sup.srcFontType) { case abfSrcFontTypeType1Name: case abfSrcFontTypeCFFName: - if (h->top->sup.flags & ABF_CID_FONT) + if (h->top->sup.flags & ABF_ROS_FONT) return "Type1"; /* Name-keyed to cid-keyed conversion */ else break; case abfSrcFontTypeType1CID: case abfSrcFontTypeCFFCID: - if (h->top->sup.flags & ABF_CID_FONT) + if (h->top->sup.flags & ABF_ROS_FONT) break; else return "CID"; /* CID-keyed to name-keyed conversion */ @@ -992,7 +992,7 @@ static void writeOtherSubrs(t1wCtx h, abfPrivateDict *priv) { if (h->arg.flags & T1W_OTHERSUBRS_PRIVATE) { /* Private OtherSubrs */ - if (h->top->sup.flags & ABF_CID_FONT) { + if (h->top->sup.flags & ABF_ROS_FONT) { /* CID-keyed */ if (priv->LanguageGroup == 1) writeTextArray(h, ARRAY_LEN(gcothers), gcothers); @@ -1012,7 +1012,7 @@ static void writeOtherSubrs(t1wCtx h, abfPrivateDict *priv) { /* Write Private dict. */ static void writePrivateDict(t1wCtx h, abfPrivateDict *priv, long SDBytes) { - int cid = (h->top->sup.flags & ABF_CID_FONT) != 0; + int cid = (h->top->sup.flags & ABF_ROS_FONT) != 0; int size = (1 /* BlueValues */ + (priv->OtherBlues.cnt != ABF_EMPTY_ARRAY) + @@ -2140,7 +2140,7 @@ int t1wEndFont(t1wCtx h, abfTopDict *top) { /* Write out font */ h->top = top; h->dst.cnt = 0; - if (top->sup.flags & ABF_CID_FONT) + if (top->sup.flags & ABF_ROS_FONT) writeCIDKeyedFont(h); else writeNameKeyedFont(h); diff --git a/c/shared/tx_shared.cpp b/c/shared/tx_shared.cpp index 2eb876a3d..47f150390 100644 --- a/c/shared/tx_shared.cpp +++ b/c/shared/tx_shared.cpp @@ -490,7 +490,7 @@ static void dstFileSetAutoName(txCtx h, abfTopDict *top) { *p = '\0'; filename = buf; } else if (h->flags & AUTO_FILE_FROM_FONT) - filename = (top->sup.flags & ABF_CID_FONT) ? top->cid.CIDFontName.ptr : top->FDArray.array[0].FontName.ptr; + filename = (top->sup.flags & ABF_ROS_FONT) ? top->cid.CIDFontName.ptr : top->FDArray.array[0].FontName.ptr; else return; @@ -1450,7 +1450,7 @@ static void selectGlyph(txCtx h, int type, unsigned short id, const char *gname) dnaNEXT(h->cef.subset)->id = id; break; case sel_by_cid: - if (h->top->sup.flags & ABF_CID_FONT) { + if (h->top->sup.flags & ABF_ROS_FONT) { if (h->cef.lookup.cnt == 0) /* Make CID lookup list */ makeGlyphLookup(h, cef_cmpByCID); @@ -1458,7 +1458,7 @@ static void selectGlyph(txCtx h, int type, unsigned short id, const char *gname) } break; case sel_by_name: - if (!(h->top->sup.flags & ABF_CID_FONT)) { + if (!(h->top->sup.flags & ABF_ROS_FONT)) { if (h->cef.lookup.cnt == 0) /* Make glyph name lookup list */ makeGlyphLookup(h, cef_cmpByName); @@ -1544,10 +1544,10 @@ static void printSpec(txCtx h, cefEmbedSpec *spec) { h->cef.src.filename, h->src.glyphs.cnt, h->dst.stm.filename, spec->subset.cnt); - p = (h->top->sup.flags & ABF_CID_FONT) ? "/" : ""; + p = (h->top->sup.flags & ABF_ROS_FONT) ? "/" : ""; for (i = 0; i < spec->subset.cnt; i++) { printf("%s%hu", p, spec->subset.array[i].id); - p = (h->top->sup.flags & ABF_CID_FONT) ? ",/" : ","; + p = (h->top->sup.flags & ABF_ROS_FONT) ? ",/" : ","; } printf("\n"); @@ -1607,7 +1607,7 @@ static void cef_EndFont(txCtx h) { h->cef.gnames.cnt = 0; unrec = 0xE000; /* Start of Private Use Area */ - if (h->top->sup.flags & ABF_CID_FONT) { + if (h->top->sup.flags & ABF_ROS_FONT) { /* Make CID subset, encoding all glyphs in PUA */ for (i = 0; i < h->cef.subset.cnt; i++) { cefSubsetGlyph *dst = &h->cef.subset.array[i]; @@ -1951,7 +1951,7 @@ static void mtx_BegFont(txCtx h, abfTopDict *top) { h->mtx.bbox.right = 0; h->mtx.bbox.top = 0; - if (top->sup.flags & ABF_CID_FONT) + if (top->sup.flags & ABF_ROS_FONT) fprintf(h->dst.stm.fp, "### glyph[tag] {cid,fd,width,{left,bottom,right,top}}\n"); else @@ -1983,7 +1983,7 @@ static void mtx_EndFont(txCtx h) { h->mtx.bbox.setby.bottom->tag, h->mtx.bbox.setby.right->tag, h->mtx.bbox.setby.top->tag); - if (h->top->sup.flags & ABF_CID_FONT) + if (h->top->sup.flags & ABF_ROS_FONT) fprintf(h->dst.stm.fp, "cid {%hu,%hu,%hu,%hu}\n", h->mtx.bbox.setby.left->cid, h->mtx.bbox.setby.bottom->cid, @@ -2114,7 +2114,7 @@ static void t1_BegFont(txCtx h, abfTopDict *top) { } if (h->t1w.options & T1W_DECID) { /* Convert cid-keyed font to name-keyed font */ - if (!(top->sup.flags & ABF_CID_FONT)) + if (!(top->sup.flags & ABF_ROS_FONT)) fatal(h, "-decid specified for non-CID font"); /* Initialize */ @@ -2132,7 +2132,7 @@ static void t1_BegFont(txCtx h, abfTopDict *top) { top->WasEmbedded = 1; if (h->t1w.flags & T1W_TYPE_BASE) - h->t1w.maxGlyphs = (top->sup.flags & ABF_CID_FONT) ? top->cid.CIDCount : top->sup.nGlyphs; + h->t1w.maxGlyphs = (top->sup.flags & ABF_ROS_FONT) ? top->cid.CIDCount : top->sup.nGlyphs; dstFileSetAutoName(h, top); @@ -2471,7 +2471,7 @@ static void t1_EndFont(txCtx h) { (void)ufoGetGlyphByCID(h->ufr.ctx, 0, &h->cb.glyph); /* Convert to name-keyed font */ - h->top->sup.flags &= ~ABF_CID_FONT; + h->top->sup.flags &= ~ABF_ROS_FONT; abfFontDict* selectedFD = &h->top->FDArray.array[h->t1w.fd]; abfFontDict* temp = (abfFontDict *) sMemNew( sizeof(abfFontDict)); @@ -2621,7 +2621,7 @@ static int svg_GlyphBeg(abfGlyphCallbacks *cb, abfGlyphInfo *info) { /* Determine (or fabricate) Unicode value for glyph. */ info->flags |= ABF_GLYPH_UNICODE; - if (h->top->sup.flags & ABF_CID_FONT) { + if (h->top->sup.flags & ABF_ROS_FONT) { if (info->encoding.code == ABF_GLYPH_UNENC) { info->encoding.code = h->svw.unrec; h->svw.unrec++; @@ -3569,7 +3569,7 @@ static void dcf_DumpEncoding(txCtx h, const ctlRegion *region) { if (!(h->dcf.flags & DCF_Encoding) || region->begin == -1 || - h->top->sup.flags & ABF_CID_FONT) + h->top->sup.flags & ABF_ROS_FONT) return; switch (region->begin) { @@ -3662,7 +3662,7 @@ static void dcf_DumpCharset(txCtx h, const ctlRegion *region) { switch (fmt) { case 0: - flowTitle(h, (h->top->sup.flags & ABF_CID_FONT) ? "glyph[gid]=cid" : "glyph[gid]=sid"); + flowTitle(h, (h->top->sup.flags & ABF_ROS_FONT) ? "glyph[gid]=cid" : "glyph[gid]=sid"); for (; gid < h->top->sup.nGlyphs; gid++) flowBreak(h, "[%ld]=%hu", gid, read2(h)); flowEnd(h); @@ -3909,7 +3909,7 @@ static void dcf_DumpCharStringsINDEX(txCtx h, const ctlRegion *region) { return; flowBeg(h); fprintf(h->dst.stm.fp, "--- glyph[tag]={%s,path}\n", - (h->top->sup.flags & ABF_CID_FONT) ? "cid" : "name"); + (h->top->sup.flags & ABF_ROS_FONT) ? "cid" : "name"); h->dcf.flags |= DCF_Flatten; callbackSubset(h); flowEnd(h); @@ -4268,9 +4268,6 @@ static void makeRandSubset(txCtx h, const char *opt, char *arg) { static void makeFDSubset(txCtx h) { long i, j; - if (!(h->top->sup.flags & ABF_CID_FONT)) - fatal(h, "-fd specified for non-CID font"); - getGlyphList(h); for (i = 0; i < h->src.glyphs.cnt; i++) { @@ -4313,7 +4310,7 @@ static int renameGlyphBeg(abfGlyphCallbacks *cb, abfGlyphInfo *info) { } static void makeGOADBSubset(txCtx h) { - if (h->top->sup.flags & ABF_CID_FONT) + if (h->top->sup.flags & ABF_ROS_FONT) fatal(h, "-gs specified for CID font"); getGlyphList(h); @@ -4420,7 +4417,7 @@ void prepSubset(txCtx h) { then proceeds to build the glyph list arg in makeSubsetArgList() */ if (h->flags & SHOW_NAMES) { fflush(stdout); - if (h->top->sup.flags & ABF_CID_FONT) + if (h->top->sup.flags & ABF_ROS_FONT) h->logger->log(sINFO, "--- CIDFontName: %s", h->top->cid.CIDFontName.ptr); else @@ -4571,7 +4568,7 @@ void callbackGlyph(txCtx h, int type, unsigned short id, const char *name) { /* Add .notdef glyph to destination font. If it's already added it will be skipped. */ static void addNotdef(txCtx h) { - if (((h->src.type == src_Type1) || (h->src.type == src_SVG) || (h->src.type == src_UFO)) && !(h->top->sup.flags & ABF_CID_FONT)) + if (((h->src.type == src_Type1) || (h->src.type == src_SVG) || (h->src.type == src_UFO)) && !(h->top->sup.flags & ABF_ROS_FONT)) callbackGlyph(h, sel_by_name, 0, ".notdef"); else callbackGlyph(h, sel_by_tag, 0, NULL); diff --git a/c/shared/uforead.cpp b/c/shared/uforead.cpp index 8c593b82b..78ad834be 100644 --- a/c/shared/uforead.cpp +++ b/c/shared/uforead.cpp @@ -1287,9 +1287,8 @@ static int parseGroups(ufoCtx h) { h->cb.stm.clientFileName = "groups.plist"; h->stm.src = h->cb.stm.open(&h->cb.stm, UFO_SRC_STREAM_ID, 0); if (h->stm.src == NULL || h->cb.stm.seek(&h->cb.stm, h->stm.src, 0)) { - if (h->top.sup.flags == ABF_CID_FONT) - h->logger->log(sWARNING, "FDArraySelect not defined for cid-keyed font"); - return ufoSuccess; + if (h->top.sup.flags == ABF_ROS_FONT) + h->logger->log(sWARNING, "FDArraySelect not defined for cid-keyed font"); return ufoSuccess; } dnaSET_CNT(h->valueArray, 0); @@ -1407,7 +1406,7 @@ static void addCharFromGLIF(ufoCtx h, int tag, GLIF_Rec* glifRec, fatal(h, ufoErrParse, "Glyph '%s' missing FDArray index in dict", glyphName); } chr->iFD = glifRec->iFD; - } else if (h->top.sup.flags & ABF_CID_FONT) { + } else if (h->top.sup.flags & ABF_ROS_FONT) { fatal(h, ufoErrParse, "Glyph '%s' missing CID number in dict", glyphName); } chr->gname.ptr = glyphName; @@ -1791,7 +1790,7 @@ static int parseXMLPlistFile(ufoCtx h, xmlNodePtr cur) { /* lib.plist: preparse set CID Font flags if has CID-keyed UFO required keys */ if (h->parseState.UFOFile == parsingLib) { if (validCIDKeyedFont(h, cur)) { - h->top.sup.flags |= ABF_CID_FONT; + h->top.sup.flags |= ABF_ROS_FONT; h->top.sup.srcFontType = abfSrcFontTypeUFOCID; } } @@ -1875,7 +1874,7 @@ static bool setLibKey(ufoCtx h, char* keyName, xmlNodePtr cur) { return false; } - if ((h->top.sup.flags & ABF_CID_FONT) && + if ((h->top.sup.flags & ABF_ROS_FONT) && top->cid.CIDFontName.ptr == NULL && h->top.FDArray.array[0].FontName.ptr != NULL) { /* derive name from fontinfo.plist familyName-styleName */ @@ -3096,7 +3095,7 @@ static int readGlyph(ufoCtx h, unsigned short tag, abfGlyphCallbacks* glyph_cb) /* note that gname.ptr is not stable: it is a pointer into the h->string->buf array, which moves when it gets resized. */ gi->gname.ptr = getString(h, (STI)gi->tag); - if (h->top.sup.flags & ABF_CID_FONT) { + if (h->top.sup.flags & ABF_ROS_FONT) { gi->flags |= ABF_GLYPH_CID; if (h->top.FDArray.array[gi->iFD].Private.LanguageGroup == 1) gi->flags |= ABF_GLYPH_LANG_1; @@ -3325,8 +3324,8 @@ int ufoBegFont(ufoCtx h, long flags, abfTopDict** top, char* altLayerDir) { (h->top.cid.Ordering.ptr != NULL) && /* required com.adobe.type.ROS key */ (h->top.cid.Supplement >= 0) && /* required com.adobe.type.ROS key */ (h->requiredCIDKeyFlag & CIDKEY_CIDMAP)) { /* required com.adobe.type.postscriptCIDMap key */ - if (!(h->top.sup.flags & ABF_CID_FONT)) { - h->top.sup.flags |= ABF_CID_FONT; + if (!(h->top.sup.flags & ABF_ROS_FONT)) { + h->top.sup.flags |= ABF_ROS_FONT; h->top.sup.srcFontType = abfSrcFontTypeUFOCID; } } @@ -3427,7 +3426,7 @@ static int CTL_CDECL matchCID(const void *key, const void *value) { int ufoGetGlyphByCID(ufoCtx h, unsigned short cid, abfGlyphCallbacks *glyph_cb) { volatile unsigned short tag; /* volatile suppresses optimizer warning */ - if (!(h->flags & ABF_CID_FONT)) + if (!(h->flags & ABF_ROS_FONT)) return ufoErrNoGlyph; if (h->chars.index.array[h->chars.index.cnt - 1].cid == diff --git a/c/shared/ufowrite.cpp b/c/shared/ufowrite.cpp index ae9533116..ca499a7b9 100644 --- a/c/shared/ufowrite.cpp +++ b/c/shared/ufowrite.cpp @@ -722,7 +722,7 @@ static void writeLibPlist(ufwCtx h) { writeLine(h, ""); writeLine(h, ""); - if (h->top->sup.flags & ABF_CID_FONT) { + if (h->top->sup.flags & ABF_ROS_FONT) { if (h->top->cid.CIDFontName.ptr != NULL) { writeLine(h, "\tcom.adobe.type.CIDFontName"); snprintf(buffer, buflen, "\t%s", h->top->cid.CIDFontName.ptr); @@ -948,7 +948,7 @@ static int writeFontInfo(ufwCtx h, abfTopDict *top) { /* This is what I care about the most. Add the rest in the order of the UFO 3 spec. */ - if (top->sup.flags & ABF_CID_FONT) { + if (top->sup.flags & ABF_ROS_FONT) { if (top->cid.CIDFontName.ptr != NULL) { writeLine(h, "\tpostscriptFontName"); snprintf(buffer, sizeof(buffer), @@ -979,7 +979,7 @@ static int writeFontInfo(ufwCtx h, abfTopDict *top) { writeLine(h, buffer); } - if (top->sup.flags & ABF_CID_FONT) { + if (top->sup.flags & ABF_ROS_FONT) { if (top->cid.CIDFontVersion != 0) { char versionStr[32]; snprintf(versionStr, sizeof(versionStr), @@ -1076,7 +1076,7 @@ static int writeFontInfo(ufwCtx h, abfTopDict *top) { writeLine(h, "\t"); } - if (top->sup.flags != ABF_CID_FONT) { + if (top->FDArray.cnt == 1) { privateDict = &(fontDict0->Private); writeBlueValues(h, privateDict); } @@ -1115,7 +1115,7 @@ int ufwEndFont(ufwCtx h, abfTopDict *top) { writeContents(h); writeLibPlist(h); - if (h->top->sup.flags & ABF_CID_FONT || top->FDArray.cnt > 1) // for now, only write if CID font. Revisit in next PR adding multi-fddict support to non-cidkeyed fonts. + if (top->FDArray.cnt > 1) // for now, only write if CID font. Revisit in next PR adding multi-fddict support to non-cidkeyed fonts. writeGroups(h, top); writeMetaInfo(h); h->state = 0; /* Indicates writing to temp stream */ diff --git a/tests/tx_data/expected_output/CFF2-serif-sub.cff2.txt b/tests/tx_data/expected_output/CFF2-serif-sub.cff2.txt index 14f288134..8c7b7dbb8 100644 --- a/tests/tx_data/expected_output/CFF2-serif-sub.cff2.txt +++ b/tests/tx_data/expected_output/CFF2-serif-sub.cff2.txt @@ -1,5 +1,5 @@ -## glyph[tag] {cid,iFD,path} -glyph[21847] {21847,3, +## glyph[tag] {name,encoding,path} +glyph[21847] {(missing),-, 0 width 252 31 move 100 23 line diff --git a/tests/tx_data/expected_output/bug437/dump-cidfont.txt b/tests/tx_data/expected_output/bug437/dump-cidfont.txt index b31558210..bc6d0d3ba 100644 --- a/tests/tx_data/expected_output/bug437/dump-cidfont.txt +++ b/tests/tx_data/expected_output/bug437/dump-cidfont.txt @@ -1,4 +1,4 @@ -## Filename tx_data/input/cidfont-noPSname.ps +## Filename /home/skef/src/afdko4/tests/tx_data/input/cidfont-noPSname.ps ## Top Dict Notice "Copyright 2014-2018 Adobe Systems Incorporated (http://www.adobe.com/), with Reserved Font Name 'Source'. Source is a trademark of Adobe Systems Incorporated in the United States and/or other countries." FullName "Source Han Sans AJ16 Regular" @@ -12,7 +12,7 @@ cid.Ordering "Japan1" cid.Supplement 0 cid.CIDFontVersion 1.000 cid.CIDCount 1144 -sup.flags 0x00000001 (ABF_CID_FONT) +sup.flags 0x00000001 (ABF_ROS_FONT) sup.srcFontType Type 1 (cid-keyed) sup.nGlyphs 4 ## FontDict[0] diff --git a/tests/tx_data/expected_output/bug897.cff.dcf b/tests/tx_data/expected_output/bug897.cff.dcf index 919e9c69a..f29b3f57a 100644 --- a/tests/tx_data/expected_output/bug897.cff.dcf +++ b/tests/tx_data/expected_output/bug897.cff.dcf @@ -6,55 +6,34 @@ offSize=2 ### Name INDEX (00000004-00000017) --- object[index]={value} [0]={SourceSans-Test} -### Top DICT INDEX (00000018-00000049) +### Top DICT INDEX (00000018-0000003b) --- object[index]={value} [0]={ - 391 392 1 ROS - 393 version - 394 FullName - 394 FamilyName + 395 version + 396 FullName + 396 FamilyName -150 UnderlinePosition 37 -120 971 880 FontBBox - 5 CIDCount - 126 charset - 136 CharStrings - 130 FDIndex - 706 FDArray + 117 charset + 127 CharStrings + 75 697 Private } -### String INDEX (0000004a-0000007b) +### String INDEX (0000003c-00000072) --- object[index]={value} -[391]={Adobe} -[392]={Identity} -[393]={1.0} -[394]={SourceSans} -[395]={SourceSans-Test} -### GlobalSubrINDEX (0000007c-0000007d) +[391]={gid00001} +[392]={gid00002} +[393]={gid00003} +[394]={gid00004} +[395]={1.0} +[396]={SourceSans} +### GlobalSubrINDEX (00000073-00000074) empty -### Charset (0000007e-00000081) +### Encoding ........ (Standard) +### Charset (00000075-00000078) format=1 --- Range1[index]={first,nLeft} -[0]={1,3} -### FDSelect (00000082-00000087) -format =0 ---- glyph[gid]=fd -[0]=0 -[1]=2 -[2]=1 -[3]=1 -[4]=2 -### FDArray INDEX (000002c2-000002d8) ---- object[index]={value} -[0]={ - 395 FontName - 23 729 Private -} -[1]={ - 25 752 Private -} -[2]={ - 27 777 Private -} -### CharStrings INDEX (00000088-000002c1) +[0]={391,3} +### CharStrings INDEX (0000007f-000002b8) --- object[index]={value} [0]={ 100 -120 rmoveto @@ -146,24 +125,19 @@ format =0 [4]={ endchar } ---- FD[0] -### Private DICT (000002d9-000002ef) +### Private DICT (000002b9-00000303) -250 0 1350 0 BlueValues 40 StdHW 40 StdVW 40 80 StemSnapH 40 80 StemSnapV 1000 defaultWidthX ---- FD[1] -### Private DICT (000002f0-00000308) -250 0 1350 0 BlueValues 58 StdHW 63 StdVW 58 7 19 StemSnapH 63 10 16 StemSnapV 1000 defaultWidthX ---- FD[2] -### Private DICT (00000309-00000323) -13 13 543 14 176 14 BlueValues -250 21 OtherBlues 69 StdHW diff --git a/tests/tx_data/expected_output/cid_roundtrip/testCID.txt b/tests/tx_data/expected_output/cid_roundtrip/testCID.txt index 809f5b65a..b97021be2 100644 --- a/tests/tx_data/expected_output/cid_roundtrip/testCID.txt +++ b/tests/tx_data/expected_output/cid_roundtrip/testCID.txt @@ -1,4 +1,4 @@ -## Filename /Users/scheuren/code/gitsource/adobe/afdko/tests/tx_data/input/cid_roundtrip/testCID.ufo +## Filename /home/skef/src/afdko4/tests/tx_data/input/cid_roundtrip/testCID.ufo ## Top Dict version "2.3" Notice "Copyright 2014-2020 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'. Source is a trademark of Adobe in the United States and/or other countries." @@ -13,7 +13,7 @@ cid.Ordering "Identity" cid.Supplement 0 cid.CIDFontVersion 2.003 cid.CIDCount 34468 -sup.flags 0x00000001 (ABF_CID_FONT) +sup.flags 0x00000001 (ABF_ROS_FONT) sup.srcFontType UFO (cid-keyed) sup.nGlyphs 135 ## FontDict[0] diff --git a/tests/tx_data/expected_output/fdselect4.otf.dump b/tests/tx_data/expected_output/fdselect4.otf.dump index 0e88a283e..2b9cc0f4e 100644 --- a/tests/tx_data/expected_output/fdselect4.otf.dump +++ b/tests/tx_data/expected_output/fdselect4.otf.dump @@ -1,4 +1,4 @@ -## Filename fdselect4.otf +## Filename /home/skef/src/afdko4/tests/tx_data/input/fdselect4.otf ## Top Dict version "1.0" FullName "SourceSans" @@ -6,12 +6,7 @@ FamilyName "SourceSans" UnderlinePosition -150 FontBBox {37,-120,971,880} FSType 4 -cid.CIDFontName "SourceSans-Test" -cid.Registry "Adobe" -cid.Ordering "Identity" -cid.Supplement 1 -sup.flags 0x00000001 (ABF_CID_FONT) -sup.srcFontType CFF (cid-keyed) +sup.srcFontType CFF (name-keyed) sup.nGlyphs 5 ## FontDict[0] FontName "SourceSans-Test" @@ -36,9 +31,9 @@ StdHW 69 StdVW 85 StemSnapH {69,79,88} StemSnapV {85,95,111} -## glyph[tag] {cid,iFD} -glyph[0] {0,0} -glyph[1] {1,2} -glyph[2] {2,1} -glyph[3] {3,1} -glyph[4] {4,2} +## glyph[tag] {name,encoding} +glyph[0] {.notdef,-} +glyph[1] {gid00001,U+0000} +glyph[2] {gid00002,U+4E9C} +glyph[3] {gid00003,U+9BF5} +glyph[4] {gid00004,-} diff --git a/tests/tx_data/expected_output/pfa-start-pt-with-float.ufo/fontinfo.plist b/tests/tx_data/expected_output/pfa-start-pt-with-float.ufo/fontinfo.plist index 6567ba647..a2d2114e6 100644 --- a/tests/tx_data/expected_output/pfa-start-pt-with-float.ufo/fontinfo.plist +++ b/tests/tx_data/expected_output/pfa-start-pt-with-float.ufo/fontinfo.plist @@ -22,5 +22,26 @@ Regular postscriptUnderlinePosition -125 + postscriptBlueValues + + 0 + 0 + + postscriptStdHW + + 0 + + postscriptStdVW + + 0 + + postscriptBlueScale + 0.037 + postscriptBlueShift + 7 + postscriptBlueFuzz + 0 + ExpansionFactor + 0.06 diff --git a/tests/tx_data/expected_output/pfa-start-pt-with-float.ufo/groups.plist b/tests/tx_data/expected_output/pfa-start-pt-with-float.ufo/groups.plist deleted file mode 100644 index 468bde6fb..000000000 --- a/tests/tx_data/expected_output/pfa-start-pt-with-float.ufo/groups.plist +++ /dev/null @@ -1,12 +0,0 @@ - - - - - FDArraySelect.0.TestFont-Regular - - cid00000 - cid00001 - cid00002 - - -