diff options
author | Karl Berry <karl@freefriends.org> | 2021-02-25 19:22:25 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-02-25 19:22:25 +0000 |
commit | ad547a6b5986815fda458221149728d9d9ab1d87 (patch) | |
tree | 16296910eb3eca724371474ea9aea3994dc69614 /Build/source/texk/ttfdump/libttf/vdmx.c | |
parent | 947b43de3dd21d58ccc2ffadefc4441ea1c2a813 (diff) |
restore Build,TODO from r57911
git-svn-id: svn://tug.org/texlive/trunk@57915 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/ttfdump/libttf/vdmx.c')
-rw-r--r-- | Build/source/texk/ttfdump/libttf/vdmx.c | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/Build/source/texk/ttfdump/libttf/vdmx.c b/Build/source/texk/ttfdump/libttf/vdmx.c new file mode 100644 index 00000000000..ed9139d7c11 --- /dev/null +++ b/Build/source/texk/ttfdump/libttf/vdmx.c @@ -0,0 +1,133 @@ +/* vdmx.c -- Vertical Device Metrics + * Copyright (C) 1996 Li-Da Lho, All right reserved + */ +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include "ttf.h" +#include "ttfutil.h" + +/* $Id: vdmx.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $ */ + +static void ttfLoadVDMX(FILE *fp,VDMXPtr vdmx,ULONG offset); + +void ttfInitVDMX(TTFontPtr font) +{ + ULONG tag = FT_MAKE_TAG ('V', 'D', 'M', 'X'); + TableDirPtr ptd; + + if ((ptd = ttfLookUpTableDir(tag,font)) != NULL) + { + font->vdmx = XCALLOC1 (VDMX); + ttfLoadVDMX(font->fp,font->vdmx,ptd->offset); + } +} + +static void ttfLoadVDMX (FILE *fp,VDMXPtr vdmx,ULONG offset) +{ + int i; + + xfseek(fp, offset, SEEK_SET, "ttfLoadVDMX"); + + vdmx->version = ttfGetUSHORT(fp); + vdmx->numRecs = ttfGetUSHORT(fp); + vdmx->numRatios = ttfGetUSHORT(fp); + + vdmx->ratRange = XCALLOC (vdmx->numRatios, Ratios); + for (i=0;i<vdmx->numRatios;i++) + { + (vdmx->ratRange+i)->CharSet = ttfGetBYTE(fp); + (vdmx->ratRange+i)->xRatio = ttfGetBYTE(fp); + (vdmx->ratRange+i)->yStartRatio = ttfGetBYTE(fp); + (vdmx->ratRange+i)->yEndRatio = ttfGetBYTE(fp); + + } + + vdmx->offset = ttfMakeUSHORT (vdmx->numRatios, fp); + + vdmx->groups = XCALLOC (vdmx->numRecs, Vdmx); + for (i=0;i<vdmx->numRecs;i++) + { + int j; + (vdmx->groups+i)->recs = ttfGetUSHORT(fp); + (vdmx->groups+i)->startsz = ttfGetBYTE(fp); + (vdmx->groups+i)->endsz = ttfGetBYTE(fp); + + (vdmx->groups+i)->entry = XCALLOC ((vdmx->groups+i)->recs, vTable); + + for (j=0;j<(vdmx->groups+i)->recs;j++) + { + ((vdmx->groups+i)->entry+j)->yPelHeight = ttfGetUSHORT(fp); + ((vdmx->groups+i)->entry+j)->yMax = ttfGetSHORT(fp); + ((vdmx->groups+i)->entry+j)->yMin = ttfGetSHORT(fp); + } + } +} + +void ttfPrintVDMX(FILE *fp,VDMXPtr vdmx) +{ + int i; + + fprintf(fp,"'VDMX' Table - Precomputed Vertical Device Metrics\n"); + fprintf(fp,"--------------------------------------------------\n"); + + + fprintf(fp,"Version:\t %d\n", vdmx->version); + fprintf(fp,"Number of Hgt Records:\t %d\n",vdmx->numRecs); + fprintf(fp,"Number of Ratio Records:\t %d\n",vdmx->numRecs); + + for (i=0;i<vdmx->numRatios;i++) + { + fprintf(fp,"\t Ratio Record #%d\n",i+1); + fprintf(fp,"\t\t CharSetId \t %d\n",(vdmx->ratRange+i)->CharSet); + fprintf(fp,"\t\t xRatio \t %d\n",(vdmx->ratRange+i)->xRatio); + fprintf(fp,"\t\t yStartRatio \t %d\n",(vdmx->ratRange+i)->yStartRatio); + fprintf(fp,"\t\t yEndRatio \t %d\n",(vdmx->ratRange+i)->yEndRatio); + fprintf(fp,"\t\t Record Offset %d (group #%d)\n\n",vdmx->offset[i],i); + } + + fprintf(fp,"\t VDMX Height Record Groups\n"); + fprintf(fp,"\t -------------------------\n\n"); + + for (i=0;i<vdmx->numRecs;i++) + { + int j; + + fprintf(fp,"\t %d. Number of Hgt Records %d\n",i, + (vdmx->groups+i)->recs); + fprintf(fp,"\t Starting Y Pel Height %d\n", + (vdmx->groups+i)->startsz); + fprintf(fp,"\t Ending Y Pel Height %d\n", + (vdmx->groups+i)->endsz); + + for (j=0;j<(vdmx->groups+i)->recs;j++) + { + fprintf(fp,"\t\t %d. Pel Height= %d\n",j+1, + ((vdmx->groups+i)->entry+j)->yPelHeight); + fprintf(fp,"\t\t yMax= \t %d\n", + ((vdmx->groups+i)->entry+j)->yMax); + fprintf(fp,"\t\t yMin= \t %d\n\n", + ((vdmx->groups+i)->entry+j)->yMin); + } + } + +} + +void ttfFreeVDMX(VDMXPtr vdmx) +{ + int i; + if (vdmx != NULL) + { + for (i=0;i<vdmx->numRecs;i++) + { + free((vdmx->groups+i)->entry); + } + free(vdmx->ratRange); + free(vdmx->offset); + free(vdmx->groups); + free(vdmx); + } +} |