~ubuntu-branches/ubuntu/jaunty/texlive-bin/jaunty

« back to all changes in this revision

Viewing changes to build/source/texk/ttfdump/libttf/gasp.c

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2008-06-26 23:14:59 UTC
  • mfrom: (2.1.30 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080626231459-y02rjsrgtafu83yr
Tags: 2007.dfsg.2-3
add missing source roadmap.fig of roadmap.eps in fontinst documentation
(Closes: #482915) (urgency medium due to RC bug)
(new patch add-missing-fontinst-source)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* gasp.c -- Grid-fitting And Scan-conversion Procedure
 
2
 * Copyright (C) 1996 Li-Da Lho, All right reserved 
 
3
 */
 
4
#include <stdio.h>
 
5
#include <stdlib.h>
 
6
#include "config.h"
 
7
#include "ttf.h"
 
8
#include "ttfutil.h"
 
9
 
 
10
#ifdef MEMCHECK
 
11
#include <dmalloc.h>
 
12
#endif
 
13
 
 
14
/*      $Id: gasp.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $   */
 
15
 
 
16
#ifndef lint
 
17
static char vcid[] = "$Id: gasp.c,v 1.1.1.1 1998/06/05 07:47:52 robert Exp $";
 
18
#endif /* lint */
 
19
 
 
20
static GASPPtr ttfAllocGASP(TTFontPtr font);
 
21
static void ttfLoadGASP(FILE *fp,GASPPtr gasp,ULONG offset);
 
22
 
 
23
void ttfInitGASP(TTFontPtr font)
 
24
{
 
25
    ULONG tag = 'g' | 'a' << 8 | 's' << 16 | 'p' << 24;
 
26
    TableDirPtr ptd;
 
27
     
 
28
    if ((ptd = ttfLookUpTableDir(tag,font)) != NULL)
 
29
        {
 
30
            font->gasp = ttfAllocGASP(font);
 
31
            ttfLoadGASP(font->fp,font->gasp,ptd->offset);
 
32
        }
 
33
}
 
34
static GASPPtr ttfAllocGASP(TTFontPtr font)
 
35
{
 
36
    GASPPtr gasp;
 
37
    
 
38
    if ((gasp = (GASPPtr) calloc(1,sizeof(GASP))) == NULL)
 
39
        {
 
40
            ttfError("Out of Memory in __FILE__:__LINE__\n");
 
41
            return NULL;
 
42
        }
 
43
    return gasp;
 
44
}
 
45
static void ttfLoadGASP (FILE *fp,GASPPtr gasp,ULONG offset)
 
46
{
 
47
    int i;
 
48
 
 
49
    if (fseek(fp,offset,SEEK_SET) !=0)
 
50
        ttfError("Fseek Failed in ttfLoadGASP \n");     
 
51
    
 
52
    gasp->version = ttfGetUSHORT(fp);
 
53
    gasp->numRanges = ttfGetUSHORT(fp);
 
54
    
 
55
    gasp->gaspRange = (GASPRANGE *) calloc(gasp->numRanges, sizeof(GASPRANGE));
 
56
    
 
57
    if (gasp->gaspRange == NULL)
 
58
        ttfError("Out of Memory in __FILE__:__LINE__\n");
 
59
    else
 
60
        for (i=0;i<gasp->numRanges;i++)
 
61
            {
 
62
                gasp->gaspRange[i].rangeMaxPPEM = ttfGetUSHORT(fp);
 
63
                gasp->gaspRange[i].rangeGaspBehavior = ttfGetUSHORT(fp);
 
64
            }
 
65
}
 
66
 
 
67
void ttfPrintGASP(FILE *fp,GASPPtr gasp)
 
68
{
 
69
    int i;
 
70
 
 
71
    fprintf(fp,"'gasp' Table - Grid-fitting And Scan-conversion Procedure\n"); 
 
72
    fprintf(fp,"---------------------------------------------------------\n");
 
73
 
 
74
    fprintf(fp,"'gasp' version:\t %d\n",gasp->version);
 
75
    fprintf(fp,"numRanges: \t %d\n\n",gasp->numRanges);
 
76
 
 
77
    for (i=0;i<gasp->numRanges;i++)
 
78
        {
 
79
            fprintf(fp,"\t gasp Range %d\n",i);
 
80
            fprintf(fp,"\t rangeMaxPPEM:\t %d\n",
 
81
                    gasp->gaspRange[i].rangeMaxPPEM);
 
82
            fprintf(fp,"\t rangeGaspBehavior:\t 0x%04x\n\n",
 
83
                    gasp->gaspRange[i].rangeGaspBehavior);
 
84
        }
 
85
    fprintf(fp,"\n");
 
86
}
 
87
 
 
88
void ttfFreeGASP(GASPPtr gasp)
 
89
{
 
90
    if (gasp != NULL)
 
91
        {
 
92
            free(gasp->gaspRange);
 
93
            free(gasp);
 
94
        }
 
95
}