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
|
/* Copyright (C) 1994 Aladdin Enterprises. All rights reserved.
This file is part of GNU Ghostscript.
GNU Ghostscript is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY. No author or distributor accepts responsibility to
anyone for the consequences of using it or for whether it serves any
particular purpose or works at all, unless he says so in writing. Refer
to the GNU Ghostscript General Public License for full details.
*/
/* gsfont0.c */
/* Composite font operations for Ghostscript library */
#include "memory_.h"
#include "gx.h"
#include "gserrors.h"
#include "gsstruct.h"
#include "gxfixed.h"
#include "gsmatrix.h"
#include "gxdevice.h"
#include "gxdevmem.h"
#include "gxchar.h"
#include "gxfcache.h" /* gs_font_dir */
#include "gxfont.h"
#include "gxfont0.h"
/* Structure descriptor */
public_st_gs_font_type0();
private ENUM_PTRS_BEGIN(font_type0_enum_ptrs) ENUM_PREFIX(st_gs_font, 3);
#define pfont ((gs_font_type0 *)vptr)
ENUM_PTR(0, gs_font_type0, data.Encoding);
ENUM_PTR(1, gs_font_type0, data.FDepVector);
case 2:
if ( pfont->data.FMapType == fmap_SubsVector )
{ *pep = (void *)&pfont->data.SubsVector;
return ptr_const_string_type;
}
else
{ *pep = 0;
break;
}
ENUM_PTRS_END
private RELOC_PTRS_BEGIN(font_type0_reloc_ptrs) RELOC_PREFIX(st_gs_font);
RELOC_PTR(gs_font_type0, data.Encoding);
RELOC_PTR(gs_font_type0, data.FDepVector);
if ( pfont->data.FMapType == fmap_SubsVector )
RELOC_CONST_STRING_PTR(gs_font_type0, data.SubsVector);
#undef pfont
RELOC_PTRS_END
/* Adjust a composite font by concatenating a given matrix */
/* to the FontMatrix of all descendant composite fonts. */
private int
gs_type0_adjust_matrix(gs_font_dir *pdir, gs_font_type0 *pfont,
const gs_matrix *pmat)
{ gs_font **pdep = pfont->data.FDepVector;
uint fdep_size = pfont->data.fdep_size;
gs_font **ptdep;
uint i;
/* Check for any descendant composite fonts. */
for ( i = 0; i < fdep_size; i++ )
if ( pdep[i]->FontType == ft_composite )
break;
if ( i == fdep_size )
return 0;
ptdep = gs_alloc_struct_array(pfont->memory, fdep_size, gs_font *,
&st_gs_font_ptr_element,
"gs_type0_adjust_font(FDepVector)");
if ( ptdep == 0 )
return_error(gs_error_VMerror);
memcpy(ptdep, pdep, sizeof(gs_font *) * fdep_size);
for ( ; i < fdep_size; i++ )
if ( pdep[i]->FontType == ft_composite )
{ int code = gs_makefont(pdir, pdep[i], pmat, &ptdep[i]);
if ( code < 0 )
return code;
}
pfont->data.FDepVector = ptdep;
return 0;
}
/* Finish defining a composite font, */
/* by adjusting its descendants' FontMatrices. */
int
gs_type0_define_font(gs_font_dir *pdir, gs_font *pfont)
{ const gs_matrix *pmat = &pfont->FontMatrix;
/* Check for the identity matrix, which is common in root fonts. */
if ( pmat->xx == 1.0 && pmat->yy == 1.0 &&
pmat->xy == 0.0 && pmat->yx == 0.0 &&
pmat->tx == 0.0 && pmat->ty == 0.0
)
return 0;
return gs_type0_adjust_matrix(pdir, (gs_font_type0 *)pfont, pmat);
}
/* Finish scaling a composite font similarly. */
int
gs_type0_make_font(gs_font_dir *pdir, const gs_font *pfont,
const gs_matrix *pmat, gs_font **ppfont)
{ return gs_type0_adjust_matrix(pdir, (gs_font_type0 *)*ppfont, pmat);
}
|