2
* drv_tfm.c - A font driver for TFM fonts.
4
* 30 Sep 1996 First version.
5
* 17 Jan 1997 for VFlib 3.1
6
* 24 Feb 1997 Changed metric computation.
7
* 26 Feb 1997 Added 'query_font_type'.
8
* 4 Aug 1997 VFlib 3.3 Changed API.
9
* 1 Feb 1998 for VFlib 3.4
10
* 21 Apr 1998 Debugged get_font_prop().
13
* Copyright (C) 1996-1998 by Hirotsugu Kakugawa.
14
* All rights reserved.
16
* This file is part of the VFlib Library. This library is free
17
* software; you can redistribute it and/or modify it under the terms of
18
* the GNU Library General Public License as published by the Free
19
* Software Foundation; either version 2 of the License, or (at your
20
* option) any later version. This library is distributed in the hope
21
* that it will be useful, but WITHOUT ANY WARRANTY; without even the
22
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
23
* PURPOSE. See the GNU Library General Public License for more details.
24
* You should have received a copy of the GNU Library General Public
25
* License along with this library; if not, write to the Free Software
26
* Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
36
#include "VFlib-3_6.h"
63
typedef struct s_font_tfm *FONT_TFM;
66
Private SEXP_LIST default_fontdirs;
67
Private SEXP_LIST default_extensions;
68
Private SEXP_STRING default_glyph_style;
69
Private int v_default_glyph_style;
70
Private SEXP_STRING default_point_size;
71
Private double v_default_point_size;
72
Private SEXP_STRING default_pixel_size;
73
Private double v_default_pixel_size;
74
Private SEXP_STRING default_dpi;
75
Private double v_default_dpi_x, v_default_dpi_y;
76
Private SEXP_STRING default_aspect;
77
Private double v_default_aspect;
78
Private SEXP_ALIST default_properties;
79
Private SEXP_ALIST default_variables;
80
Private SEXP_STRING default_debug_mode;
83
Private int tfm_create(VF_FONT,char*,char*,int,SEXP);
84
Private int tfm_close(VF_FONT);
85
Private int tfm_get_metric1(VF_FONT,long,VF_METRIC1,double,double);
86
Private int tfm_get_metric2(VF_FONT,long,VF_METRIC2,double,double);
87
Private int tfm_get_fontbbx1(VF_FONT,double,double,
88
double*,double*,double*,double*);
89
Private int tfm_get_fontbbx2(VF_FONT,double,double,
91
Private VF_BITMAP tfm_get_bitmap1(VF_FONT,long,double,double);
92
Private VF_BITMAP tfm_get_bitmap2(VF_FONT,long,double,double);
93
Private VF_OUTLINE tfm_get_outline(VF_FONT,long,double,double);
94
Private char* tfm_get_font_prop(VF_FONT,char*);
99
VF_Init_Driver_TFM(void)
101
struct s_capability_table ct[20];
105
/* VF_CAPE_FONT_DIRECTORIES */
106
ct[z].cap = VF_CAPE_FONT_DIRECTORIES; ct[z].type = CAPABILITY_LIST;
107
ct[z].ess = CAPABILITY_OPTIONAL; ct[z++].val = &default_fontdirs;
108
/* VF_CAPE_EXTENSIONS */
109
ct[z].cap = VF_CAPE_EXTENSIONS; ct[z].type = CAPABILITY_LIST;
110
ct[z].ess = CAPABILITY_OPTIONAL; ct[z++].val = &default_extensions;
111
/* VF_CAPE_TEX_GLYPH_STYLE */
112
ct[z].cap = VF_CAPE_TEX_GLYPH_STYLE; ct[z].type = CAPABILITY_STRING;
113
ct[z].ess = CAPABILITY_OPTIONAL; ct[z++].val = &default_glyph_style;
114
/* VF_CAPE_POINT_SIZE */
115
ct[z].cap = VF_CAPE_POINT_SIZE; ct[z].type = CAPABILITY_STRING;
116
ct[z].ess = CAPABILITY_OPTIONAL; ct[z++].val = &default_point_size;
117
/* VF_CAPE_PIXEL_SIZE */
118
ct[z].cap = VF_CAPE_PIXEL_SIZE; ct[z].type = CAPABILITY_STRING;
119
ct[z].ess = CAPABILITY_OPTIONAL; ct[z++].val = &default_pixel_size;
121
ct[z].cap = VF_CAPE_DPI; ct[z].type = CAPABILITY_STRING;
122
ct[z].ess = CAPABILITY_OPTIONAL; ct[z++].val = &default_dpi;
123
/* VF_CAPE_ASPECT_RATIO */
124
ct[z].cap = VF_CAPE_ASPECT_RATIO; ct[z].type = CAPABILITY_STRING;
125
ct[z].ess = CAPABILITY_OPTIONAL; ct[z++].val = &default_aspect;
126
/* VF_CAPE_PROPERTIES */
127
ct[z].cap = VF_CAPE_PROPERTIES; ct[z].type = CAPABILITY_ALIST;
128
ct[z].ess = CAPABILITY_OPTIONAL; ct[z++].val = &default_properties;
129
/* VF_CAPE_VARIABLE_VALUES */
130
ct[z].cap = VF_CAPE_VARIABLE_VALUES; ct[z].type = CAPABILITY_ALIST;
131
ct[z].ess = CAPABILITY_OPTIONAL; ct[z++].val = &default_variables;
133
ct[z].cap = VF_CAPE_DEBUG; ct[z].type = CAPABILITY_STRING;
134
ct[z].ess = CAPABILITY_OPTIONAL; ct[z++].val = &default_debug_mode;
136
ct[z].cap = NULL; ct[z].type = 0; ct[z].ess = 0; ct[z++].val = NULL;
139
if (vf_cap_GetParsedClassDefault(FONTCLASS_NAME_TFM, ct,
140
vf_tex_default_variables, NULL)
141
== VFLIBCAP_PARSED_ERROR)
144
if (default_extensions == NULL)
145
default_extensions = vf_sexp_cstring2list(DEFAULT_EXTENSIONS_TFM);
147
v_default_glyph_style = TEX_GLYPH_STYLE_EMPTY;
148
if (default_glyph_style != NULL)
149
v_default_glyph_style
150
= vf_tex_parse_glyph_style(vf_sexp_get_cstring(default_glyph_style),
151
TEX_GLYPH_STYLE_EMPTY);
153
v_default_point_size = -1;
154
if (default_point_size != NULL)
155
v_default_point_size = atof(vf_sexp_get_cstring(default_point_size));
157
v_default_pixel_size = -1;
158
if (default_pixel_size != NULL)
159
v_default_pixel_size = atof(vf_sexp_get_cstring(default_pixel_size));
161
v_default_dpi_x = -1;
162
v_default_dpi_y = -1;
163
if (default_dpi != NULL)
164
v_default_dpi_x = v_default_dpi_y = atof(vf_sexp_get_cstring(default_dpi));
166
v_default_aspect = 1.0;
167
if (default_aspect != NULL)
168
v_default_aspect = atof(vf_sexp_get_cstring(default_aspect));
173
VF_InstallFontDriver(FONTCLASS_NAME_TFM, (DRIVER_FUNC_TYPE)tfm_create);
179
tfm_create(VF_FONT font, char *font_class,
180
char *font_name, int implicit, SEXP entry)
183
char *font_file, *tfm_path, *p;
185
SEXP cap_ffile, cap_glyph_style, cap_point, cap_pixel;
186
SEXP cap_dpi, cap_mag, cap_aspect, cap_props;
187
struct s_capability_table ct[20];
191
/* VF_CAPE_FONT_CLASS */
192
ct[z].cap = VF_CAPE_FONT_CLASS; ct[z].type = CAPABILITY_STRING;
193
ct[z].ess = CAPABILITY_ESSENTIAL; ct[z++].val = NULL;
194
/* VF_CAPE_FONT_FILE */
195
ct[z].cap = VF_CAPE_FONT_FILE; ct[z].type = CAPABILITY_STRING;
196
ct[z].ess = CAPABILITY_OPTIONAL; ct[z++].val = &cap_ffile;
197
/* VF_CAPE_TEX_GLYPH_STYLE */
198
ct[z].cap = VF_CAPE_TEX_GLYPH_STYLE; ct[z].type = CAPABILITY_STRING;
199
ct[z].ess = CAPABILITY_OPTIONAL; ct[z++].val = &cap_glyph_style;
200
/* VF_CAPE_POINT_SIZE */
201
ct[z].cap = VF_CAPE_POINT_SIZE; ct[z].type = CAPABILITY_STRING;
202
ct[z].ess = CAPABILITY_OPTIONAL; ct[z++].val = &cap_point;
203
/* VF_CAPE_PIXEL_SIZE */
204
ct[z].cap = VF_CAPE_PIXEL_SIZE; ct[z].type = CAPABILITY_STRING;
205
ct[z].ess = CAPABILITY_OPTIONAL; ct[z++].val = &cap_pixel;
207
ct[z].cap = VF_CAPE_DPI; ct[z].type = CAPABILITY_STRING;
208
ct[z].ess = CAPABILITY_OPTIONAL; ct[z++].val = &cap_dpi;
210
ct[z].cap = VF_CAPE_MAG; ct[z].type = CAPABILITY_STRING;
211
ct[z].ess = CAPABILITY_OPTIONAL; ct[z++].val = &cap_mag;
212
/* VF_CAPE_ASPECT_RATIO */
213
ct[z].cap = VF_CAPE_ASPECT_RATIO; ct[z].type = CAPABILITY_STRING;
214
ct[z].ess = CAPABILITY_OPTIONAL; ct[z++].val = &cap_aspect;
215
/* VF_CAPE_PROPERTIES */
216
ct[z].cap = VF_CAPE_PROPERTIES; ct[z].type = CAPABILITY_ALIST;
217
ct[z].ess = CAPABILITY_OPTIONAL; ct[z++].val = &cap_props;
219
ct[z].cap = NULL; ct[z].type = 0; ct[z].ess = 0; ct[z++].val = NULL;
222
if (implicit == 1){ /* implicit font */
223
font_file = font_name;
224
} else { /* explicit font */
225
if (vf_cap_GetParsedFontEntry(entry, font_name, ct,
226
default_variables, vf_tex_default_variables)
227
== VFLIBCAP_PARSED_ERROR)
229
if (cap_ffile == NULL){
230
/* Use font name as font file name if font file name is not given. */
231
font_file = font_name;
233
font_file = vf_sexp_get_cstring(cap_ffile);
237
font->font_type = VF_FONT_TYPE_BITMAP;
238
font->get_metric1 = tfm_get_metric1;
239
font->get_metric2 = tfm_get_metric2;
240
font->get_fontbbx1 = tfm_get_fontbbx1;
241
font->get_fontbbx2 = tfm_get_fontbbx2;
242
font->get_bitmap1 = tfm_get_bitmap1;
243
font->get_bitmap2 = tfm_get_bitmap2;
244
font->get_outline = tfm_get_outline;
245
font->get_font_prop = tfm_get_font_prop;
246
font->query_font_type = NULL;
247
font->close = tfm_close;
251
ALLOC_IF_ERR(font_tfm, struct s_font_tfm)
253
font->private = font_tfm;
255
font_tfm->tfm = NULL;
256
font_tfm->font_name = NULL;
257
font_tfm->font_file = NULL;
258
font_tfm->point_size = v_default_point_size;
259
font_tfm->pixel_size = v_default_pixel_size;
260
font_tfm->glyph_style= v_default_glyph_style;
261
font_tfm->dpi_x = v_default_dpi_x;
262
font_tfm->dpi_y = v_default_dpi_y;
264
font_tfm->aspect = v_default_aspect;
265
font_tfm->props = NULL;
268
if (cap_point != NULL)
269
font_tfm->point_size = atof(vf_sexp_get_cstring(cap_point));
270
if (cap_pixel != NULL)
271
font_tfm->pixel_size = atof(vf_sexp_get_cstring(cap_pixel));
272
if (cap_glyph_style != NULL){
273
if (strcmp(vf_sexp_get_cstring(cap_glyph_style),
274
TEX_GLYPH_STYLE_EMPTY_STR) == 0)
275
font_tfm->glyph_style = TEX_GLYPH_STYLE_EMPTY;
276
else if (strcmp(vf_sexp_get_cstring(cap_glyph_style),
277
TEX_GLYPH_STYLE_FILL_STR) == 0)
278
font_tfm->glyph_style = TEX_GLYPH_STYLE_FILL;
281
font_tfm->dpi_x = font_tfm->dpi_y = atof(vf_sexp_get_cstring(cap_dpi));
283
font_tfm->mag = atof(vf_sexp_get_cstring(cap_mag));
284
if (cap_aspect != NULL)
285
font_tfm->aspect = atof(vf_sexp_get_cstring(cap_aspect));
286
if (cap_props != NULL)
287
font_tfm->props = cap_props;
290
if ((font_tfm->font_file = vf_strdup(font_file)) == NULL)
292
if ((font_tfm->font_name = vf_strdup(font_name)) == NULL)
296
/* Parse font name. Formats of file names that this routine supports:
297
* "cmr10.300XX" - A "cmr10" font for 300 dpi.
298
* "cmr10.XX" - A "cmr10" font. Dpi value is default value.
300
* ("XX" can be any string such as "pk", "gf", and "tfm".)
302
p = vf_index(font_tfm->font_file, '.');
303
if ((p != NULL) && (isdigit((int)*(p+1)))){ /* "cmr10.300tfm" */
305
if ((font_tfm->dpi_x < 0) || (font_tfm->dpi_y < 0)){
306
font_tfm->dpi_x = (double)dev_dpi;
307
font_tfm->dpi_y = (double)dev_dpi;
309
} else { /* "cmr10" or "cmr10.tfm" */
313
tfm_path = vf_tex_search_file_tfm(font_tfm->font_file,
314
default_fontdirs, default_extensions);
316
printf("* TFM: %s ==> %s\n", font_name, tfm_path);
318
if (tfm_path == NULL)
321
font_tfm->tfm = vf_tfm_open(tfm_path);
323
if (font_tfm->tfm == NULL)
327
vf_sexp_free2(&cap_ffile, &cap_glyph_style);
328
vf_sexp_free2(&cap_point, &cap_pixel);
329
vf_sexp_free3(&cap_dpi, &cap_mag, &cap_aspect);
336
vf_error = VF_ERR_NO_MEMORY;
339
vf_sexp_free2(&cap_ffile, &cap_glyph_style);
340
vf_sexp_free2(&cap_point, &cap_pixel);
341
vf_sexp_free3(&cap_dpi, &cap_mag, &cap_aspect);
349
tfm_close(VF_FONT font)
353
font_tfm = (FONT_TFM)font->private;
354
if (font_tfm != NULL){
355
vf_tfm_free(font_tfm->tfm);
356
vf_free(font_tfm->font_name);
357
vf_free(font_tfm->font_file);
358
vf_sexp_free1(&font_tfm->props);
366
tfm_get_metric1(VF_FONT font, long code_point, VF_METRIC1 metric,
367
double mag_x, double mag_y)
371
double mx, my, ps, f;
373
if ( (metric == NULL)
374
|| ((font_tfm = (FONT_TFM)font->private) == NULL)
375
|| ((tfm = font_tfm->tfm) == NULL) ){
376
fprintf(stderr, "VFlib internal error: tfm_get_metric1()\n");
380
if (vf_tfm_metric(tfm, code_point, metric) == NULL)
383
if ((ps = font->point_size) < 0)
384
if ((ps = font_tfm->point_size) < 0)
387
if ((ps < 0) || (tfm->design_size < 1.0e-3)){
388
mx = mag_x * font->mag_x * font_tfm->mag;
389
my = mag_y * font->mag_y * font_tfm->mag;
391
f = ps / tfm->design_size;
392
mx = mag_x * font->mag_x * font_tfm->mag * f;
393
my = mag_y * font->mag_y * font_tfm->mag * f;
396
metric->bbx_width *= mx;
397
metric->bbx_height *= my;
407
tfm_get_fontbbx1(VF_FONT font, double mag_x, double mag_y,
408
double *w_p, double *h_p, double *xoff_p, double *yoff_p)
412
double mx, my, ps, f;
414
if (((font_tfm = (FONT_TFM)font->private) == NULL)
415
|| ((tfm = font_tfm->tfm) == NULL) ){
416
fprintf(stderr, "VFlib internal error: tfm_get_fontbbx1()\n");
420
if ((ps = font->point_size) < 0)
421
if ((ps = font_tfm->point_size) < 0)
424
if ((ps < 0) || (tfm->design_size < 1.0e-3)){
425
mx = mag_x * font->mag_x * font_tfm->mag;
426
my = mag_y * font->mag_y * font_tfm->mag;
428
f = ps / tfm->design_size;
429
mx = mag_x * font->mag_x * font_tfm->mag * f;
430
my = mag_y * font->mag_y * font_tfm->mag * f;
433
*w_p = tfm->font_bbx_w * mx;
434
*h_p = tfm->font_bbx_h * my;
435
*xoff_p = tfm->font_bbx_xoff * mx;
436
*yoff_p = tfm->font_bbx_yoff * my;
442
tfm_get_bitmap1(VF_FONT font, long code_point,
443
double mag_x, double mag_y)
448
struct vf_s_metric1 met;
450
if ((font_tfm = (FONT_TFM)font->private) == NULL){
451
fprintf(stderr, "VFlib internal error: tfm_get_bitmap1()\n");
455
if (tfm_get_metric1(font, code_point, &met, mag_x, mag_y) < 0)
458
if (((dpi_x = font->dpi_x) < 0) || ((dpi_y = font->dpi_y) < 0)){
459
if (((dpi_x = font_tfm->dpi_x) < 0) || ((dpi_y = font_tfm->dpi_y) < 0)){
460
dpi_x = vf_tex_default_dpi();
461
dpi_y = vf_tex_default_dpi();
465
bm = vf_alloc_bitmap_with_metric1(&met, dpi_x, dpi_y);
467
switch (font_tfm->glyph_style){
469
case TEX_GLYPH_STYLE_EMPTY:
471
case TEX_GLYPH_STYLE_FILL:
480
tfm_get_outline(VF_FONT font, long code_point,
481
double mag_x, double mag_y)
486
double dpi_x, dpi_y, bbx, ps;
487
int size, x1, y1, x2, y2, index;
488
struct vf_s_metric1 met;
490
if ( ((font_tfm = (FONT_TFM)font->private) == NULL)
491
|| ((tfm = font_tfm->tfm) == NULL) ){
492
fprintf(stderr, "VFlib internal error: tfm_get_outline()\n");
496
if (tfm_get_metric1(font, code_point, &met, mag_x, mag_y) < 0)
499
if ((ps = font->point_size) < 0)
500
if ((ps = font_tfm->point_size) < 0)
501
ps = tfm->design_size;
503
if (((dpi_x = font->dpi_x) < 0) || ((dpi_y = font->dpi_y) < 0)){
504
if (((dpi_x = font_tfm->dpi_x) < 0) || ((dpi_y = font_tfm->dpi_y) < 0)){
505
dpi_x = vf_tex_default_dpi();
506
dpi_y = vf_tex_default_dpi();
510
if ((bbx = tfm->font_bbx_w) < tfm->font_bbx_h)
511
bbx = tfm->font_bbx_h;
513
size = VF_OL_OUTLINE_HEADER_SIZE_TYPE0 + 6;
514
if ((ol = (VF_OUTLINE)calloc(size, sizeof(VF_OUTLINE_ELEM))) == NULL){
515
vf_error = VF_ERR_NO_MEMORY;
519
ol[VF_OL_HEADER_INDEX_HEADER_TYPE] = VF_OL_OUTLINE_HEADER_TYPE0;
520
ol[VF_OL_HEADER_INDEX_DATA_SIZE] = size;
521
ol[VF_OL_HEADER_INDEX_DPI_X] = VF_OL_HEADER_ENCODE(dpi_x);
522
ol[VF_OL_HEADER_INDEX_DPI_Y] = VF_OL_HEADER_ENCODE(dpi_y);
523
ol[VF_OL_HEADER_INDEX_POINT_SIZE] = VF_OL_HEADER_ENCODE(ps);
524
ol[VF_OL_HEADER_INDEX_EM] = VF_OL_COORD_RANGE;
525
ol[VF_OL_HEADER_INDEX_MAX_X] = VF_OL_COORD_RANGE * met.bbx_width/bbx;
526
ol[VF_OL_HEADER_INDEX_MAX_Y] = VF_OL_COORD_RANGE * met.bbx_height/bbx;
527
ol[VF_OL_HEADER_INDEX_REF_X] = VF_OL_COORD_RANGE * (0.0 - met.off_x/bbx);
528
ol[VF_OL_HEADER_INDEX_REF_Y] = VF_OL_COORD_RANGE * met.off_y/bbx;
529
ol[VF_OL_HEADER_INDEX_MV_X] = VF_OL_COORD_RANGE * met.mv_x/bbx;
530
ol[VF_OL_HEADER_INDEX_MV_Y] = VF_OL_COORD_RANGE * met.mv_y/bbx;
532
x1 = VF_OL_COORD_OFFSET + 0;
533
x2 = VF_OL_COORD_OFFSET + VF_OL_COORD_RANGE * met.bbx_width / bbx;
534
y1 = VF_OL_COORD_OFFSET + 0;
535
y2 = VF_OL_COORD_OFFSET + VF_OL_COORD_RANGE * met.bbx_height / bbx;
537
index = VF_OL_OUTLINE_HEADER_SIZE_TYPE0;
538
ol[index++] = VF_OL_INSTR_TOKEN | VF_OL_INSTR_CCWCURV
539
| VF_OL_INSTR_LINE | VF_OL_INSTR_CHAR;
540
ol[index++] = VF_OL_MAKE_XY(x1, y1);
541
ol[index++] = VF_OL_MAKE_XY(x1, y2);
542
ol[index++] = VF_OL_MAKE_XY(x2, y2);
543
ol[index++] = VF_OL_MAKE_XY(x2, y1);
550
tfm_get_metric2(VF_FONT font, long code_point, VF_METRIC2 metric,
551
double mag_x, double mag_y)
555
struct vf_s_metric1 met1;
557
double dpi_x, dpi_y, mx, my;
559
if ( (metric == NULL)
560
|| ((font_tfm = (FONT_TFM)font->private) == NULL)
561
|| ((tfm = font_tfm->tfm) == NULL) ){
562
fprintf(stderr, "VFlib internal error in tfm_get_metric2()\n");
566
if (vf_tfm_metric(tfm, code_point, &met1) == NULL)
569
if (((dpi_x = font_tfm->dpi_x) <= 0) || ((dpi_y = font_tfm->dpi_y) <= 0)){
570
dpi_x = vf_tex_default_dpi();
571
dpi_y = vf_tex_default_dpi();
574
if ((ps = font->pixel_size) < 0)
575
if ((ps = font_tfm->pixel_size) < 0)
578
if ((ps < 0) || (tfm->design_size < 1.0e-3)){
579
mx = mag_x * font->mag_x * font_tfm->mag * dpi_x / 72.27;
580
my = mag_y * font->mag_y * font_tfm->mag * dpi_y / 72.27;
582
mx = mag_x * font->mag_x * font_tfm->mag * (ps/tfm->design_size);
583
my = mag_y * font->mag_y * font_tfm->mag * (ps/tfm->design_size);
586
metric->bbx_width = toint(met1.bbx_width * mx);
587
metric->bbx_height = toint(met1.bbx_height * my);
588
metric->off_x = toint(met1.off_x * mx);
589
metric->off_y = toint(met1.off_y * my);
590
metric->mv_x = toint(met1.mv_x * mx);
591
metric->mv_y = toint(met1.mv_y * my);
597
tfm_get_fontbbx2(VF_FONT font, double mag_x, double mag_y,
598
int *w_p, int *h_p, int *xoff_p, int *yoff_p)
603
double dpi_x, dpi_y, mx, my;
605
if (((font_tfm = (FONT_TFM)font->private) == NULL)
606
|| ((tfm = font_tfm->tfm) == NULL) ){
607
fprintf(stderr, "VFlib internal error in tfm_get_fontbbx2()\n");
611
if (((dpi_x = font_tfm->dpi_x) <= 0) || ((dpi_y = font_tfm->dpi_y) <= 0)){
612
dpi_x = vf_tex_default_dpi();
613
dpi_y = vf_tex_default_dpi();
616
if ((ps = font->pixel_size) < 0)
617
if ((ps = font_tfm->pixel_size) < 0)
620
if ((ps < 0) || (tfm->design_size < 1.0e-3)){
621
mx = mag_x * font->mag_x * font_tfm->mag * dpi_x / 72.27;
622
my = mag_y * font->mag_y * font_tfm->mag * dpi_y / 72.27;
624
mx = mag_x * font->mag_x * font_tfm->mag * (ps/tfm->design_size);
625
my = mag_y * font->mag_y * font_tfm->mag * (ps/tfm->design_size);
628
*w_p = toint(tfm->font_bbx_w * mx);
629
*h_p = toint(tfm->font_bbx_h * my);
630
*xoff_p = toint(tfm->font_bbx_xoff * mx);
631
*yoff_p = toint(tfm->font_bbx_yoff * my);
637
tfm_get_bitmap2(VF_FONT font, long code_point,
638
double mag_x, double mag_y)
642
struct vf_s_metric2 met;
644
if ((font_tfm = (FONT_TFM)font->private) == NULL){
645
fprintf(stderr, "VFlib internal error in tfm_get_bitmap2()\n");
649
if (tfm_get_metric2(font, code_point, &met, mag_x, mag_y) < 0)
652
bm = vf_alloc_bitmap_with_metric2(&met);
654
switch (font_tfm->glyph_style){
656
case TEX_GLYPH_STYLE_EMPTY:
658
case TEX_GLYPH_STYLE_FILL:
668
tfm_get_font_prop(VF_FONT font, char *prop_name)
673
double ps, dpi_x, dpi_y;
676
if ( ((font_tfm = (FONT_TFM)font->private) == NULL)
677
|| ((tfm = font_tfm->tfm) == NULL) ){
678
fprintf(stderr, "VFlib internal error in tfm_get_font_prop()\n");
682
if ((v = vf_sexp_assoc(prop_name, font_tfm->props)) != NULL){
683
return vf_strdup(vf_sexp_get_cstring(vf_sexp_cadr(v)));
684
} else if ((v = vf_sexp_assoc(prop_name, default_properties)) != NULL){
685
return vf_strdup(vf_sexp_get_cstring(vf_sexp_cadr(v)));
688
if (((dpi_x = font->dpi_x)<=0) || ((dpi_y = font->dpi_y)<=0)){
689
if (((dpi_x = font_tfm->dpi_x)<=0) || ((dpi_y = font_tfm->dpi_y)<=0)){
690
dpi_x = vf_tex_default_dpi();
691
dpi_y = vf_tex_default_dpi();
695
printf("** %.3f %.3f %.3f %d %.3f %.3f %.3f\n",
696
dpi_x, dpi_y, tfm->design_size,
697
font->pixel_size, font_tfm->pixel_size,
698
font->point_size, font_tfm->point_size);
701
if (font->mode == 1){
702
if ((ps = font->point_size) < 0)
703
if ((ps = font_tfm->point_size) < 0)
704
ps = tfm->design_size;
705
ps = ps * font->mag_y * font_tfm->mag;
706
if (strcmp(prop_name, "POINT_SIZE") == 0){
707
sprintf(str, "%d", toint(ps * 10.0));
708
return vf_strdup(str);
709
} else if (strcmp(prop_name, "PIXEL_SIZE") == 0){
710
sprintf(str, "%d", toint(ps * dpi_y / 72.27));
711
return vf_strdup(str);
712
} else if (strcmp(prop_name, "RESOLUTION_X") == 0){
713
sprintf(str, "%d", toint(dpi_x));
714
return vf_strdup(str);
715
} else if (strcmp(prop_name, "RESOLUTION_Y") == 0){
716
sprintf(str, "%d", toint(dpi_y));
717
return vf_strdup(str);
720
} else if (font->mode == 2){
721
if (strcmp(prop_name, "POINT_SIZE") == 0){
722
if ((ps = font->pixel_size) < 0){
723
if ((ps = font_tfm->pixel_size) < 0){
724
sprintf(str, "%d", toint(tfm->design_size * 10.0
725
* font->mag_y * font_tfm->mag));
726
return vf_strdup(str);
729
ps = ps * font->mag_y * font_tfm->mag;
730
sprintf(str, "%d", toint(ps * 10.0 * 72.27 / dpi_y));
731
return vf_strdup(str);
732
} else if (strcmp(prop_name, "PIXEL_SIZE") == 0){
733
if ((ps = font->pixel_size) < 0)
734
if ((ps = font_tfm->pixel_size) < 0)
735
ps = tfm->design_size * dpi_y / 72.27;
736
ps = ps * font->mag_y * font_tfm->mag;
737
sprintf(str, "%d", toint(ps));
738
return vf_strdup(str);
739
} else if (strcmp(prop_name, "RESOLUTION_X") == 0){
740
sprintf(str, "%d", toint(dpi_x));
741
return vf_strdup(str);
742
} else if (strcmp(prop_name, "RESOLUTION_Y") == 0){
743
sprintf(str, "%d", toint(dpi_y));
744
return vf_strdup(str);