summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/pdf/pdffont.w
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/pdf/pdffont.w')
-rw-r--r--Build/source/texk/web2c/luatexdir/pdf/pdffont.w145
1 files changed, 64 insertions, 81 deletions
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdffont.w b/Build/source/texk/web2c/luatexdir/pdf/pdffont.w
index 4a7319db8a3..b3f1605154c 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdffont.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdffont.w
@@ -21,7 +21,6 @@
@ @c
-
#include "ptexlib.h"
@ As \pdfTeX{} should also act as a back-end driver, it needs to support virtual
@@ -37,38 +36,38 @@ The |has_packet()| C macro checks for this condition.
@c
scaled_whd output_one_char(PDF pdf, halfword p)
{
- scaled_whd ci; /* the real width, height and depth of the character */
internal_font_number f = font(p);
int c = character(p);
int ex_glyph = ex_glyph(p)/1000;
- ci = get_charinfo_whd(f, c);
+ scaled_whd ci = get_charinfo_whd(f, c); /* the real width, height and depth of the character */
if (!(char_exists(f,c))) {
char_warning(f,c);
return ci;
}
- //ci.wd = round_xn_over_d(ci.wd, 1000 + ex_glyph, 1000);
ci.wd = ext_xn_over_d(ci.wd, 1000000 + ex_glyph(p), 1000000);
switch (pdf->posstruct->dir) {
- case dir_TLT:
- break;
- case dir_TRT:
- pos_left(ci.wd);
- break;
- case dir_LTL:
- pos_down(ci.ht);
- pos_left(ci.wd);
- break;
- case dir_RTT:
- pos_down(ci.ht);
- pos_left(ci.wd / 2);
- break;
- default:
- assert(0);
+ case dir_TLT:
+ break;
+ case dir_TRT:
+ pos_left(ci.wd);
+ break;
+ case dir_LTL:
+ pos_down(ci.ht);
+ pos_left(ci.wd);
+ break;
+ case dir_RTT:
+ pos_down(ci.ht);
+ pos_left(ci.wd / 2);
+ break;
+ default:
+ formatted_warning("pdf backend","ignoring bad dir %i when outputting a character",pdf->posstruct->dir);
}
if (has_packet(f, c)) {
do_vf_packet(pdf, f, c, ex_glyph);
- } else
- backend_out[glyph_node] (pdf, f, c, ex_glyph); /* |pdf_place_glyph(pdf, f, c, ex_glyph);| */
+ } else {
+ /* |pdf_place_glyph(pdf, f, c, ex_glyph);| */
+ backend_out[glyph_node] (pdf, f, c, ex_glyph);
+ }
return ci;
}
@@ -77,72 +76,59 @@ scaled_whd output_one_char(PDF pdf, halfword p)
static void pdf_use_font(internal_font_number f, int fontnum)
{
set_font_used(f, true);
- assert((fontnum > 0) || ((fontnum < 0) && (pdf_font_num(-fontnum) > 0)));
- set_pdf_font_num(f, fontnum);
+ if ((fontnum > 0) || ((fontnum < 0) && (pdf_font_num(-fontnum) > 0))) {
+ set_pdf_font_num(f, fontnum);
+ } else {
+ normal_error("pdf backend","bad font id");
+ }
}
-@ To set PDF font we need to find out fonts with the same name, because \TeX\
-can load the same font several times for various sizes. For such fonts we
-define only one font resource. The array |pdf_font_num| holds the object
-number of font resource. A negative value of an entry of |pdf_font_num|
-indicates that the corresponding font shares the font resource with the font
+@ To set PDF font we need to find out fonts with the same name, because \TeX\ can
+load the same font several times for various sizes. For such fonts we define only
+one font resource. The array |pdf_font_num| holds the object number of font
+resource. A negative value of an entry of |pdf_font_num| indicates that the
+corresponding font shares the font resource with the font
@c
#define same(n,f,k) (n(f) != NULL && n(k) != NULL && strcmp(n(f), n(k)) == 0)
+/*
+ For some lua-loaded (for instance AFM) fonts, it is normal to have
+ a zero cidregistry, and such fonts do not have a fontmap entry yet
+ at this point, so the test should use the other branch
+*/
+
static boolean font_shareable(internal_font_number f, internal_font_number k)
{
- int ret = 0;
- /* For some lua-loaded (for instance AFM) fonts, it is normal to have
- a zero cidregistry, and such fonts do not have a fontmap entry yet
- at this point, so the test should use the other branch */
- if (font_cidregistry(f) == NULL && font_cidregistry(k) == NULL &&
- font_encodingbytes(f) != 2 && font_encodingbytes(k) != 2) {
- if (font_map(k) != NULL &&
- font_map(f) != NULL && (same(font_name, k, f))) {
- ret = 1;
+ if (font_cidregistry(f) == NULL && font_cidregistry(k) == NULL && font_encodingbytes(f) != 2 && font_encodingbytes(k) != 2) {
+ if (font_map(k) != NULL && font_map(f) != NULL && (same(font_name, k, f))) {
+ return 1;
}
- } else {
- if ((same(font_filename, k, f) && same(font_fullname, k, f))) {
- ret = 1;
- }
-#ifdef DEBUG
- printf("\nfont_shareable(%d:%s:%s,%d:%s:%s): => %d\n",
- f, font_filename(f), font_fullname(f),
- k, font_filename(k), font_fullname(k), ret);
-#endif
+ } else if ((same(font_filename, k, f) && same(font_fullname, k, f))) {
+ return 1;
}
- return ret;
+ return 0;
}
@ create a font object
@c
void pdf_init_font(PDF pdf, internal_font_number f)
{
- internal_font_number k/*, b*/;
+ internal_font_number k;
fm_entry *fm;
int i, l;
- assert(!font_used(f));
-
- ///* if |f| is auto expanded then ensure the base font is initialized */
- //
- // if (font_auto_expand(f) && ((b = pdf_font_blink(f)) != null_font)) {
- // if (!font_used(b))
- // pdf_init_font(pdf, b);
- // set_font_map(f, font_map(b));
- // /* propagate slant and extend from unexpanded base font */
- // set_font_slant(f, font_slant(b));
- // set_font_extend(f, font_extend(b));
- //}
- /* check whether |f| can share the font object with some |k|: we have 2 cases
- here: 1) |f| and |k| have the same tfm name (so they have been loaded at
- different sizes, eg 'cmr10' and 'cmr10 at 11pt'); 2) |f| has been auto
- expanded from |k|
- */
-
- /* take over slant and extend from map entry, if not already set;
- this should also be the only place where getfontmap() may be called. */
-
+ if (font_used(f)) {
+ formatted_error("pdf backend","font %i gets initialized twice",(int) f);
+ }
+ /*
+ check whether |f| can share the font object with some |k|: we have 2 cases
+ here: 1) |f| and |k| have the same tfm name (so they have been loaded at
+ different sizes, eg 'cmr10' and 'cmr10 at 11pt'); 2) |f| has been auto
+ expanded from |k|
+
+ take over slant and extend from map entry, if not already set;
+ this should also be the only place where getfontmap() may be called.
+ */
fm = getfontmap(font_name(f));
if (font_map(f) == NULL && fm != NULL) {
font_map(f) = fm;
@@ -155,7 +141,6 @@ void pdf_init_font(PDF pdf, internal_font_number f)
while (i != 0) {
k = obj_info(pdf, i);
if (font_shareable(f, k)) {
- assert(pdf_font_num(k) != 0);
if (pdf_font_num(k) < 0)
pdf_use_font(f, pdf_font_num(k));
else
@@ -169,20 +154,18 @@ void pdf_init_font(PDF pdf, internal_font_number f)
pdf_use_font(f, l);
}
-@ set the actual font on PDF page
+@ set the actual font on PDF page; sets |ff| to the tfm number of the base font
+sharing the font object with |f|; |ff| is either |f| itself (then it is its own
+base font), or some font with the same tfm name at different size and/or
+expansion.
+
@c
internal_font_number pdf_set_font(PDF pdf, internal_font_number f)
{
- int ff; /* for use with |set_ff| */
+ int ff; /* for use with |set_ff| */
if (!font_used(f))
pdf_init_font(pdf, f);
- /*
- set |ff| to the tfm number of the base font sharing the font object with |f|;
- |ff| is either |f| itself (then it is its own base font),
- or some font with the same tfm name at different size and/or expansion.
- */
- ff = pdf_font_num(f) < 0 ? -pdf_font_num(f) : f; /* aka |set_ff(f)| */
- assert(pdf_font_num(ff) > 0); /* base font object number */
+ ff = pdf_font_num(f) < 0 ? -pdf_font_num(f) : f; /* aka |set_ff(f)| */
addto_page_resources(pdf, obj_type_font, pdf_font_num(ff));
return ff;
}
@@ -191,7 +174,7 @@ internal_font_number pdf_set_font(PDF pdf, internal_font_number f)
void pdf_include_chars(PDF pdf)
{
str_number s;
- unsigned char *k, *j; /* running index */
+ unsigned char *k, *j; /* running index */
internal_font_number f;
scan_font_ident();
f = cur_val;
@@ -200,7 +183,7 @@ void pdf_include_chars(PDF pdf)
pdf_check_vf(cur_val);
if (!font_used(f))
pdf_init_font(pdf, f);
- scan_pdf_ext_toks();
+ scan_toks(false, true);
s = tokens_to_string(def_ref);
delete_token_ref(def_ref);
j = str_string(s) + str_length(s);