/* Fill CFF font dict. */ void cfwDictFillFont(cfwCtx g, DICT *dst, abfFontDict *src) { dst->cnt = 0; /* FontName */ if (src->FontName.impl != SRI_UNDEF) saveStringOp(g, dst, (SRI)src->FontName.impl, cff_FontName); /* PaintType */ if (src->PaintType != cff_DFLT_PaintType) cfwDictSaveIntOp(dst, src->PaintType, cff_PaintType); /* FontMatrix */ saveFontMatrix(dst, &src->FontMatrix); }
/* Fill CFF FDInfo DICTs. */ void cfwDictFillPrivate(cfwCtx g, DICT *dst, abfPrivateDict *src) { dst->cnt = 0; if (!(g->flags & CFW_NO_FAMILY_OPT)) { /* Delete duplicates from the Family arrays */ delFamilyDups(src->BlueValues.cnt, src->BlueValues.array, &src->FamilyBlues.cnt, src->FamilyBlues.array, 0); delFamilyDups(src->OtherBlues.cnt, src->OtherBlues.array, &src->FamilyOtherBlues.cnt, src->FamilyOtherBlues.array, 1); } /* Delete StemSnap arrays that match corresponding Std value */ if (src->StemSnapH.cnt == 1 && src->StemSnapH.array[0] == src->StdHW) { src->StemSnapH.cnt = ABF_EMPTY_ARRAY; } if (src->StemSnapV.cnt == 1 && src->StemSnapV.array[0] == src->StdVW) { src->StemSnapV.cnt = ABF_EMPTY_ARRAY; } /* BlueValues */ if (src->BlueValues.cnt != ABF_EMPTY_ARRAY) { saveRealDeltaOp(dst, src->BlueValues.cnt, src->BlueValues.array, cff_BlueValues); } /* OtherBlues */ if (src->OtherBlues.cnt != ABF_EMPTY_ARRAY) { saveRealDeltaOp(dst, src->OtherBlues.cnt, src->OtherBlues.array, cff_OtherBlues); } /* FamilyBlues */ if (src->FamilyBlues.cnt != ABF_EMPTY_ARRAY) { saveRealDeltaOp(dst, src->FamilyBlues.cnt, src->FamilyBlues.array, cff_FamilyBlues); } /* FamilyOtherBlues */ if (src->FamilyOtherBlues.cnt != ABF_EMPTY_ARRAY) { saveRealDeltaOp(dst, src->FamilyOtherBlues.cnt, src->FamilyOtherBlues.array, cff_FamilyOtherBlues); } /* BlueScale */ if (src->BlueScale != (float)cff_DFLT_BlueScale) { cfwDictSaveRealOp(dst, src->BlueScale, cff_BlueScale); } /* BlueShift */ if (src->BlueShift != cff_DFLT_BlueShift) { cfwDictSaveRealOp(dst, src->BlueShift, cff_BlueShift); } /* BlueFuzz */ if (src->BlueFuzz != cff_DFLT_BlueFuzz) { cfwDictSaveRealOp(dst, src->BlueFuzz, cff_BlueFuzz); } /* StdHW */ if (src->StdHW != ABF_UNSET_REAL) { cfwDictSaveRealOp(dst, src->StdHW, cff_StdHW); } /* StdVW */ if (src->StdVW != ABF_UNSET_REAL) { cfwDictSaveRealOp(dst, src->StdVW, cff_StdVW); } /* StemSnapH */ if (src->StemSnapH.cnt != ABF_EMPTY_ARRAY) { saveRealDeltaOp(dst, src->StemSnapH.cnt, src->StemSnapH.array, cff_StemSnapH); } /* StemSnapV */ if (src->StemSnapV.cnt != ABF_EMPTY_ARRAY) { saveRealDeltaOp(dst, src->StemSnapV.cnt, src->StemSnapV.array, cff_StemSnapV); } /* ForceBold */ if (src->ForceBold != cff_DFLT_ForceBold) { cfwDictSaveIntOp(dst, src->ForceBold, cff_ForceBold); } /* LanguageGroup */ if (src->LanguageGroup != cff_DFLT_LanguageGroup) { cfwDictSaveIntOp(dst, src->LanguageGroup, cff_LanguageGroup); } /* ExpansionFactor */ if (src->ExpansionFactor != (float)cff_DFLT_ExpansionFactor) { cfwDictSaveRealOp(dst, src->ExpansionFactor, cff_ExpansionFactor); } /* initialRandomSeed */ if (src->initialRandomSeed != cff_DFLT_initialRandomSeed) { cfwDictSaveRealOp(dst, src->initialRandomSeed, cff_initialRandomSeed); } }
/* Fill CFF top dict. */ void cfwDictFillTop(cfwCtx g, DICT *dst, abfTopDict *top, abfFontDict *font0, long iSyntheticBase) { int embed = g->flags & (CFW_EMBED_OPT | CFW_ROM_OPT); dst->cnt = 0; if (iSyntheticBase != -1) { /* Make synthetic font dictionary */ cfwDictSaveIntOp(dst, iSyntheticBase, cff_SyntheticBase); /* FullName */ if (top->FullName.impl != SRI_UNDEF) { saveStringOp(g, dst, (SRI)top->FullName.impl, cff_FullName); } /* ItalicAngle */ if (top->ItalicAngle != cff_DFLT_ItalicAngle) { cfwDictSaveRealOp(dst, top->ItalicAngle, cff_ItalicAngle); } /* FontMatrix */ saveFontMatrix(dst, &font0->FontMatrix); return; } /* ROS */ if (top->sup.flags & ABF_CID_FONT) { cfwDictSaveInt(dst, cfwSindexAssignSID(g, (SRI)top->cid.Registry.impl)); cfwDictSaveInt(dst, cfwSindexAssignSID(g, (SRI)top->cid.Ordering.impl)); cfwDictSaveInt(dst, top->cid.Supplement); cfwDictSaveOp(dst, cff_ROS); } /* version */ if (top->version.impl != SRI_UNDEF && !embed) { saveStringOp(g, dst, (SRI)top->version.impl, cff_version); } /* Notice */ if (top->Notice.impl != SRI_UNDEF) { saveStringOp(g, dst, (SRI)top->Notice.impl, cff_Notice); } if (top->Copyright.impl != SRI_UNDEF && (!embed || top->Notice.impl == SRI_UNDEF)) { saveStringOp(g, dst, (SRI)top->Copyright.impl, cff_Copyright); } /* FullName */ if (top->FullName.impl != SRI_UNDEF && !embed) { saveStringOp(g, dst, (SRI)top->FullName.impl, cff_FullName); } /* FamilyName */ if (top->FamilyName.impl != SRI_UNDEF && !embed) { saveStringOp(g, dst, (SRI)top->FamilyName.impl, cff_FamilyName); } /* Weight */ if (top->Weight.impl != SRI_UNDEF) { saveStringOp(g, dst, (SRI)top->Weight.impl, cff_Weight); } /* isFixedPitch */ if (top->isFixedPitch != cff_DFLT_isFixedPitch && !embed) { cfwDictSaveIntOp(dst, top->isFixedPitch, cff_isFixedPitch); } /* ItalicAngle */ if (top->ItalicAngle != cff_DFLT_ItalicAngle) { cfwDictSaveRealOp(dst, top->ItalicAngle, cff_ItalicAngle); } /* UnderlinePosition */ if (top->UnderlinePosition != cff_DFLT_UnderlinePosition && !embed) { cfwDictSaveRealOp(dst, top->UnderlinePosition, cff_UnderlinePosition); } /* UnderlineThickness */ if (top->UnderlineThickness != cff_DFLT_UnderlineThickness && !embed) { cfwDictSaveRealOp(dst, top->UnderlineThickness, cff_UnderlineThickness); } /* PostScript */ if (top->PostScript.impl != SRI_UNDEF) { saveStringOp(g, dst, (SRI)top->PostScript.impl, cff_PostScript); } /* BaseFontName */ if (top->BaseFontName.impl != SRI_UNDEF) { saveStringOp(g, dst, (SRI)top->BaseFontName.impl, cff_BaseFontName); } /* BaseFontBlend */ if (top->BaseFontBlend.cnt != ABF_EMPTY_ARRAY) { saveIntDeltaOp(dst, top->BaseFontBlend.cnt, top->BaseFontBlend.array, cff_BaseFontBlend); } /* FontBBox */ if (top->FontBBox[0] != 0 || top->FontBBox[1] != 0 || top->FontBBox[2] != 0 || top->FontBBox[3] != 0) { top->FontBBox[0] = roundf(top->FontBBox[0]); top->FontBBox[1] = roundf(top->FontBBox[1]); top->FontBBox[2] = roundf(top->FontBBox[2]); top->FontBBox[3] = roundf(top->FontBBox[3]); saveRealArrayOp(dst, 4, top->FontBBox, cff_FontBBox); } if (top->sup.flags & ABF_CID_FONT) { /* FontMatrix; note default values are different from font dict */ if (top->cid.FontMatrix.cnt != ABF_EMPTY_ARRAY && (top->cid.FontMatrix.array[0] != 1.0 || top->cid.FontMatrix.array[1] != 0.0 || top->cid.FontMatrix.array[2] != 0.0 || top->cid.FontMatrix.array[3] != 1.0 || top->cid.FontMatrix.array[4] != 0.0 || top->cid.FontMatrix.array[5] != 0.0)) { saveRealArrayOp(dst, 6, top->cid.FontMatrix.array, cff_FontMatrix); } } else { /* PaintType */ if (font0->PaintType != cff_DFLT_PaintType) { cfwDictSaveIntOp(dst, font0->PaintType, cff_PaintType); } /* FontMatrix */ saveFontMatrix(dst, &font0->FontMatrix); } /* UniqueID */ if (top->UniqueID != ABF_UNSET_INT) { cfwDictSaveIntOp(dst, top->UniqueID, cff_UniqueID); } /* StrokeWidth */ if (top->StrokeWidth != cff_DFLT_StrokeWidth) { cfwDictSaveRealOp(dst, top->StrokeWidth, cff_StrokeWidth); } if (top->sup.flags & ABF_CID_FONT) { /* CIDFontVersion */ if (top->cid.CIDFontVersion != cff_DFLT_CIDFontVersion) { cfwDictSaveRealOp(dst, top->cid.CIDFontVersion, cff_CIDFontVersion); } /* CIDFontRevision */ if (top->cid.CIDFontRevision != cff_DFLT_CIDFontRevision) { cfwDictSaveIntOp(dst, top->cid.CIDFontRevision, cff_CIDFontRevision); } /* CIDCount */ if (top->cid.CIDCount != cff_DFLT_CIDCount) { cfwDictSaveIntOp(dst, top->cid.CIDCount, cff_CIDCount); } /* UIDBase */ if (top->cid.UIDBase != ABF_UNSET_INT) { cfwDictSaveIntOp(dst, top->cid.UIDBase, cff_UIDBase); } } /* XUID */ if (top->XUID.cnt != ABF_EMPTY_ARRAY) { saveIntArrayOp(dst, top->XUID.cnt, top->XUID.array, cff_XUID); } }