summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mupdf/fitz.h3
-rw-r--r--include/mupdf/fitz/bidi.h21
-rw-r--r--include/mupdf/fitz/text.h12
-rw-r--r--source/fitz/bidi-impl.h8
-rw-r--r--source/fitz/bidi.c22
-rw-r--r--source/fitz/text.c8
-rw-r--r--source/html/html-layout.c28
-rw-r--r--source/pdf/pdf-appearance.c2
-rw-r--r--source/pdf/pdf-op-run.c4
-rw-r--r--source/tools/murun.c4
-rw-r--r--source/xps/xps-glyphs.c2
11 files changed, 49 insertions, 65 deletions
diff --git a/include/mupdf/fitz.h b/include/mupdf/fitz.h
index 7ffca1cf..ec0c87a4 100644
--- a/include/mupdf/fitz.h
+++ b/include/mupdf/fitz.h
@@ -17,6 +17,7 @@ extern "C" {
#include "mupdf/fitz/string.h"
#include "mupdf/fitz/tree.h"
#include "mupdf/fitz/ucdn.h"
+#include "mupdf/fitz/bidi.h"
#include "mupdf/fitz/xml.h"
/* I/O */
@@ -65,8 +66,6 @@ extern "C" {
#include "mupdf/fitz/output-svg.h"
#include "mupdf/fitz/output-tga.h"
-#include "mupdf/fitz/bidi.h"
-
#ifdef __cplusplus
}
#endif
diff --git a/include/mupdf/fitz/bidi.h b/include/mupdf/fitz/bidi.h
index f458c498..e5cb87ed 100644
--- a/include/mupdf/fitz/bidi.h
+++ b/include/mupdf/fitz/bidi.h
@@ -23,9 +23,9 @@
typedef enum fz_bidi_direction_e
{
- BIDI_LEFT_TO_RIGHT = 0,
- BIDI_RIGHT_TO_LEFT = 1,
- BIDI_NEUTRAL = 2
+ FZ_BIDI_LTR = 0,
+ FZ_BIDI_RTL = 1,
+ FZ_BIDI_NEUTRAL = 2
}
fz_bidi_direction;
@@ -36,16 +36,8 @@ typedef enum fz_bidi_flags_e
}
fz_bidi_flags;
-typedef uint8_t fz_bidi_chartype;
-typedef int fz_bidi_level; /* Note: Max level is 125 */
-
-enum
-{
- BIDI_LEVEL_MAX = 125 /* Updated for 6.3.0 */
-};
-
/**
- * Prototype for callback function supplied to Bidi_fragmentText.
+ * Prototype for callback function supplied to fz_bidi_fragment_text.
*
* @param fragment first character in fragment
* @param fragmentLen number of characters in fragment
@@ -76,8 +68,7 @@ typedef void (fz_bidi_fragment_callback)(const uint32_t *fragment,
*
* @param[in] text start of Unicode sequence
* @param[in] textlen number of Unicodes to analyse
- * @param[in] baseDir direction of paragraph (specify BIDI_NEUTRAL
- * to force auto-detection)
+ * @param[in] baseDir direction of paragraph (specify FZ_BIDI_NEUTRAL to force auto-detection)
* @param[in] callback function to be called for each fragment
* @param[in] arg data to be passed to the callback function
* @param[in] flags flags to control operation (see fz_bidi_flags above)
@@ -90,4 +81,4 @@ void fz_bidi_fragment_text(fz_context *ctx,
void *arg,
int flags);
-#endif /* FITZ_BIDI_H */
+#endif
diff --git a/include/mupdf/fitz/text.h b/include/mupdf/fitz/text.h
index 84f72957..52035bc5 100644
--- a/include/mupdf/fitz/text.h
+++ b/include/mupdf/fitz/text.h
@@ -29,14 +29,6 @@ struct fz_text_item_s
int ucs; /* -1 for one ucs to many gid mappings */
};
-typedef enum fz_text_direction_e
-{
- /* There are various possible 'directions' for text */
- FZ_DIR_UNSET = 0, /* Unset (or Neutral). All PDF text is sent as this. */
- FZ_DIR_R2L = 1, /* Text is r2l */
- FZ_DIR_L2R = 2 /* Text is l2r */
-} fz_text_direction;
-
typedef enum fz_text_language_e
{
FZ_LANG_UNSET = 0
@@ -66,8 +58,8 @@ fz_text *fz_new_text(fz_context *ctx);
fz_text *fz_keep_text(fz_context *ctx, const fz_text *text);
void fz_drop_text(fz_context *ctx, const fz_text *text);
-void fz_show_glyph(fz_context *ctx, fz_text *text, fz_font *font, const fz_matrix *trm, int glyph, int unicode, int wmode, int bidi_level, fz_text_direction markup_dir, fz_text_language language);
-void fz_show_string(fz_context *ctx, fz_text *text, fz_font *font, fz_matrix *trm, const char *s, int wmode, int bidi_level, fz_text_direction markup_dir, fz_text_language language);
+void fz_show_glyph(fz_context *ctx, fz_text *text, fz_font *font, const fz_matrix *trm, int glyph, int unicode, int wmode, int bidi_level, fz_bidi_direction markup_dir, fz_text_language language);
+void fz_show_string(fz_context *ctx, fz_text *text, fz_font *font, fz_matrix *trm, const char *s, int wmode, int bidi_level, fz_bidi_direction markup_dir, fz_text_language language);
fz_rect *fz_bound_text(fz_context *ctx, const fz_text *text, const fz_stroke_state *stroke, const fz_matrix *ctm, fz_rect *r);
fz_text *fz_clone_text(fz_context *ctx, const fz_text *text);
diff --git a/source/fitz/bidi-impl.h b/source/fitz/bidi-impl.h
index 0de3458b..e9a5b3b4 100644
--- a/source/fitz/bidi-impl.h
+++ b/source/fitz/bidi-impl.h
@@ -64,6 +64,14 @@ enum
BDI_N = BDI_ON /* alias, where ON, WS and S are treated the same */
};
+typedef int fz_bidi_level; /* Note: Max level is 125 */
+typedef uint8_t fz_bidi_chartype;
+
+enum
+{
+ BIDI_LEVEL_MAX = 125 /* Updated for 6.3.0 */
+};
+
void fz_bidi_resolve_neutrals(fz_bidi_level baselevel, fz_bidi_chartype *pcls, const fz_bidi_level *plevel, int cch);
void fz_bidi_resolve_implicit(const fz_bidi_chartype *pcls, fz_bidi_level *plevel, int cch);
void fz_bidi_resolve_weak(fz_context *ctx, fz_bidi_level baselevel, fz_bidi_chartype *pcls, fz_bidi_level *plevel, int cch);
diff --git a/source/fitz/bidi.c b/source/fitz/bidi.c
index 979d2f1c..1fda5656 100644
--- a/source/fitz/bidi.c
+++ b/source/fitz/bidi.c
@@ -274,15 +274,15 @@ static fz_bidi_level base_level_from_text(fz_bidi_chartype *types, int len)
{
/* strong left */
case BDI_L:
- return BIDI_LEFT_TO_RIGHT;
+ return FZ_BIDI_LTR;
/* strong right */
case BDI_R:
case BDI_AL:
- return BIDI_RIGHT_TO_LEFT;
+ return FZ_BIDI_RTL;
}
}
- return BIDI_LEFT_TO_RIGHT;
+ return FZ_BIDI_LTR;
}
static fz_bidi_direction direction_from_type(fz_bidi_chartype type)
@@ -291,14 +291,14 @@ static fz_bidi_direction direction_from_type(fz_bidi_chartype type)
{
case BDI_L:
case BDI_EN:
- return BIDI_LEFT_TO_RIGHT;
+ return FZ_BIDI_LTR;
case BDI_R:
case BDI_AL:
- return BIDI_RIGHT_TO_LEFT;
+ return FZ_BIDI_RTL;
default:
- return BIDI_NEUTRAL;
+ return FZ_BIDI_NEUTRAL;
}
}
@@ -320,11 +320,11 @@ classify_quoted_blocks(const uint32_t *text,
{
switch (direction_from_type(types[i]))
{
- case BIDI_LEFT_TO_RIGHT:
+ case FZ_BIDI_LTR:
ltrFound = TRUE;
break;
- case BIDI_RIGHT_TO_LEFT:
+ case FZ_BIDI_RTL:
rtlFound = TRUE;
break;
@@ -428,13 +428,13 @@ create_levels(fz_context *ctx,
classify_characters(text, types, len, flags);
- if (*baseDir != BIDI_LEFT_TO_RIGHT && *baseDir != BIDI_RIGHT_TO_LEFT)
+ if (*baseDir != FZ_BIDI_LTR && *baseDir != FZ_BIDI_RTL)
{
/* Derive the base level from the text and
* update *baseDir in case the caller wants to know.
*/
baseLevel = base_level_from_text(types, len);
- *baseDir = ODD(baseLevel)==1 ? BIDI_RIGHT_TO_LEFT : BIDI_LEFT_TO_RIGHT;
+ *baseDir = ODD(baseLevel)==1 ? FZ_BIDI_RTL : FZ_BIDI_LTR;
}
else
{
@@ -453,7 +453,7 @@ create_levels(fz_context *ctx,
{
if (text[i]=='\t')
{
- types[i] = (*baseDir == BIDI_RIGHT_TO_LEFT) ? BDI_R : BDI_L;
+ types[i] = (*baseDir == FZ_BIDI_RTL) ? BDI_R : BDI_L;
}
}
}
diff --git a/source/fitz/text.c b/source/fitz/text.c
index 512c671c..76838fe8 100644
--- a/source/fitz/text.c
+++ b/source/fitz/text.c
@@ -37,7 +37,7 @@ fz_drop_text(fz_context *ctx, const fz_text *textc)
}
static fz_text_span *
-fz_new_text_span(fz_context *ctx, fz_font *font, int wmode, int bidi_level, fz_text_direction markup_dir, fz_text_language language, const fz_matrix *trm)
+fz_new_text_span(fz_context *ctx, fz_font *font, int wmode, int bidi_level, fz_bidi_direction markup_dir, fz_text_language language, const fz_matrix *trm)
{
fz_text_span *span = fz_malloc_struct(ctx, fz_text_span);
span->font = fz_keep_font(ctx, font);
@@ -52,7 +52,7 @@ fz_new_text_span(fz_context *ctx, fz_font *font, int wmode, int bidi_level, fz_t
}
static fz_text_span *
-fz_add_text_span(fz_context *ctx, fz_text *text, fz_font *font, int wmode, int bidi_level, fz_text_direction markup_dir, fz_text_language language, const fz_matrix *trm)
+fz_add_text_span(fz_context *ctx, fz_text *text, fz_font *font, int wmode, int bidi_level, fz_bidi_direction markup_dir, fz_text_language language, const fz_matrix *trm)
{
if (!text->tail)
{
@@ -86,7 +86,7 @@ fz_grow_text_span(fz_context *ctx, fz_text_span *span, int n)
}
void
-fz_show_glyph(fz_context *ctx, fz_text *text, fz_font *font, const fz_matrix *trm, int gid, int ucs, int wmode, int bidi_level, fz_text_direction markup_dir, fz_text_language lang)
+fz_show_glyph(fz_context *ctx, fz_text *text, fz_font *font, const fz_matrix *trm, int gid, int ucs, int wmode, int bidi_level, fz_bidi_direction markup_dir, fz_text_language lang)
{
fz_text_span *span;
@@ -105,7 +105,7 @@ fz_show_glyph(fz_context *ctx, fz_text *text, fz_font *font, const fz_matrix *tr
}
void
-fz_show_string(fz_context *ctx, fz_text *text, fz_font *user_font, fz_matrix *trm, const char *s, int wmode, int bidi_level, fz_text_direction markup_dir, fz_text_language language)
+fz_show_string(fz_context *ctx, fz_text *text, fz_font *user_font, fz_matrix *trm, const char *s, int wmode, int bidi_level, fz_bidi_direction markup_dir, fz_text_language language)
{
fz_font *font;
int gid, ucs;
diff --git a/source/html/html-layout.c b/source/html/html-layout.c
index 140577fd..bbd8a161 100644
--- a/source/html/html-layout.c
+++ b/source/html/html-layout.c
@@ -108,7 +108,7 @@ static fz_html_flow *add_flow(fz_context *ctx, fz_pool *pool, fz_html *top, fz_c
flow->type = type;
flow->expand = 0;
flow->bidi_level = 0;
- flow->markup_dir = FZ_DIR_UNSET;
+ flow->markup_dir = FZ_BIDI_NEUTRAL;
flow->breaks_line = 0;
flow->style = style;
*top->flow_tail = flow;
@@ -390,7 +390,7 @@ static void init_box(fz_context *ctx, fz_html *box)
box->flow_head = NULL;
box->flow_tail = &box->flow_head;
- box->flow_dir = FZ_DIR_UNSET;
+ box->flow_dir = FZ_BIDI_NEUTRAL;
fz_default_css_style(ctx, &box->style);
}
@@ -641,7 +641,7 @@ typedef struct string_walker
{
fz_context *ctx;
hb_buffer_t *hb_buf;
- int r2l;
+ int rtl;
const char *start;
const char *end;
const char *s;
@@ -700,11 +700,11 @@ static int quick_ligature(fz_context *ctx, string_walker *walker, unsigned int i
return walker->glyph_info[i].codepoint;
}
-static void init_string_walker(fz_context *ctx, string_walker *walker, hb_buffer_t *hb_buf, int r2l, fz_font *font, int script, const char *text)
+static void init_string_walker(fz_context *ctx, string_walker *walker, hb_buffer_t *hb_buf, int rtl, fz_font *font, int script, const char *text)
{
walker->ctx = ctx;
walker->hb_buf = hb_buf;
- walker->r2l = r2l;
+ walker->rtl = rtl;
walker->start = text;
walker->end = text;
walker->s = text;
@@ -747,7 +747,7 @@ static int walk_string(string_walker *walker)
/* Disable harfbuzz shaping if script is common or LGC and there are no opentype tables. */
quickshape = 0;
- if (walker->script <= 3 && !walker->r2l && !walker->font->has_opentype)
+ if (walker->script <= 3 && !walker->rtl && !walker->font->has_opentype)
quickshape = 1;
hb_lock(ctx);
@@ -760,7 +760,7 @@ static int walk_string(string_walker *walker)
fz_throw(ctx, FZ_ERROR_GENERIC, "freetype setting character size: %s", ft_error_string(fterr));
hb_buffer_clear_contents(walker->hb_buf);
- hb_buffer_set_direction(walker->hb_buf, walker->r2l ? HB_DIRECTION_RTL : HB_DIRECTION_LTR);
+ hb_buffer_set_direction(walker->hb_buf, walker->rtl ? HB_DIRECTION_RTL : HB_DIRECTION_LTR);
/* hb_buffer_set_script(hb_buf, hb_ucdn_script_translate(script)); */
/* hb_buffer_set_language(hb_buf, hb_language_from_string("en", strlen("en"))); */
/* hb_buffer_set_cluster_level(hb_buf, HB_BUFFER_CLUSTER_LEVEL_CHARACTERS); */
@@ -920,7 +920,7 @@ static void layout_line(fz_context *ctx, float indent, float page_w, float line_
/* Do we need to do any reordering? */
if (min_level != max_level || (min_level & 1))
{
- /* The lowest level we swap is always a r2l one */
+ /* The lowest level we swap is always a rtl one */
min_level |= 1;
/* Each time around the loop we swap runs of fragments that have
* levels >= max_level (and decrement max_level). */
@@ -1038,7 +1038,7 @@ static void layout_flow(fz_context *ctx, fz_html *box, fz_html *top, float em, f
indent = box->is_first_flow ? fz_from_css_number(top->style.text_indent, em, top->w) : 0;
align = top->style.text_align;
- if (box->flow_dir == FZ_DIR_R2L)
+ if (box->flow_dir == FZ_BIDI_RTL)
{
if (align == TA_LEFT)
align = TA_RIGHT;
@@ -1545,7 +1545,7 @@ static void draw_list_mark(fz_context *ctx, fz_html *box, float page_top, float
{
s += fz_chartorune(&c, s);
g = fz_encode_character_with_fallback(ctx, box->style.font, c, UCDN_SCRIPT_LATIN, &font);
- fz_show_glyph(ctx, text, font, &trm, g, c, 0, 0, FZ_DIR_UNSET, FZ_LANG_UNSET);
+ fz_show_glyph(ctx, text, font, &trm, g, c, 0, 0, FZ_BIDI_NEUTRAL, FZ_LANG_UNSET);
trm.e += fz_advance_glyph(ctx, font, g, 0) * box->em;
}
@@ -1915,17 +1915,11 @@ static void fragment_cb(const uint32_t *fragment,
}
static void
-detect_flow_directionality(fz_context *ctx, fz_pool *pool, uni_buf *buffer, int baseDir, fz_html_flow *flow)
+detect_flow_directionality(fz_context *ctx, fz_pool *pool, uni_buf *buffer, fz_bidi_direction bidi_dir, fz_html_flow *flow)
{
fz_html_flow *end = flow;
const char *text;
bidi_data data;
- fz_bidi_direction bidi_dir = BIDI_NEUTRAL;
-
- if (baseDir == FZ_DIR_L2R)
- bidi_dir = BIDI_LEFT_TO_RIGHT;
- else if (baseDir == FZ_DIR_R2L)
- bidi_dir = BIDI_RIGHT_TO_LEFT;
while (end)
{
diff --git a/source/pdf/pdf-appearance.c b/source/pdf/pdf-appearance.c
index c64e73af..45d81c63 100644
--- a/source/pdf/pdf-appearance.c
+++ b/source/pdf/pdf-appearance.c
@@ -1916,7 +1916,7 @@ static void add_text(fz_context *ctx, font_info *font_rec, fz_text *text, char *
str += n;
str_len -= n;
gid = fz_encode_character(ctx, font, ucs);
- fz_show_glyph(ctx, text, font, &tm, gid, ucs, 0, 0, FZ_DIR_UNSET, FZ_LANG_UNSET);
+ fz_show_glyph(ctx, text, font, &tm, gid, ucs, 0, 0, FZ_BIDI_NEUTRAL, FZ_LANG_UNSET);
tm.e += fz_advance_glyph(ctx, font, gid, 0) * font_rec->da_rec.font_size;
}
}
diff --git a/source/pdf/pdf-op-run.c b/source/pdf/pdf-op-run.c
index 962c1845..cb83aa8b 100644
--- a/source/pdf/pdf-op-run.c
+++ b/source/pdf/pdf-op-run.c
@@ -943,11 +943,11 @@ pdf_show_char(fz_context *ctx, pdf_run_processor *pr, int cid)
fz_union_rect(&pr->text_bbox, &bbox);
/* add glyph to textobject */
- fz_show_glyph(ctx, pr->text, fontdesc->font, &trm, gid, ucsbuf[0], fontdesc->wmode, 0, FZ_DIR_UNSET, FZ_LANG_UNSET);
+ fz_show_glyph(ctx, pr->text, fontdesc->font, &trm, gid, ucsbuf[0], fontdesc->wmode, 0, FZ_BIDI_NEUTRAL, FZ_LANG_UNSET);
/* add filler glyphs for one-to-many unicode mapping */
for (i = 1; i < ucslen; i++)
- fz_show_glyph(ctx, pr->text, fontdesc->font, &trm, -1, ucsbuf[i], fontdesc->wmode, 0, FZ_DIR_UNSET, FZ_LANG_UNSET);
+ fz_show_glyph(ctx, pr->text, fontdesc->font, &trm, -1, ucsbuf[i], fontdesc->wmode, 0, FZ_BIDI_NEUTRAL, FZ_LANG_UNSET);
if (fontdesc->wmode == 0)
{
diff --git a/source/tools/murun.c b/source/tools/murun.c
index b7e328e7..2e11014e 100644
--- a/source/tools/murun.c
+++ b/source/tools/murun.c
@@ -1970,7 +1970,7 @@ static void ffi_Text_showGlyph(js_State *J)
int wmode = js_isdefined(J, 5) ? js_toboolean(J, 5) : 0;
fz_try(ctx)
- fz_show_glyph(ctx, text, font, &trm, glyph, unicode, wmode, 0, FZ_DIR_UNSET, FZ_LANG_UNSET);
+ fz_show_glyph(ctx, text, font, &trm, glyph, unicode, wmode, 0, FZ_BIDI_NEUTRAL, FZ_LANG_UNSET);
fz_catch(ctx)
rethrow(J);
}
@@ -1985,7 +1985,7 @@ static void ffi_Text_showString(js_State *J)
int wmode = js_isdefined(J, 4) ? js_toboolean(J, 4) : 0;
fz_try(ctx)
- fz_show_string(ctx, text, font, &trm, s, wmode, 0, FZ_DIR_UNSET, FZ_LANG_UNSET);
+ fz_show_string(ctx, text, font, &trm, s, wmode, 0, FZ_BIDI_NEUTRAL, FZ_LANG_UNSET);
fz_catch(ctx)
rethrow(J);
diff --git a/source/xps/xps-glyphs.c b/source/xps/xps-glyphs.c
index 3d0ebfd0..9110c169 100644
--- a/source/xps/xps-glyphs.c
+++ b/source/xps/xps-glyphs.c
@@ -451,7 +451,7 @@ xps_parse_glyphs_imp(fz_context *ctx, xps_document *doc, const fz_matrix *ctm,
tm.f = y - v_offset;
}
- dir = bidi_level & 1 ? FZ_DIR_R2L : FZ_DIR_L2R;
+ dir = bidi_level & 1 ? FZ_BIDI_RTL : FZ_BIDI_LTR;
fz_show_glyph(ctx, text, font, &tm, glyph_index, char_code, is_sideways, bidi_level, dir, FZ_LANG_UNSET);
x += advance * 0.01f * size;