Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this user
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
donald
/
evince
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
0
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security
Insights
Files
19a00ed
backend
comics
djvu
dvi
mdvi-lib
Makefile.am
afmparse.c
afmparse.h
bitmap.c
bitmap.h
color.c
color.h
common.c
common.h
defaults.h
dvimisc.c
dviopcodes.h
dviread.c
files.c
font.c
fontmap.c
fontmap.h
fontsrch.c
gf.c
hash.c
hash.h
list.c
mdvi.h
pagesel.c
paper.c
paper.h
pk.c
private.h
setup.c
sp-epsf.c
special.c
sysdeps.h
t1.c
tfm.c
tfmfile.c
tt.c
util.c
vf.c
Makefile.am
cairo-device.c
cairo-device.h
dvi-document.c
dvi-document.h
dvidocument.evince-backend.in
fonts.c
fonts.h
texmfcnf.c
texmfcnf.h
impress
pdf
pixbuf
ps
tiff
Makefile.am
backend.symbols
cut-n-paste
data
help
libdocument
libmisc
libview
po
previewer
properties
shell
test
thumbnailer
AUTHORS
COPYING
ChangeLog.pre-git
MAINTAINERS
Makefile.am
NEWS
NOTES
README
README.commits
TODO
autogen.sh
configure.ac
evince-document.h
evince-document.pc.in
evince-view.h
evince-view.pc.in
evince.doap
git.mk
Breadcrumbs
evince
/
backend
/
dvi
/
mdvi-lib
/
tfm.c
Blame
Blame
Latest commit
History
History
214 lines (190 loc) · 5.41 KB
Breadcrumbs
evince
/
backend
/
dvi
/
mdvi-lib
/
tfm.c
Top
File metadata and controls
Code
Blame
214 lines (190 loc) · 5.41 KB
Raw
/* * Copyright (C) 2000, Matias Atria * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include <config.h> #include <stdlib.h> #include <stdarg.h> #include <string.h> #include <sys/stat.h> #include <unistd.h> #include "mdvi.h" #include "private.h" static int tfm_load_font __PROTO((DviParams *, DviFont *)); static int tfm_font_get_glyph __PROTO((DviParams *, DviFont *, int)); DviFontInfo tfm_font_info = { "TFM", 0, /* scaling not supported by format */ tfm_load_font, tfm_font_get_glyph, mdvi_shrink_box, mdvi_shrink_box, NULL, /* free */ NULL, /* reset */ NULL, /* lookup */ kpse_tfm_format, NULL }; DviFontInfo ofm_font_info = { "OFM", 0, /* scaling not supported by format */ tfm_load_font, tfm_font_get_glyph, mdvi_shrink_box, mdvi_shrink_box, NULL, /* free */ NULL, /* reset */ NULL, /* lookup */ kpse_ofm_format, NULL }; DviFontInfo afm_font_info = { "AFM", 0, /* scaling not supported by format */ tfm_load_font, tfm_font_get_glyph, mdvi_shrink_box, mdvi_shrink_box, NULL, /* free */ NULL, /* reset */ NULL, /* lookup */ kpse_afm_format, NULL }; #define TYPENAME(font) \ ((font)->search.info ? (font)->search.info : "none") /* * Although it does not seem that way, this conversion is independent of the * shrinking factors, within roundoff (that's because `conv' and `vconv' * have already been scaled by hshrink and vshrink, repsectively). We * should really use `dviconv' and `dvivconv', but I'm not so sure those * should be moved to the DviParams structure. */ #define XCONV(x) FROUND(params->conv * (x) * params->hshrink) #define YCONV(y) FROUND(params->vconv * (y) * params->vshrink) /* this is used quite often in several places, so I made it standalone */ int get_tfm_chars(DviParams *params, DviFont *font, TFMInfo *info, int loaded) { Int32 z, alpha, beta; int n; DviFontChar *ch; TFMChar *ptr; n = info->hic - info->loc + 1; if(n != FONT_GLYPH_COUNT(font)) { font->chars = mdvi_realloc(font->chars, n * sizeof(DviFontChar)); } font->loc = info->loc; font->hic = info->hic; ch = font->chars; ptr = info->chars; /* Prepare z, alpha and beta for TFM width computation */ TFMPREPARE(font->scale, z, alpha, beta); /* get the character metrics */ for(n = info->loc; n <= info->hic; ch++, ptr++, n++) { int a, b, c, d; ch->offset = ptr->present; if(ch->offset == 0) continue; /* this is what we came here for */ ch->tfmwidth = TFMSCALE(z, ptr->advance, alpha, beta); /* scale all other TFM units (so they are in DVI units) */ a = TFMSCALE(z, ptr->left, alpha, beta); b = TFMSCALE(z, ptr->right, alpha, beta); c = TFMSCALE(z, ptr->height, alpha, beta); d = TFMSCALE(z, ptr->depth, alpha, beta); /* now convert to unscaled pixels */ ch->width = XCONV(b - a); ch->height = YCONV(c - d); if(ch->height < 0) ch->height = -ch->height; ch->x = XCONV(a); ch->y = YCONV(c); /* * the offset is not used, but we might as well set it to * something meaningful (and it MUST be non-zero) */ ch->flags = 0; ch->code = n; ch->glyph.data = NULL; ch->grey.data = NULL; ch->shrunk.data = NULL; ch->loaded = loaded; } return 0; } /* * We use this function as a last resort to find the character widths in a * font The DVI rendering code can correctly skip over a glyph if it knows * its TFM width, which is what we try to find here. */ static int tfm_load_font(DviParams *params, DviFont *font) { TFMInfo *tfm; int type; switch(font->search.info->kpse_type) { case kpse_tfm_format: type = DviFontTFM; break; case kpse_afm_format: type = DviFontAFM; break; case kpse_ofm_format: type = DviFontOFM; break; default: return -1; } /* we don't need this */ if(font->in) { fclose(font->in); font->in = NULL; } tfm = get_font_metrics(font->fontname, type, font->filename); if(tfm == NULL) return -1; if(tfm->checksum && font->checksum && tfm->checksum != font->checksum) { mdvi_warning(_("%s: Checksum mismatch (got %u, expected %u)\n"), font->fontname, (unsigned)tfm->checksum, (unsigned)font->checksum); } font->checksum = tfm->checksum; font->design = tfm->design; font->loc = 0; font->hic = 0; font->chars = NULL; get_tfm_chars(params, font, tfm, 1); /* free everything */ free_font_metrics(tfm); return 0; } static int tfm_font_get_glyph(DviParams *params, DviFont *font, int code) { DviFontChar *ch; ch = FONTCHAR(font, code); if(!glyph_present(ch)) return -1; ch->glyph.x = ch->x; ch->glyph.y = ch->y; ch->glyph.w = ch->width; ch->glyph.h = ch->height; /* * This has two purposes: (1) avoid unnecessary calls to this function, * and (2) detect when the glyph data for a TFM font is actually used * (we'll get a SEGV). Any occurrence of that is a bug. */ ch->glyph.data = MDVI_GLYPH_EMPTY; return 0; }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
You can’t perform that action at this time.