makeotf
/* Create 16-bit and 32-bit (if needed) Unicode cmaps */ static void makeUnicodecmaps(hotCtx g) { mapCtx h = g->ctx.map; long i; /* Create the BMP UTF-16 cmaps */ cmapBeginEncoding(g, cmap_MS, cmap_MS_UGL, 0); for (i = 0; i < h->sort.uv.cnt; i++) { AddlUV *adUV; hotGlyphInfo *gi = h->sort.uv.array[i]; if (gi->flags & GNAME_UNREC_HAS_SUPP) { continue; } if (!IS_SUPP_UV(gi->uv)) { cmapAddMapping(g, gi->uv, GET_GID(gi), 2); } for (adUV = gi->addlUV; adUV != NULL; adUV = adUV->next) { if (!IS_SUPP_UV(adUV->uv)) { cmapAddMapping(g, adUV->uv, GET_GID(gi), 2); } } } if (cmapEndEncoding(g)) { cmapPointToPreviousEncoding(g, cmap_UNI, cmap_UNI_UTF16_BMP); } else { return; } /* Create UTF-32 cmaps, if needed, as supersets of the BMP UTF-16 cmaps: */ if (h->nSuppUV == 0) { return; } cmapBeginEncoding(g, cmap_MS, cmap_MS_UCS4, 0); for (i = 0; i < h->sort.uv.cnt; i++) { AddlUV *adUV; hotGlyphInfo *gi = h->sort.uv.array[i]; cmapAddMapping(g, gi->uv, GET_GID(gi), 4); for (adUV = gi->addlUV; adUV != NULL; adUV = adUV->next) { cmapAddMapping(g, adUV->uv, GET_GID(gi), 4); } } if (cmapEndEncoding(g)) { cmapPointToPreviousEncoding(g, cmap_UNI, cmap_UNI_UTF32); } } /* Make Mac cmap for CID fonts */
/* Any CMaps have already been read in by mapAddCmap */ int mapFill(hotCtx g) { mapCtx h = g->ctx.map; if (IS_CID(g) && h->cid.hor.name == SINX_UNDEF) { hotMsg(g, hotFATAL, "H Unicode CMap not seen"); } /* Roman Custom cmap made in mapInit(), Roman Mac cmap made in mapApplyReencoding(). */ makeUnicodecmaps(g); <== setOS_2Fields(g); if (IS_CID(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) { hotMsg(g, hotWARNING, "Macintosh Adobe CMap not seen"); } if (h->uvs.entries.cnt == 0) { hotMsg(g, hotWARNING, "Unicode variation Selector File not seen"); } } if (h->uvs.entries.cnt > 0) { makeUVScmap(g); /* will make a Unicode Variation Selector cmap 14 when UVS data file was seen..*/ } #if HOT_DEBUG if (DB_MAP(g)) { dbgPrintInfo(g); } #endif return 1; }
afdko/map.c at 9d708d22614fbf15939956b7bd1696911a52df1c · adobe-type-tools/afdko · GitHub
afdko/hot.c at 9d708d22614fbf15939956b7bd1696911a52df1c · adobe-type-tools/afdko · GitHub
/* Convert to OTF */ void hotConvert(hotCtx g) { BBox old_bbox; old_bbox = g->font.bbox; setBounds(g); if (bbox_changed(&old_bbox, &g->font.bbox)) { patch_cff_fontbbox(g); } mapFill(g); featFill(g); prepWinData(g); setVBounds(g); if (g->convertFlags & HOT_ADD_STUB_DSIG) hotAddAnonTable(g, TAG('D', 'S', 'I', 'G'), refillDSIG); sfntFill(g); sfntWrite(g); #if HOT_DEBUG if (g->font.debug & HOT_DB_AFM) { mapPrintAFM(g); } #endif /* HOT_DEBUG */ cffFree(g->ctx.cff); hotReuse(g); }
/* Convert font */ void cbConvert(cbCtx h, int flags, char *clientVers, char *pfbfile, char *otffile, char *featurefile, char *hcmapfile, char *vcmapfile, char *mcmapfile, char *uvsFile, long otherflags, short macScript, short macLanguage, long addGlyphWeight, unsigned long maxNumSubrs, short fsSelectionMask_on, short fsSelectionMask_off, unsigned short os2Version, char *licenseID) { int psinfo; int type; char *FontName; char pfbpath[FILENAME_MAX + 1]; char otfpath[FILENAME_MAX + 1]; int freeFeatName = 0; unsigned long hotConvertFlags = 0; if (otherflags & OTHERFLAGS_DO_ID2_GSUB_CHAIN_CONXT) { hotConvertFlags |= HOT_ID2_CHAIN_CONTXT3; } if (otherflags & OTHERFLAGS_ALLOW_STUB_GSUB) { hotConvertFlags |= HOT_ALLOW_STUB_GSUB; } if (otherflags & OTHERFLAGS_OLD_SPACE_DEFAULT_CHAR) { hotConvertFlags |= HOT_OLD_SPACE_DEFAULT_CHAR; } if (h->fcdb.syntaxVersion == 1) { hotConvertFlags |= HOT_USE_V1_MENU_NAMES; } if (otherflags & OTHERFLAGS_OLD_NAMEID4) hotConvertFlags |= HOT_USE_OLD_NAMEID4; if (otherflags & OTHERFLAGS_OMIT_MAC_NAMES) { hotConvertFlags |= HOT_OMIT_MAC_NAMES; } if (otherflags & OTHERFLAGS_STUB_CMAP4) { hotConvertFlags |= HOT_STUB_CMAP4; } if (otherflags & OTHERFLAGS_OVERRIDE_MENUNAMES) { hotConvertFlags |= HOT_OVERRIDE_MENUNAMES; } if (otherflags & OTHERFLAGS_DO_NOT_OPTIMIZE_KERN) { hotConvertFlags |= HOT_DO_NOT_OPTIMIZE_KERN; } if (otherflags & OTHERFLAGS_ADD_STUB_DSIG) { hotConvertFlags |= HOT_ADD_STUB_DSIG; } if (otherflags & OTHERFLAGS_VERBOSE) { hotConvertFlags |= HOT_CONVERT_VERBOSE; } if (otherflags & OTHERFLAGS_FINAL_NAMES) { hotConvertFlags |= HOT_CONVERT_FINAL_NAMES; } hotSetConvertFlags(h->hot.ctx, hotConvertFlags); if (flags & HOT_RENAME) { h->alias.useFinalNames = 1; } else { h->alias.useFinalNames = 0; } /* Make PFB path */ sprintf(pfbpath, "%s%s", h->dir.pfb, pfbfile); /*CFFDBG part of hack to print out temp cff file for CID fonts */ /*h->CMap.file.name set here is used only to trigger dbg behavior in tempClose() */ if (hcmapfile != NULL) { h->tmp.file.name = pfbpath; } if (!fileExists(pfbpath)) { cbFatal(h, "Source font file not found: %s \n", pfbpath); return; } if ((featurefile != NULL) && (!fileExists(featurefile))) { cbFatal(h, "Feature file not found: %s \n", featurefile); return; } /* Convert font to CFF */ { hotReadFontOverrides fontOverrides; fontOverrides.syntheticWeight = addGlyphWeight; fontOverrides.maxNumSubrs = maxNumSubrs; FontName = psConvFont(h, flags, pfbpath, &psinfo, &fontOverrides); } type = psinfo & HOT_TYPE_MASK; if (h->cff.euroAdded) { psinfo |= HOT_EURO_ADDED; } if (uvsFile != NULL) { hotAddUVSMap(h->hot.ctx, uvsFile); } /* Determine dir that feature file's in */ h->feat.mainFile = featurefile; if (featurefile != NULL) { char *p; p = findDirName(featurefile); if (p == NULL) { h->feat.includeDir[0] = curdir(); } else { char featDir[FILENAME_MAX]; strncpy(featDir, featurefile, p - featurefile); featDir[p - featurefile] = '\0'; copyStr(h, &h->feat.includeDir[0], featDir); freeFeatName = 1; } } if (type == hotCID) { /* Add CMaps */ if (hcmapfile == NULL) { cbFatal(h, "no CMaps specified [%s]\n", pfbpath); } addCMap(h, hcmapfile); addCMap(h, vcmapfile); addCMap(h, mcmapfile); } // Get database data via callbacks if (h->fcdb.files.cnt == 0) { { fcdbGetRec(h->fcdb.ctx, FontName); cbWarning(h, "FontMenuNameDB file was not specified or not found. [%s]", FontName); } } else if (fcdbGetRec(h->fcdb.ctx, FontName)) { { cbWarning(h, "not in FontMenuNameDB [%s]", FontName); } } // Make sure that GOADB file has been read in, if required if ((flags & HOT_RENAME) && (h->alias.recs.cnt < 1) && (type != hotCID)) { cbWarning(h, "Glyph renaming was requested, but the GlyphOrderAndAliasDB file was not specified."); } h->mac.cmapScript = macScript; /* Used in hotAddmiscData, in ProcessFontInfo */ h->mac.cmapLanguage = macLanguage; ProcessFontInfo(h->hot.ctx, clientVers, FontName, psinfo, &h->mac, otherflags, fsSelectionMask_on, fsSelectionMask_off, os2Version, licenseID); /* Make OTF path */ if (otffile == NULL) { makeOTFPath(h, otfpath, FontName); } else { sprintf(otfpath, "%s%s", h->dir.otf, otffile); } /* Write OTF file */ fileOpen(&h->otf.file, h, otfpath, "w+b"); hotConvert(h->hot.ctx);<==<==<== <==<==<== <==<==<== <==<==<== fileClose(&h->otf.file); if (freeFeatName) { cbMemFree(h, h->feat.includeDir[0]); } h->feat.anon.cnt = 0; }
afdko/map.c at 9d708d22614fbf15939956b7bd1696911a52df1c · adobe-type-tools/afdko · GitHub