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.w179
1 files changed, 51 insertions, 128 deletions
diff --git a/Build/source/texk/web2c/luatexdir/pdf/pdffont.w b/Build/source/texk/web2c/luatexdir/pdf/pdffont.w
index 5a1cee3d28b..967869b318c 100644
--- a/Build/source/texk/web2c/luatexdir/pdf/pdffont.w
+++ b/Build/source/texk/web2c/luatexdir/pdf/pdffont.w
@@ -1,6 +1,6 @@
% pdffont.w
%
-% Copyright 2009-2012 Taco Hoekwater <taco@@luatex.org>
+% Copyright 2009-2014 Taco Hoekwater <taco@@luatex.org>
%
% This file is part of LuaTeX.
%
@@ -21,8 +21,8 @@
@ @c
static const char _svn_version[] =
- "$Id: pdffont.w 4576 2013-02-08 20:42:57Z hhenkel $"
- "$URL: https://foundry.supelec.fr/svn/luatex/tags/beta-0.76.0/source/texk/web2c/luatexdir/pdf/pdffont.w $";
+ "$Id: pdffont.w 4710 2014-01-02 13:26:55Z oneiros $"
+ "$URL: https://foundry.supelec.fr/svn/luatex/trunk/source/texk/web2c/luatexdir/pdf/pdffont.w $";
#include "ptexlib.h"
@@ -41,13 +41,18 @@ should check whether the used character is a virtual or real character.
The |has_packet()| C macro checks for this condition.
-@ The following code typesets a character to PDF output
+@ The following code typesets a character to PDF output
@c
-void output_one_char(PDF pdf, internal_font_number ffi, int c)
+scaled_whd output_one_char(PDF pdf, halfword p)
{
scaled_whd ci; /* the real width, height and depth of the character */
- ci = get_charinfo_whd(ffi, c);
+ internal_font_number f = font(p);
+ int c = character(p);
+ int ex_glyph = ex_glyph(p)/1000;
+ ci = get_charinfo_whd(f, c);
+ //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;
@@ -65,13 +70,14 @@ void output_one_char(PDF pdf, internal_font_number ffi, int c)
default:
assert(0);
}
- if (has_packet(ffi, c)) {
- do_vf_packet(pdf, ffi, c);
+ if (has_packet(f, c)) {
+ do_vf_packet(pdf, f, c, ex_glyph);
} else
- backend_out[glyph_node] (pdf, ffi, c); /* |pdf_place_glyph(pdf, ffi, c);| */
+ backend_out[glyph_node] (pdf, f, c, ex_glyph); /* |pdf_place_glyph(pdf, f, c, ex_glyph);| */
+ return ci;
}
-@ Mark |f| as a used font; set |font_used(f)|, |font_size(f)| and |pdf_font_num(f)|
+@ Mark |f| as a used font; set |font_used(f)|, |font_size(f)| and |pdf_font_num(f)|
@c
static void pdf_use_font(internal_font_number f, int fontnum)
{
@@ -92,28 +98,17 @@ indicates that the corresponding font shares the font resource with the font
static boolean font_shareable(internal_font_number f, internal_font_number k)
{
int ret = 0;
- internal_font_number b; /* possible base font */
/* 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) ||
- (font_auto_expand(f) &&
- (b = pdf_font_blink(k)) != null_font && same(font_name, k, b)))) {
+ font_map(f) != NULL && (same(font_name, k, f))) {
ret = 1;
}
-#ifdef DEBUG
- printf("\nfont_shareable(%d:%d, %d:%d): => %d\n", f, pdf_font_blink(f),
- k, pdf_font_blink(k), ret);
-#endif
} else {
- if ((same(font_filename, k, f) && same(font_fullname, k, f))
- || (font_auto_expand(f)
- && (b = pdf_font_blink(k)) != null_font
- && same(font_name, k, b))) {
+ if ((same(font_filename, k, f) && same(font_fullname, k, f))) {
ret = 1;
}
#ifdef DEBUG
@@ -125,25 +120,25 @@ static boolean font_shareable(internal_font_number f, internal_font_number k)
return ret;
}
-@ create a font object
+@ create a font object
@c
void pdf_init_font(PDF pdf, internal_font_number f)
{
- internal_font_number k, b;
+ internal_font_number k/*, b*/;
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));
- }
+ ///* 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
@@ -179,7 +174,7 @@ 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
@c
internal_font_number pdf_set_font(PDF pdf, internal_font_number f)
{
@@ -198,17 +193,7 @@ internal_font_number pdf_set_font(PDF pdf, internal_font_number f)
}
@ Here come some subroutines to deal with expanded fonts for HZ-algorithm.
-@c
-void copy_expand_params(internal_font_number k, internal_font_number f, int e)
-{ /* set expansion-related parameters for an expanded font |k|, based on the base
- font |f| and the expansion amount |e| */
- set_font_expand_ratio(k, e);
- set_font_step(k, font_step(f));
- set_font_auto_expand(k, font_auto_expand(f));
- set_pdf_font_blink(k, f);
-}
-
-@ return 1 == identical
+return 1 == identical
@c
static boolean cmp_font_name(int id, char *tt)
{
@@ -224,19 +209,18 @@ static boolean cmp_font_name(int id, char *tt)
}
@ @c
-internal_font_number tfm_lookup(char *s, scaled fs, int e)
+internal_font_number tfm_lookup(char *s, scaled fs)
{ /* looks up for a TFM with name |s| loaded at |fs| size; if found then flushes |s| */
internal_font_number k;
if (fs != 0) {
for (k = 1; k <= max_font_id(); k++) {
- if (cmp_font_name(k, s) && font_size(k) == fs
- && font_expand_ratio(k) == e) {
+ if (cmp_font_name(k, s) && font_size(k) == fs) {
return k;
}
}
} else {
for (k = 1; k <= max_font_id(); k++) {
- if (cmp_font_name(k, s) && font_expand_ratio(k) == e) {
+ if (cmp_font_name(k, s)) {
return k;
}
}
@@ -245,26 +229,7 @@ internal_font_number tfm_lookup(char *s, scaled fs, int e)
}
@ @c
-static internal_font_number load_expand_font(internal_font_number f, int e)
-{ /* loads font |f| expanded by |e| thousandths into font memory; |e| is nonzero
- and is a multiple of |font_step(f)| */
- internal_font_number k;
- k = tfm_lookup(font_name(f), font_size(f), e);
- if (k == null_font) {
- if (font_auto_expand(f)) {
- k = auto_expand_font(f, e);
- font_id_text(k) = font_id_text(f);
- } else {
- k = read_font_info(null_cs, font_name(f), font_size(f),
- font_natural_dir(f));
- }
- }
- copy_expand_params(k, f, e);
- return k;
-}
-
-@ @c
-static int fix_expand_value(internal_font_number f, int e)
+int fix_expand_value(internal_font_number f, int e)
{ /* return the multiple of |font_step(f)| that is nearest to |e| */
int step;
int max_expand;
@@ -274,10 +239,10 @@ static int fix_expand_value(internal_font_number f, int e)
if (e < 0) {
e = -e;
neg = true;
- max_expand = -font_expand_ratio(font_shrink(f));
+ max_expand = font_max_shrink(f);
} else {
neg = false;
- max_expand = font_expand_ratio(font_stretch(f));
+ max_expand = font_max_stretch(f);
}
if (e > max_expand) {
e = max_expand;
@@ -292,49 +257,13 @@ static int fix_expand_value(internal_font_number f, int e)
}
@ @c
-static internal_font_number get_expand_font(internal_font_number f, int e)
-{ /* look up and create if not found an expanded version of |f|; |f| is an
- expandable font; |e| is nonzero and is a multiple of |font_step(f)| */
- internal_font_number k;
- k = pdf_font_elink(f);
- while (k != null_font) {
- if (font_expand_ratio(k) == e)
- return k;
- k = pdf_font_elink(k);
- }
- k = load_expand_font(f, e);
- set_pdf_font_elink(k, pdf_font_elink(f));
- set_pdf_font_elink(f, k);
- return k;
-}
-
-@ @c
-internal_font_number expand_font(internal_font_number f, int e)
-{ /* looks up for font |f| expanded by |e| thousandths, |e| is an arbitrary value
- between max stretch and max shrink of |f|; if not found then creates it */
- if (e == 0)
- return f;
- e = fix_expand_value(f, e);
- if (e == 0)
- return f;
- if (pdf_font_elink(f) == null_font)
- pdf_error("font expansion", "uninitialized pdf_font_elink");
- return get_expand_font(f, e);
-}
-
-@ @c
void set_expand_params(internal_font_number f, boolean auto_expand,
- int stretch_limit, int shrink_limit,
- int font_step, int expand_ratio)
+ int stretch_limit, int shrink_limit, int font_step)
{ /* expand a font with given parameters */
set_font_step(f, font_step);
set_font_auto_expand(f, auto_expand);
- if (stretch_limit > 0)
- set_font_stretch(f, get_expand_font(f, stretch_limit));
- if (shrink_limit > 0)
- set_font_shrink(f, get_expand_font(f, -shrink_limit));
- if (expand_ratio != 0)
- set_font_expand_ratio(f, expand_ratio);
+ set_font_max_shrink(f, shrink_limit);
+ set_font_max_stretch(f, stretch_limit);
}
@ @c
@@ -348,9 +277,9 @@ void read_expand_font(void)
f = cur_val;
if (f == null_font)
pdf_error("font expansion", "invalid font identifier");
- if (pdf_font_blink(f) != null_font)
- pdf_error("font expansion",
- "\\pdffontexpand cannot be used this way (the base font has been expanded)");
+ //if (pdf_font_blink(f) != null_font)
+ // pdf_error("font expansion",
+ // "\\pdffontexpand cannot be used this way (the base font has been expanded)");
scan_optional_equals();
scan_int();
stretch_limit = fix_int(cur_val, 0, 1000);
@@ -377,25 +306,21 @@ void read_expand_font(void)
back_input();
}
- /* check if the font can be expanded */
- if (font_expand_ratio(f) != 0)
- pdf_error("font expansion",
- "this font has been expanded by another font so it cannot be used now");
if (font_step(f) != 0) {
/* this font has been expanded, ensure the expansion parameters are identical */
if (font_step(f) != font_step)
pdf_error("font expansion",
"font has been expanded with different expansion step");
- if (((font_stretch(f) == null_font) && (stretch_limit != 0)) ||
- ((font_stretch(f) != null_font)
- && (font_expand_ratio(font_stretch(f)) != stretch_limit)))
+ if (((font_max_stretch(f) == 0) && (stretch_limit != 0)) ||
+ ((font_max_stretch(f) > 0)
+ && (font_max_stretch(f) != stretch_limit)))
pdf_error("font expansion",
"font has been expanded with different stretch limit");
- if (((font_shrink(f) == null_font) && (shrink_limit != 0)) ||
- ((font_shrink(f) != null_font)
- && (-font_expand_ratio(font_shrink(f)) != shrink_limit)))
+ if (((font_max_shrink(f) == 0) && (shrink_limit != 0)) ||
+ ((font_max_shrink(f) > 0)
+ && (font_max_shrink(f) != shrink_limit)))
pdf_error("font expansion",
"font has been expanded with different shrink limit");
@@ -408,9 +333,7 @@ void read_expand_font(void)
"font should be expanded before its first use", true,
true);
set_expand_params(f, auto_expand, stretch_limit, shrink_limit,
- font_step, 0);
- if (font_type(f) == virtual_font_type)
- vf_expand_local_fonts(f);
+ font_step);
}
}