diff options
author | Henry Stiles <henry.stiles@artifex.com> | 2010-06-28 06:13:11 +0000 |
---|---|---|
committer | Henry Stiles <henry.stiles@artifex.com> | 2010-06-28 06:13:11 +0000 |
commit | b672f953f1a42b32c5592817368180fce9c3c9c4 (patch) | |
tree | 4ec4b2978c58906e39cd20e944e2475dd34aa646 | |
parent | 5c6e66705c5d8be9be1d6cc5ab1921b9811c9f40 (diff) |
Finish up bug 691362, PXL PCLSelectFont attribute not handled. The
scaling was not correct, we want to use the exact same code used in
the pcl interpreter to scale fonts then that scaling value is
converted to PCL XL user units. The code has been refactored to share
the the PCL font scaling code and support for converting the pcl font
size in centipoints to the 3 user unit types in PCL XL has been added.
C706.BIN should print correctly now. A bit more warning cleanup is
needed in this new code.
git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@11437 a1074d23-0009-0410-80fe-cf8c14f379e6
-rw-r--r-- | main/pcl6_gcc.mak | 2 | ||||
-rw-r--r-- | pcl/pcstate.h | 5 | ||||
-rw-r--r-- | pcl/pctext.c | 99 | ||||
-rw-r--r-- | pxl/pxl.mak | 2 | ||||
-rw-r--r-- | pxl/pxpthr.c | 48 |
5 files changed, 76 insertions, 80 deletions
diff --git a/main/pcl6_gcc.mak b/main/pcl6_gcc.mak index c1e5983e7..29592cc72 100644 --- a/main/pcl6_gcc.mak +++ b/main/pcl6_gcc.mak @@ -238,8 +238,8 @@ include $(COMMONDIR)/ugcc_top.mak # Subsystems include $(PLSRCDIR)/pl.mak -include $(PXLSRCDIR)/pxl.mak include $(PCLSRCDIR)/pcl.mak +include $(PXLSRCDIR)/pxl.mak # Main program. diff --git a/pcl/pcstate.h b/pcl/pcstate.h index 9246df4fc..9a247cdc8 100644 --- a/pcl/pcstate.h +++ b/pcl/pcstate.h @@ -373,4 +373,9 @@ int pcl_load_built_in_fonts(pcl_state_t *pcs, const char *pathname); int pcl_implicit_gl2_finish(pcl_state_t *pcs); int pcl_do_printer_reset(pcl_state_t *pcs); int pcl_end_page_top(pcl_state_t *pcs, int num_copies, int flush); + +/* exported from pcl to support PCL XL pass through mode */ +bool pcl_downloaded_and_bound(pl_font_t *plfont); +void pcl_font_scale(pcl_state_t *, gs_point *psz); + #endif /* pcstate_INCLUDED */ diff --git a/pcl/pctext.c b/pcl/pctext.c index 561bb5446..ba3309385 100644 --- a/pcl/pctext.c +++ b/pcl/pctext.c @@ -708,6 +708,47 @@ pcl_show_chars_slow( return code; } +void +pcl_font_scale(pcl_state_t *pcs, gs_point *pscale) +{ + /* set up the font transformation */ + if (pcs->font->scaling_technology == plfst_bitmap) { + pscale->x = pcl_coord_scale / pcs->font->resolution.x; + pscale->y = pcl_coord_scale / pcs->font->resolution.y; + } else { + /* + * Outline fonts are 1-point; the font height is given in + * (quarter-)points. However, if the font is fixed-width, + * it must be scaled by pitch, not by height, relative to + * the nominal pitch of the outline. + */ + pcl_font_selection_t * pfp = &pcs->font_selection[pcs->font_selected]; + /* AGFA madness - 72.307 points per inch for intellifonts */ + floatp ppi = (pfp->font->scaling_technology == plfst_Intellifont) ? 72.307 : 72.0; + if (pfp->font->params.proportional_spacing) { + pscale->x = pscale->y = pfp->params.height_4ths + * 0.25 * 7200.0 / ppi; + } else { + pscale->x = pscale->y = pl_fp_pitch_cp(&pfp->params) + * (1000.0 / pl_fp_pitch_cp(&pfp->font->params)) + * (7200.0 / (100.0 * ppi)); + + /* hack for a scalable lineprinter font. If a real + lineprinter bitmap font is available it will be handled + by the bitmap scaling case above */ + if (pfp->font->params.typeface_family == 0) { + pscale->x = pscale->y = 850.0; + } + + } + /* + * Scalable fonts use an upright coordinate system, + * the opposite from the usual PCL system. + */ + pscale->y = -pscale->y; + } +} + /* * Set up to handle a string of text. * @@ -726,7 +767,6 @@ pcl_text( gs_state * pgs = pcs->pgs; gs_matrix user_ctm; gs_point scale; - int scale_sign; int code; /* rtl files can have text in them - we don't print any characters @@ -749,48 +789,11 @@ pcl_text( return code; set_gs_font(pcs); - /* set up the font transformation */ - if (pcs->font->scaling_technology == plfst_bitmap) { - scale.x = pcl_coord_scale / pcs->font->resolution.x; - scale.y = pcl_coord_scale / pcs->font->resolution.y; - - /* - * Bitmap fonts use an inverted coordinate system, - * the same as the usual PCL system. - */ - scale_sign = 1; - } else { - /* - * Outline fonts are 1-point; the font height is given in - * (quarter-)points. However, if the font is fixed-width, - * it must be scaled by pitch, not by height, relative to - * the nominal pitch of the outline. - */ - pcl_font_selection_t * pfp = &pcs->font_selection[pcs->font_selected]; - /* AGFA madness - 72.307 points per inch for intellifonts */ - floatp ppi = (pfp->font->scaling_technology == plfst_Intellifont) ? 72.307 : 72.0; - if (pfp->font->params.proportional_spacing) { - scale.x = scale.y = pfp->params.height_4ths - * 0.25 * 7200.0 / ppi; - } else { - scale.x = scale.y = pl_fp_pitch_cp(&pfp->params) - * (1000.0 / pl_fp_pitch_cp(&pfp->font->params)) - * (7200.0 / (100.0 * ppi)); + gs_currentmatrix(pgs, &user_ctm); - /* hack for a scalable lineprinter font. If a real - lineprinter bitmap font is available it will be handled - by the bitmap scaling case above */ - if (pfp->font->params.typeface_family == 0) { - scale.x = scale.y = 850.0; - } + (void)pcl_font_scale(pcs, &scale); - } - /* - * Scalable fonts use an upright coordinate system, - * the opposite from the usual PCL system. - */ - scale_sign = -1; - } + gs_scale(pgs, scale.x, scale.y); /* * If floating underline is on, since we're about to print a real @@ -801,24 +804,12 @@ pcl_text( * works. */ if (pcs->underline_enabled && pcs->underline_floating) { - float yu = scale.y / 5.0; + float yu = fabs(scale.y) / 5.0; if (yu > pcs->underline_position) pcs->underline_position = yu; } - /* - * XXX I'm using the more general, slower approach rather than - * just multiplying/dividing by scale factors, in order to keep it - * correct through orientation changes. Various parts of this should - * be cleaned up when performance time rolls around. - */ - gs_currentmatrix(pgs, &user_ctm); - - /* possibly invert text because HP coordinate system is inverted */ - scale.y *= scale_sign; - gs_scale(pgs, scale.x, scale.y); - /* it is not clear if vertical substitutes are allowed in mode -1 */ if (pcs->text_path != 0) pcs->font->allow_vertical_substitutes = true; diff --git a/pxl/pxl.mak b/pxl/pxl.mak index 7f718aef5..3f61145a9 100644 --- a/pxl/pxl.mak +++ b/pxl/pxl.mak @@ -110,7 +110,7 @@ $(PXLOBJ)pxpthr.$(OBJ): $(PXLSRC)pxpthr.c $(AK) \ $(gsstate_h) $(gscoord_h) $(gspath_h) $(gstypes_h) $(gsdevice_h)\ $(pcommand_h) $(pgmand_h) $(pcstate_h) $(pcparse_h) $(pctop_h)\ $(pcpage_h) $(pxstate_h) $(pxoper_h) $(stdio__h) $(pxpthr_h)\ - $(pxparse_h) $(pxgstate_h) $(pcdraw_h) $(gsicc_manage_h) + $(pxparse_h) $(pxgstate_h) $(pcdraw_h) $(pcfont_h) $(gsicc_manage_h) $(PXLCCC) $(PXLSRC)pxpthr.c $(PXLO_)pxpthr.$(OBJ) $(PXLOBJ)pxvalue.$(OBJ): $(PXLSRC)pxvalue.c $(AK) $(std_h) $(gsmemory_h) $(pxvalue_h) diff --git a/pxl/pxpthr.c b/pxl/pxpthr.c index 9a57395b6..9acc51f53 100644 --- a/pxl/pxpthr.c +++ b/pxl/pxpthr.c @@ -23,6 +23,7 @@ #include "pcommand.h" #include "pgmand.h" #include "pcstate.h" +#include "pcfont.h" #include "pcparse.h" #include "pctop.h" #include "pcpage.h" @@ -345,11 +346,7 @@ int pxpcl_selectfont(px_args_t *par, px_state_t *pxs) uint len = pstr->value.array.size; px_gstate_t *pxgs = pxs->pxgs; pcl_font_selection_t *pfp; - float ppi; - float scale; - /* NB move these to a header file */ - extern void set_symbol_map(px_state_t *pxs, bool wide16); - extern bool pcl_downloaded_and_bound(pl_font_t *plfont); + if ( !global_pcs ) pxPassthrough_init(pxs); @@ -373,25 +370,33 @@ int pxpcl_selectfont(px_args_t *par, px_state_t *pxs) if (code < 0) return code; pfp = &global_pcs->font_selection[global_pcs->font_selected]; - ppi = (pfp->font->scaling_technology == plfst_Intellifont) ? 72.307 : 72.0; - if (pfp->font->params.proportional_spacing) + { - scale = (pfp->params.height_4ths * 0.25) * pxs->units_per_measure.x / ppi; +#define CP_PER_INCH (7200.0) +#define CP_PER_MM (7200.0/25.4) +#define CP_PER_10ths_of_MM (CP_PER_MM/10.0) + + static const floatp centipoints_per_measure[4] = { + CP_PER_INCH, /* eInch */ + CP_PER_MM, /* eMillimeter */ + CP_PER_10ths_of_MM, /* eTenthsOfAMillimeter */ + 1 /* pxeMeasure_next, won't reach */ + }; + + gs_point sz; + pcl_font_scale(global_pcs, &sz); + pxgs->char_size = sz.x / + centipoints_per_measure[pxs->measure] * + pxs->units_per_measure.x; } - else - { - scale = 1200.0 / (pfp->params.pitch.per_inch_x100 / 100.0) * (72.0 / ppi); + pxgs->symbol_set = pfp->params.symbol_set; - /* hack for a scalable lineprinter font. If a real - lineprinter bitmap font is available it will be handled - by the bitmap scaling case above */ - if (pfp->font->params.typeface_family == 0) { - scale = 850.0; - } + if (pcl_downloaded_and_bound(global_pcs->font)) { + pxgs->symbol_map = 0; + } else { + set_symbol_map(pxs, global_pcs->font->font_type == plft_16bit); } - pxgs->char_size = scale; - pxgs->symbol_set = pfp->params.symbol_set; { pl_font_t *plf = global_pcs->font; @@ -409,11 +414,6 @@ int pxpcl_selectfont(px_args_t *par, px_state_t *pxs) pxgs->base_font = (px_font_t *)plf; } - if (pcl_downloaded_and_bound(global_pcs->font)) { - pxgs->symbol_map = 0; - } else { - set_symbol_map(pxs, global_pcs->font->font_type == plft_16bit); - } pxgs->char_matrix_set = false; return 0; } |