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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 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 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375
|
/*
* DEVICE dependent, TrueType font (FreeType2 lib)
*/
#include "conf.h"
#if defined(FREETYPE) || defined(VFLIB)
#include "defs.h"
#include "emit.h"
#include "global.h"
#include "bifont.h"
#include "rastfont.h"
#include "ps.h"
#ifdef FREETYPE
#include "dvi2ps_freetype.h"
#endif /* FREETYPE */
static struct psbiops po;
#ifdef FREETYPE
/* tfm
*/
dev_ft_begfontdict(fe, maxc)
struct font_entry *fe;
int maxc;
{
if (fe->ncdl == -1) {
fe->k = dev_newdevfont();
EMIT(outfp, "%.3f %d /%s NF\n",
1.0, maxc+1, psfname(fe->k));
fe->ncdl = 0;
}
get_tfm_psbiops(fe, &po);
return psgetfontsize(&po);
}
void
dev_ft_initfontdict(fe, tfmfi, i, w, h, xo, d, pixel)
struct font_entry *fe;
struct tfmfntinfo *tfmfi;
int i;
int w, h, xo, d;
char *pixel;
{
struct tfmchar_entry *ce;
int bw;
end_string();
ce = tfmfi->ch+i;
ce->dev_font = fe->k;
ce->dev_char = i;
dev_setfont(ce->dev_font);
#ifdef DEBUG
if (Debug)
EMIT(outfp, "%% font: %s char: %x\n", fe->n, i);
#endif
bw = (w+7)>>3;
EMITC('[');
if (!pscharbitmap(bw, bw, h, pixel)) {
bw = 1;
h = 1;
}
EMIT(outfp, "\n%d %d %d %d %.3f] %d D\n",
bw<<3, h, xo, d, ((float)ce->tfmw)/(float)hconv, ce->dev_char);
}
dev_fto_begfontdict(fe, famname, mark, maxc, remap)
struct font_entry *fe;
char *famname;
Boolean *mark;
int maxc;
unsigned char *remap;
{
char dictname[STRSIZE];
fe->k = dev_newdevfont();
/* better name wanted */
(void)sprintf(dictname, "%s-TT%d", fe->n, fe->k);
fttobi(tfmfinfo(fe)->tfm_bf, dictname);
get_tfm_psbiops(fe, &po);
tt_type1_prologue1(dictname, famname);
stdex_type1_encoding(mark, maxc, remap);
tt_type1_prologue2();
tt_type1_prologue3();
return psgetfontsize(&po);
}
dev_fto_refontdict(fe)
struct font_entry *fe;
{
fe->k = dev_newdevfont();
get_tfm_psbiops(fe, &po);
psfindfontop(psfname(fe->k), &po);
fe->ncdl = 0;
}
void
dev_fto_initfontdict(i, outline, a)
int i;
FT_Outline *outline;
int a;
{
PS_CharString(outline, stdex_type1_charname(i), a);
}
dev_fto_endfontdict(fe)
struct font_entry *fe;
{
tt_type1_epilogue(500);
psfindfontop(psfname(fe->k), &po);
}
#endif /* FREETYPE */
/* jfm
*/
dev_jft_begfontdict(fe)
struct font_entry *fe;
{
get_jfm_psbiops(fe, &po);
return psgetfontsize(&po);
}
void
dev_jft_initfontdict(fe, jftfi, i, jis, tw, w, h, xo, d, pixel)
struct font_entry *fe;
struct jftfntinfo *jftfi;
int i, jis;
int tw, w, h, xo, d;
char *pixel;
{
struct jftchar_entry *ce;
struct pdlist *pl;
int bw;
end_string();
ce = jftfi->ch+i;
/* open font dict before first char */
if ((pl = getpdlist(CORRNORM))->pl_char == FIRSTPACKPSCHAR)
EMIT(outfp, "%.3f %d /%s NF\n",
1.0, NPACKPSCHARS, psfname(pl->pl_font));
#ifdef STATS
if (fe->ncdl == -1)
fe->ncdl = 0;
#endif
ce->dev_font = pl->pl_font;
ce->dev_char = pl->pl_char;
dev_setfont(ce->dev_font);
#ifdef DEBUG
if (Debug)
EMIT(outfp, "%% font: %s char: %x\n", fe->n, jis);
#endif
bw = (w+7)>>3;
EMITC('[');
if (!pscharbitmap(bw, bw, h, pixel)) {
bw = 1;
h = 1;
}
EMIT(outfp, "\n%d %d %d %d %.3f] %d D\n",
bw<<3, h, xo, d, ((float)tw)/(float)hconv, ce->dev_char);
}
#ifdef FREETYPE
static struct pd pd;
static char *jfntname, *jfamname;
dev_jfto_begfontdict(dictname, famname)
char *dictname, *famname;
{
jfntname = dictname;
jfamname = famname;
initpd(pd);
}
void
dev_jfto_initfontdict(jftfi, i, nc, outline, a)
struct jftfntinfo *jftfi;
int i, nc;
FT_Outline *outline;
int a;
{
struct jftchar_entry *ce;
static char dictname[STRSIZE];
end_string();
ce = jftfi->ch+i;
/* open font dict before first char */
if (getpd(&pd)) {
(void)sprintf(dictname, "%s-TC%d", jfntname, pd.pd_font);
po.po_dev_name = dictname;
jtt_type1_prologue1(dictname, jfamname);
cnum_type1_encoding(nc >= NPACKPSCHARS ? NPACKPSCHARS : nc);
jtt_type1_prologue2();
tt_type1_prologue3();
}
ce->dev_font = pd.pd_font;
ce->dev_char = pd.pd_char;
PS_CharString(outline, cnum_type1_charname(pd.pd_char), a);
if (lastpd(pd))
jfto_endfontdict(pd.pd_font);
}
dev_jfto_endfontdict()
{
if (!lastpd(pd))
jfto_endfontdict(pd.pd_font);
}
jfto_endfontdict(pd_font)
int pd_font;
{
tt_type1_epilogue(1000);
psfindsubfop(psfname(pd_font), &po);
}
#endif /* FREETYPE */
void
dev_jft_initfe(fe)
struct font_entry *fe;
{
DEV_FONT jft_fontdict();
int jft_setchar(), jft_setstring();
int jft_setchar_abs(), jft_setstring_abs();
fe->dev_fontdict = jft_fontdict;
if (bifpos_rel(jfmfinfo(fe)->jfm_bf)) {
fe->dev_setchar = jft_setchar;
fe->dev_setstring = jft_setstring;
} else {
fe->dev_setchar = jft_setchar_abs;
fe->dev_setstring = jft_setstring_abs;
}
}
jft_setchar(c)
int c;
{
struct jftchar_entry *ce;
int cw;
ce = &(jftfinfo(curfontent)->ch[jis_to_idx94(c)]);
begin_string();
pschar(ce->dev_char);
*ps_move += (cw = ce->tfmw);
return cw;
}
/* ARGSUSED */
jft_setstring(s, len)
char *s;
int len;
{
Fatal("%s implementation error: jft_setstring", G_progname);
}
jft_setchar_abs(c)
int c;
{
int cw;
cw = jft_setchar(c);
dev_setposn_abs(ps_h, ps_v);
return cw;
}
/* ARGSUSED */
jft_setstring_abs(s, len)
char *s;
int len;
{
Fatal("%s implementation error: jft_setstring_abs", G_progname);
}
/* jstfm
*/
dev_jsft_begfontdict(fe)
struct font_entry *fe;
{
get_jstfm_psbiops(fe, &po);
return psgetfontsize(&po);
}
void
dev_jsft_initfe(fe)
struct font_entry *fe;
{
DEV_FONT jsft_fontdict();
int jsft_setchar(), jsft_setstring();
int jsft_setchar_abs(), jsft_setstring_abs();
fe->dev_fontdict = jsft_fontdict;
if (bifpos_rel(jstfmfinfo(fe)->js_bf)) {
fe->dev_setchar = jsft_setchar;
fe->dev_setstring = jsft_setstring;
} else {
fe->dev_setchar = jsft_setchar_abs;
fe->dev_setstring = jsft_setstring_abs;
}
}
jsft_setchar(c)
int c;
{
struct jstfmfntinfo *jsfi;
int cw;
jsfi = jstfmfinfo(curfontent);
begin_string();
pschar(jsftfinfo(jsfi)->ch[jsub_to_idx94(jsfi->jsubfont,c)].dev_char);
*ps_move += (cw = jsfi->ch[c].tfmw);
return cw;
}
/* ARGSUSED */
jsft_setstring(s, len)
char *s;
int len;
{
char *sp;
struct jstfmchar_entry *ce = jstfmfinfo(curfontent)->ch;
struct jstfmfntinfo *jsfi;
int cw;
jsfi = jstfmfinfo(curfontent);
begin_string();
for (sp = s, cw = 0; sp < s+len; sp++) {
pschar(jsftfinfo(jsfi)->ch[jsub_to_idx94(jsfi->jsubfont,*sp)].dev_char);
cw += (ce+*sp)->tfmw;
}
*ps_move += cw;
return cw;
}
jsft_setchar_abs(c)
int c;
{
int cw;
cw = jsft_setchar(c);
dev_setposn_abs(ps_h, ps_v);
return cw;
}
/* ARGSUSED */
jsft_setstring_abs(s, len)
char *s;
int len;
{
char *sp;
struct jstfmchar_entry *ce = jstfmfinfo(curfontent)->ch;
struct jstfmfntinfo *jsfi;
int cw, w;
jsfi = jstfmfinfo(curfontent);
for (sp = s, cw = 0; sp < s+len; sp++) {
begin_string();
pschar(jsftfinfo(jsfi)->ch[jsub_to_idx94(jsfi->jsubfont,*sp)].dev_char);
end_string();
cw += (w = (ce+*sp)->tfmw);
*ps_move += w;
dev_setposn_abs(ps_h, ps_v);
}
return cw;
}
#endif
|