summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenry Stiles <henry.stiles@artifex.com>2007-08-15 06:12:50 +0000
committerHenry Stiles <henry.stiles@artifex.com>2007-08-15 06:12:50 +0000
commit83c6d04bf68553ad512c83b7810386112b405471 (patch)
tree7c731841b66ec5aaa9cabbfed9e93bbf14db58ac
parent3c809962efdff897e208ea5e55af71c4a994deab (diff)
Modifications for pcl, pxl, and xps so text works properly with high
level devices, the clients did not set orig_FontMatrix or FontMatrix, instead gs_setcharmatrix was used to express character scaling. This does not work with devices like pdfwrite which don't have access to the character matrix. It does not suffice to simply set the FontMatrix, setcharmatrix still must be used so the cache machinery is aware of the character matrix. Thanks to Igor for helping out with this. NOTES: 1) XPS changes were not tested. 2) pcl and gl do not use a character matrix. The scaling information is concatenated into the ctm. XL and XPS do use a character scaling matrix. 3) This modification has been hurried together for a release, we hope to build a simpler interface for font scaling by non-postscript clients later. git-svn-id: http://svn.ghostscript.com/ghostpcl/trunk/ghostpcl@2886 06663e23-700e-0410-b217-a244a6096597
-rw-r--r--pcl/pctext.c2
-rw-r--r--pcl/pglabel.c4
-rw-r--r--pl/plfont.c11
-rw-r--r--pxl/pxerrors.c4
-rw-r--r--pxl/pxfont.c8
-rw-r--r--pxl/pxstate.c23
-rw-r--r--xps/xpsglyphs.c4
7 files changed, 21 insertions, 35 deletions
diff --git a/pcl/pctext.c b/pcl/pctext.c
index 4d393caf1..cfd104c63 100644
--- a/pcl/pctext.c
+++ b/pcl/pctext.c
@@ -57,6 +57,8 @@ set_gs_font(
{
gs_font * pfont = (gs_font *)pcs->font->pfont;
gs_setfont(pcs->pgs, pfont);
+ /* font scaling is reflected directly in the ctm */
+ pfont->FontMatrix = pfont->orig_FontMatrix;
}
/* uncomment the following definition to treat map type 0 as defined
diff --git a/pcl/pglabel.c b/pcl/pglabel.c
index 9125c33c1..f3380f37f 100644
--- a/pcl/pglabel.c
+++ b/pcl/pglabel.c
@@ -778,10 +778,8 @@ hpgl_print_char(
gs_concat(pgs, &smat);
}
- /*
- * Patch the next-character procedure.
- */
gs_setfont(pgs, pfont);
+ pfont->FontMatrix = pfont->orig_FontMatrix;
/*
* Adjust the initial position of the character according to
diff --git a/pl/plfont.c b/pl/plfont.c
index 71051f48f..2a4bac2d1 100644
--- a/pl/plfont.c
+++ b/pl/plfont.c
@@ -658,6 +658,7 @@ pl_fill_in_font(gs_font *pfont, pl_font_t *plfont, gs_font_dir *pdir, gs_memory_
int i;
plfont->pfont = pfont;
/* Initialize generic font data. */
+ gs_make_identity(&pfont->orig_FontMatrix);
pfont->next = pfont->prev = 0;
pfont->memory = mem;
pfont->dir = pdir;
@@ -690,16 +691,13 @@ pl_fill_in_font(gs_font *pfont, pl_font_t *plfont, gs_font_dir *pdir, gs_memory_
}
strncpy(pfont->key_name.chars, font_name, sizeof(pfont->font_name.chars));
pfont->key_name.size = strlen(font_name);
- memset(&pfont->orig_FontMatrix, 0, sizeof(pfont->orig_FontMatrix));
return 0;
}
/* Fill in bitmap font boilerplate. */
void
pl_fill_in_bitmap_font(gs_font_base *pfont, long unique_id)
-{ /* It appears that bitmap fonts don't need a FontMatrix. */
- gs_make_identity(&pfont->FontMatrix);
- pfont->FontType = ft_user_defined;
+{ pfont->FontType = ft_user_defined;
pfont->BitmapWidths = true;
pfont->ExactSize = fbit_use_bitmaps;
pfont->InBetweenSize = fbit_use_bitmaps;
@@ -716,8 +714,7 @@ pl_fill_in_bitmap_font(gs_font_base *pfont, long unique_id)
/* Fill in TrueType font boilerplate. */
void
pl_fill_in_tt_font(gs_font_type42 *pfont, void *data, long unique_id)
-{ gs_make_identity(&pfont->FontMatrix);
- pfont->FontType = ft_TrueType;
+{ pfont->FontType = ft_TrueType;
pfont->BitmapWidths = true;
pfont->ExactSize = fbit_use_outlines;
pfont->InBetweenSize = fbit_use_outlines;
@@ -750,7 +747,7 @@ pl_fill_in_intelli_font(gs_font_base *pfont, long unique_id)
{ /* Intellifonts have an 8782-unit design space. */
{ gs_matrix mat;
gs_make_scaling(1.0/8782, 1.0/8782, &mat);
- gs_matrix_translate(&mat, -2980.0, -5380.0, &pfont->FontMatrix);
+ gs_matrix_translate(&mat, -2980.0, -5380.0, &pfont->orig_FontMatrix);
}
pfont->FontType = ft_user_defined;
pfont->BitmapWidths = true;
diff --git a/pxl/pxerrors.c b/pxl/pxerrors.c
index d21f9da30..68f4b4d7d 100644
--- a/pxl/pxerrors.c
+++ b/pxl/pxerrors.c
@@ -249,10 +249,12 @@ px_begin_error_page(px_state_t *pxs)
/*pxSetPageDefaultCTM(NULL, pxs);*/
{
gs_point pt;
+ gs_font *pfont = pxs->error_page_font->pfont;
px_get_default_media_size(pxs, &pt);
gs_translate(pgs, 0.0, pt.y);
gs_scale(pgs, 1.0, -1.0);
- gs_setfont(pgs, (gs_font *)pxs->error_page_font->pfont);
+ gs_setfont(pgs, pfont);
+ pfont->FontMatrix = pfont->orig_FontMatrix;
return 90;
}
}
diff --git a/pxl/pxfont.c b/pxl/pxfont.c
index c1d2d4579..2f11bad9d 100644
--- a/pxl/pxfont.c
+++ b/pxl/pxfont.c
@@ -337,6 +337,7 @@ px_text(px_args_t *par, px_state_t *pxs, bool to_path)
int code = 0;
gs_char *pchr = 0;
pl_font_t *plfont;
+ gs_matrix save_ctm;
if ( pfont == 0 )
return_error(errorNoCurrentFont);
@@ -362,7 +363,13 @@ px_text(px_args_t *par, px_state_t *pxs, bool to_path)
return 0;
}
+ /* set the character matrix in the graphics state */
gs_setcharmatrix(pgs, &pxgs->char_matrix);
+ /* The character matrix is not visible to devices. High level
+ devices get character scaling information from the font's
+ matrix (FontMatrix). */
+ gs_matrix_multiply(&pxgs->char_matrix, &pfont->orig_FontMatrix,
+ &pfont->FontMatrix);
/* we don't need to consider the vertical mess for resident fonts */
if (plfont->storage != pxfsDownLoaded) {
pfont->WMode = 0; /* horizontal */
@@ -407,7 +414,6 @@ px_text(px_args_t *par, px_state_t *pxs, bool to_path)
len, mem, &penum, to_path,
pxgs->char_bold_value == 0);
-
if ( code >= 0 ) {
code = gs_text_process(penum);
gs_text_release(penum, "pxtext");
diff --git a/pxl/pxstate.c b/pxl/pxstate.c
index 7b23689a9..60d13090f 100644
--- a/pxl/pxstate.c
+++ b/pxl/pxstate.c
@@ -68,29 +68,6 @@ px_state_release(px_state_t *pxs)
px_dict_release(&pxs->font_dict);
gs_free_object(pxs->memory, pxs->error_page_show_enum,
"px_state_release(pxs->error_page_show_enum)");
-
- /* free character cache machinery */
- gs_free_object(pxs->memory, pxs->font_dir->fmcache.mdata, "px_state_release");
- {
- /* free the circular list of memory chunks first */
- gx_bits_cache_chunk *chunk = pxs->font_dir->ccache.chunks;
- gx_bits_cache_chunk *start_chunk = chunk;
- gx_bits_cache_chunk *prev_chunk;
- while (1) {
- if (start_chunk == chunk->next) {
- gs_free_object(pxs->memory, chunk->data, "px_state_release");
- gs_free_object(pxs->memory, chunk, "px_state_release");
- break;
- }
- prev_chunk = chunk;
- chunk = chunk->next;
- gs_free_object(pxs->memory, prev_chunk->data, "px_state_release");
- gs_free_object(pxs->memory, prev_chunk, "px_state_release");
- }
- }
- gs_free_object(pxs->memory, pxs->font_dir->ccache.table, "px_state_release");
- /* free gs font dir */
- gs_free_object(pxs->memory, pxs->font_dir, "px_state_release(gs_font_dir)");
/* Don't free pxgs since it'll get freed as pgs' client */
gs_free_object(pxs->memory, pxs, "px_state_release");
}
diff --git a/xps/xpsglyphs.c b/xps/xpsglyphs.c
index d7ca80140..7b1bbcfdb 100644
--- a/xps/xpsglyphs.c
+++ b/xps/xpsglyphs.c
@@ -589,8 +589,12 @@ xps_parse_glyphs(xps_context_t *ctx, xps_resource_t *dict, xps_item_t *root)
gs_make_scaling(font_size, -font_size, &matrix);
if (is_sideways)
gs_matrix_rotate(&matrix, 90.0, &matrix);
+
gs_setcharmatrix(ctx->pgs, &matrix);
+ gs_matrix_multiply(&matrix, &font->font->orig_FontMatrix,
+ &font->font->FontMatrix);
+
xps_begin_opacity(ctx, dict, opacity_att, opacity_mask_tag);
/*