diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2015-10-07 17:03:12 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2015-12-11 12:11:31 +0100 |
commit | e3275837d5738c5092b2e452829919e31ad553e5 (patch) | |
tree | 0b1ffed536e6887236c4e50cbb808808bbe2684e | |
parent | c22e6a6dc2bf6acbac955bd5fbdd896329dfd725 (diff) | |
download | mupdf-e3275837d5738c5092b2e452829919e31ad553e5.tar.xz |
Rename structured text structs and functions to 'stext'.
Less risk of confusion with the text type used in the device interface.
-rw-r--r-- | include/mupdf/fitz/structured-text.h | 108 | ||||
-rw-r--r-- | include/mupdf/fitz/util.h | 12 | ||||
-rw-r--r-- | platform/android/jni/mupdf.c | 74 | ||||
-rw-r--r-- | platform/ios/Classes/MuPageViewNormal.m | 24 | ||||
-rw-r--r-- | platform/ios/Classes/MuPageViewReflow.m | 18 | ||||
-rw-r--r-- | platform/ios/common.m | 12 | ||||
-rw-r--r-- | platform/x11/pdfapp.c | 26 | ||||
-rw-r--r-- | platform/x11/pdfapp.h | 4 | ||||
-rw-r--r-- | source/fitz/stext-device.c | 256 | ||||
-rw-r--r-- | source/fitz/stext-output.c | 48 | ||||
-rw-r--r-- | source/fitz/stext-paragraph.c | 84 | ||||
-rw-r--r-- | source/fitz/stext-search.c | 50 | ||||
-rw-r--r-- | source/fitz/util.c | 98 | ||||
-rw-r--r-- | source/tools/mudraw.c | 22 |
14 files changed, 418 insertions, 418 deletions
diff --git a/include/mupdf/fitz/structured-text.h b/include/mupdf/fitz/structured-text.h index e31276ef..ffb9f263 100644 --- a/include/mupdf/fitz/structured-text.h +++ b/include/mupdf/fitz/structured-text.h @@ -16,34 +16,34 @@ (In development - Subject to change in future versions) */ -typedef struct fz_text_style_s fz_text_style; -typedef struct fz_text_char_s fz_text_char; -typedef struct fz_text_span_s fz_text_span; -typedef struct fz_text_line_s fz_text_line; -typedef struct fz_text_block_s fz_text_block; +typedef struct fz_stext_style_s fz_stext_style; +typedef struct fz_stext_char_s fz_stext_char; +typedef struct fz_stext_span_s fz_stext_span; +typedef struct fz_stext_line_s fz_stext_line; +typedef struct fz_stext_block_s fz_stext_block; typedef struct fz_image_block_s fz_image_block; typedef struct fz_page_block_s fz_page_block; -typedef struct fz_text_sheet_s fz_text_sheet; -typedef struct fz_text_page_s fz_text_page; +typedef struct fz_stext_sheet_s fz_stext_sheet; +typedef struct fz_stext_page_s fz_stext_page; /* - fz_text_sheet: A text sheet contains a list of distinct text styles + fz_stext_sheet: A text sheet contains a list of distinct text styles used on a page (or a series of pages). */ -struct fz_text_sheet_s +struct fz_stext_sheet_s { int maxid; - fz_text_style *style; + fz_stext_style *style; }; /* - fz_text_style: A text style contains details of a distinct text style + fz_stext_style: A text style contains details of a distinct text style used on a page. */ -struct fz_text_style_s +struct fz_stext_style_s { - fz_text_style *next; + fz_stext_style *next; int id; fz_font *font; float size; @@ -58,15 +58,15 @@ struct fz_text_style_s }; /* - fz_text_page: A text page is a list of page blocks, together with + fz_stext_page: A text page is a list of page blocks, together with an overall bounding box. */ -struct fz_text_page_s +struct fz_stext_page_s { fz_rect mediabox; int len, cap; fz_page_block *blocks; - fz_text_page *next; + fz_stext_page *next; }; /* @@ -77,7 +77,7 @@ struct fz_page_block_s int type; union { - fz_text_block *text; + fz_stext_block *text; fz_image_block *image; } u; }; @@ -89,15 +89,15 @@ enum }; /* - fz_text_block: A text block is a list of lines of text. In typical + fz_stext_block: A text block is a list of lines of text. In typical cases this may correspond to a paragraph or a column of text. A collection of blocks makes up a page. */ -struct fz_text_block_s +struct fz_stext_block_s { fz_rect bbox; int len, cap; - fz_text_line *lines; + fz_stext_line *lines; }; /* @@ -115,13 +115,13 @@ struct fz_image_block_s }; /* - fz_text_line: A text line is a list of text spans, with the same + fz_stext_line: A text line is a list of text spans, with the same baseline. In typical cases this should correspond (as expected) to complete lines of text. A collection of lines makes up a block. */ -struct fz_text_line_s +struct fz_stext_line_s { - fz_text_span *first_span, *last_span; + fz_stext_span *first_span, *last_span; /* Cached information */ float distance; /* Perpendicular distance from previous line */ @@ -130,16 +130,16 @@ struct fz_text_line_s }; /* - fz_text_span: A text span is a list of characters that share a common + fz_stext_span: A text span is a list of characters that share a common baseline/transformation. In typical cases a single span may be enough to represent a complete line. In cases where the text has big gaps in it (perhaps as it crosses columns or tables), a line may be represented by multiple spans. */ -struct fz_text_span_s +struct fz_stext_span_s { int len, cap; - fz_text_char *text; + fz_stext_char *text; fz_point min; /* Device space */ fz_point max; /* Device space */ int wmode; /* 0 for horizontal, 1 for vertical */ @@ -159,19 +159,19 @@ struct fz_text_span_s int align; /* 0 = left, 1 = centre, 2 = right */ float indent; /* The indent position for this column. */ - fz_text_span *next; + fz_stext_span *next; }; /* - fz_text_char: A text char is a unicode character, the style in which + fz_stext_char: A text char is a unicode character, the style in which is appears, and the point at which it is positioned. Transform (and hence bbox) information is given by the enclosing span. */ -struct fz_text_char_s +struct fz_stext_char_s { fz_point p; /* Device space */ int c; - fz_text_style *style; + fz_stext_style *style; }; typedef struct fz_char_and_box_s fz_char_and_box; @@ -182,10 +182,10 @@ struct fz_char_and_box_s fz_rect bbox; }; -fz_char_and_box *fz_text_char_at(fz_context *ctx, fz_char_and_box *cab, fz_text_page *page, int idx); +fz_char_and_box *fz_stext_char_at(fz_context *ctx, fz_char_and_box *cab, fz_stext_page *page, int idx); /* - fz_text_char_bbox: Return the bbox of a text char. Calculated from + fz_stext_char_bbox: Return the bbox of a text char. Calculated from the supplied enclosing span. bbox: A place to store the bbox @@ -198,74 +198,74 @@ fz_char_and_box *fz_text_char_at(fz_context *ctx, fz_char_and_box *cab, fz_text_ Does not throw exceptions */ -fz_rect *fz_text_char_bbox(fz_context *ctx, fz_rect *bbox, fz_text_span *span, int idx); +fz_rect *fz_stext_char_bbox(fz_context *ctx, fz_rect *bbox, fz_stext_span *span, int idx); /* - fz_new_text_sheet: Create an empty style sheet. + fz_new_stext_sheet: Create an empty style sheet. The style sheet is filled out by the text device, creating one style for each unique font, color, size combination that is used. */ -fz_text_sheet *fz_new_text_sheet(fz_context *ctx); -void fz_drop_text_sheet(fz_context *ctx, fz_text_sheet *sheet); +fz_stext_sheet *fz_new_stext_sheet(fz_context *ctx); +void fz_drop_stext_sheet(fz_context *ctx, fz_stext_sheet *sheet); /* - fz_new_text_page: Create an empty text page. + fz_new_stext_page: Create an empty text page. The text page is filled out by the text device to contain the blocks, lines and spans of text on the page. */ -fz_text_page *fz_new_text_page(fz_context *ctx); -void fz_drop_text_page(fz_context *ctx, fz_text_page *page); +fz_stext_page *fz_new_stext_page(fz_context *ctx); +void fz_drop_stext_page(fz_context *ctx, fz_stext_page *page); -void fz_analyze_text(fz_context *ctx, fz_text_sheet *sheet, fz_text_page *page); +void fz_analyze_text(fz_context *ctx, fz_stext_sheet *sheet, fz_stext_page *page); /* - fz_print_text_sheet: Output a text sheet to a file as CSS. + fz_print_stext_sheet: Output a text sheet to a file as CSS. */ -void fz_print_text_sheet(fz_context *ctx, fz_output *out, fz_text_sheet *sheet); +void fz_print_stext_sheet(fz_context *ctx, fz_output *out, fz_stext_sheet *sheet); /* - fz_print_text_page_html: Output a page to a file in HTML format. + fz_print_stext_page_html: Output a page to a file in HTML format. */ -void fz_print_text_page_html(fz_context *ctx, fz_output *out, fz_text_page *page); +void fz_print_stext_page_html(fz_context *ctx, fz_output *out, fz_stext_page *page); /* - fz_print_text_page_xml: Output a page to a file in XML format. + fz_print_stext_page_xml: Output a page to a file in XML format. */ -void fz_print_text_page_xml(fz_context *ctx, fz_output *out, fz_text_page *page); +void fz_print_stext_page_xml(fz_context *ctx, fz_output *out, fz_stext_page *page); /* - fz_print_text_page: Output a page to a file in UTF-8 format. + fz_print_stext_page: Output a page to a file in UTF-8 format. */ -void fz_print_text_page(fz_context *ctx, fz_output *out, fz_text_page *page); +void fz_print_stext_page(fz_context *ctx, fz_output *out, fz_stext_page *page); /* - fz_search_text_page: Search for occurrence of 'needle' in text page. + fz_search_stext_page: Search for occurrence of 'needle' in text page. Return the number of hits and store hit bboxes in the passed in array. NOTE: This is an experimental interface and subject to change without notice. */ -int fz_search_text_page(fz_context *ctx, fz_text_page *text, const char *needle, fz_rect *hit_bbox, int hit_max); +int fz_search_stext_page(fz_context *ctx, fz_stext_page *text, const char *needle, fz_rect *hit_bbox, int hit_max); /* fz_highlight_selection: Return a list of rectangles to highlight given a selection rectangle. NOTE: This is an experimental interface and subject to change without notice. */ -int fz_highlight_selection(fz_context *ctx, fz_text_page *page, fz_rect rect, fz_rect *hit_bbox, int hit_max); +int fz_highlight_selection(fz_context *ctx, fz_stext_page *page, fz_rect rect, fz_rect *hit_bbox, int hit_max); /* fz_copy_selection: Return a newly allocated UTF-8 string with the text for a given selection rectangle. NOTE: This is an experimental interface and subject to change without notice. */ -char *fz_copy_selection(fz_context *ctx, fz_text_page *page, fz_rect rect); +char *fz_copy_selection(fz_context *ctx, fz_stext_page *page, fz_rect rect); /* - fz_new_text_device: Create a device to extract the text on a page. + fz_new_stext_device: Create a device to extract the text on a page. Gather and sort the text on a page into spans of uniform style, arranged into lines and blocks by reading order. The reading order @@ -281,6 +281,6 @@ char *fz_copy_selection(fz_context *ctx, fz_text_page *page, fz_rect rect); containing data already (for example when merging multiple pages, or watermarking). */ -fz_device *fz_new_text_device(fz_context *ctx, fz_text_sheet *sheet, fz_text_page *page); +fz_device *fz_new_stext_device(fz_context *ctx, fz_stext_sheet *sheet, fz_stext_page *page); #endif diff --git a/include/mupdf/fitz/util.h b/include/mupdf/fitz/util.h index fc66b47e..96c9e7a8 100644 --- a/include/mupdf/fitz/util.h +++ b/include/mupdf/fitz/util.h @@ -34,18 +34,18 @@ fz_pixmap *fz_new_pixmap_from_page_contents(fz_context *ctx, fz_page *page, cons fz_pixmap *fz_new_pixmap_from_annot(fz_context *ctx, fz_page *page, fz_annot *annot, const fz_matrix *ctm, fz_colorspace *cs); /* - fz_new_text_page_from_page: Extract structured text from a page. The sheet must not be NULL. + fz_new_stext_page_from_page: Extract structured text from a page. The sheet must not be NULL. */ -fz_text_page *fz_new_text_page_from_page(fz_context *ctx, fz_page *page, fz_text_sheet *sheet); -fz_text_page *fz_new_text_page_from_page_number(fz_context *ctx, fz_document *doc, int number, fz_text_sheet *sheet); -fz_text_page *fz_new_text_page_from_display_list(fz_context *ctx, fz_display_list *list, fz_text_sheet *sheet); +fz_stext_page *fz_new_stext_page_from_page(fz_context *ctx, fz_page *page, fz_stext_sheet *sheet); +fz_stext_page *fz_new_stext_page_from_page_number(fz_context *ctx, fz_document *doc, int number, fz_stext_sheet *sheet); +fz_stext_page *fz_new_stext_page_from_display_list(fz_context *ctx, fz_display_list *list, fz_stext_sheet *sheet); /* - fz_new_buffer_from_text_page: Convert structured text into plain text, cropped by the selection rectangle. + fz_new_buffer_from_stext_page: Convert structured text into plain text, cropped by the selection rectangle. Use fz_inifinite_rect to extract all the text on the page. If 'crlf' is true, lines are separated by '\r\n', otherwise '\n'. */ -fz_buffer *fz_new_buffer_from_text_page(fz_context *ctx, fz_text_page *text, const fz_rect *sel, int crlf); +fz_buffer *fz_new_buffer_from_stext_page(fz_context *ctx, fz_stext_page *text, const fz_rect *sel, int crlf); fz_buffer *fz_new_buffer_from_page(fz_context *ctx, fz_page *page, const fz_rect *sel, int crlf); fz_buffer *fz_new_buffer_from_page_number(fz_context *ctx, fz_document *doc, int number, const fz_rect *sel, int crlf); fz_buffer *fz_new_buffer_from_display_list(fz_context *ctx, fz_display_list *list, const fz_rect *sel, int crlf); diff --git a/platform/android/jni/mupdf.c b/platform/android/jni/mupdf.c index 72214597..1afd5c65 100644 --- a/platform/android/jni/mupdf.c +++ b/platform/android/jni/mupdf.c @@ -1042,36 +1042,36 @@ JNI_FN(MuPDFCore_updatePageInternal)(JNIEnv *env, jobject thiz, jobject bitmap, } static int -charat(fz_context *ctx, fz_text_page *page, int idx) +charat(fz_context *ctx, fz_stext_page *page, int idx) { fz_char_and_box cab; - return fz_text_char_at(ctx, &cab, page, idx)->c; + return fz_stext_char_at(ctx, &cab, page, idx)->c; } static fz_rect -bboxcharat(fz_context *ctx, fz_text_page *page, int idx) +bboxcharat(fz_context *ctx, fz_stext_page *page, int idx) { fz_char_and_box cab; - return fz_text_char_at(ctx, &cab, page, idx)->bbox; + return fz_stext_char_at(ctx, &cab, page, idx)->bbox; } static int -textlen(fz_text_page *page) +textlen(fz_stext_page *page) { int len = 0; int block_num; for (block_num = 0; block_num < page->len; block_num++) { - fz_text_block *block; - fz_text_line *line; + fz_stext_block *block; + fz_stext_line *line; if (page->blocks[block_num].type != FZ_PAGE_BLOCK_TEXT) continue; block = page->blocks[block_num].u.text; for (line = block->lines; line < block->lines + block->len; line++) { - fz_text_span *span; + fz_stext_span *span; for (span = line->first_span; span; span = span->next) { @@ -1209,8 +1209,8 @@ JNI_FN(MuPDFCore_searchPage)(JNIEnv * env, jobject thiz, jstring jtext) jmethodID ctor; jobjectArray arr; jobject rect; - fz_text_sheet *sheet = NULL; - fz_text_page *text = NULL; + fz_stext_sheet *sheet = NULL; + fz_stext_page *text = NULL; fz_device *dev = NULL; float zoom; fz_matrix ctm; @@ -1242,19 +1242,19 @@ JNI_FN(MuPDFCore_searchPage)(JNIEnv * env, jobject thiz, jstring jtext) zoom = glo->resolution / 72; fz_scale(&ctm, zoom, zoom); - sheet = fz_new_text_sheet(ctx); - text = fz_new_text_page(ctx); - dev = fz_new_text_device(ctx, sheet, text); + sheet = fz_new_stext_sheet(ctx); + text = fz_new_stext_page(ctx); + dev = fz_new_stext_device(ctx, sheet, text); fz_run_page(ctx, pc->page, dev, &ctm, NULL); fz_drop_device(ctx, dev); dev = NULL; - hit_count = fz_search_text_page(ctx, text, str, glo->hit_bbox, MAX_SEARCH_HITS); + hit_count = fz_search_stext_page(ctx, text, str, glo->hit_bbox, MAX_SEARCH_HITS); } fz_always(ctx) { - fz_drop_text_page(ctx, text); - fz_drop_text_sheet(ctx, sheet); + fz_drop_stext_page(ctx, text); + fz_drop_stext_sheet(ctx, sheet); fz_drop_device(ctx, dev); } fz_catch(ctx) @@ -1301,8 +1301,8 @@ JNI_FN(MuPDFCore_text)(JNIEnv * env, jobject thiz) jclass textBlockClass; jmethodID ctor; jobjectArray barr = NULL; - fz_text_sheet *sheet = NULL; - fz_text_page *text = NULL; + fz_stext_sheet *sheet = NULL; + fz_stext_page *text = NULL; fz_device *dev = NULL; float zoom; fz_matrix ctm; @@ -1332,9 +1332,9 @@ JNI_FN(MuPDFCore_text)(JNIEnv * env, jobject thiz) zoom = glo->resolution / 72; fz_scale(&ctm, zoom, zoom); - sheet = fz_new_text_sheet(ctx); - text = fz_new_text_page(ctx); - dev = fz_new_text_device(ctx, sheet, text); + sheet = fz_new_stext_sheet(ctx); + text = fz_new_stext_page(ctx); + dev = fz_new_stext_device(ctx, sheet, text); fz_run_page(ctx, pc->page, dev, &ctm, NULL); fz_drop_device(ctx, dev); dev = NULL; @@ -1344,7 +1344,7 @@ JNI_FN(MuPDFCore_text)(JNIEnv * env, jobject thiz) for (b = 0; b < text->len; b++) { - fz_text_block *block; + fz_stext_block *block; jobjectArray *larr; if (text->blocks[b].type != FZ_PAGE_BLOCK_TEXT) @@ -1355,9 +1355,9 @@ JNI_FN(MuPDFCore_text)(JNIEnv * env, jobject thiz) for (l = 0; l < block->len; l++) { - fz_text_line *line = &block->lines[l]; + fz_stext_line *line = &block->lines[l]; jobjectArray *sarr; - fz_text_span *span; + fz_stext_span *span; int len = 0; for (span = line->first_span; span; span = span->next) @@ -1373,9 +1373,9 @@ JNI_FN(MuPDFCore_text)(JNIEnv * env, jobject thiz) for (c = 0; c < span->len; c++) { - fz_text_char *ch = &span->text[c]; + fz_stext_char *ch = &span->text[c]; fz_rect bbox; - fz_text_char_bbox(ctx, &bbox, span, c); + fz_stext_char_bbox(ctx, &bbox, span, c); jobject cobj = (*env)->NewObject(env, textCharClass, ctor, bbox.x0, bbox.y0, bbox.x1, bbox.y1, ch->c); if (cobj == NULL) fz_throw(ctx, FZ_ERROR_GENERIC, "NewObjectfailed"); @@ -1397,8 +1397,8 @@ JNI_FN(MuPDFCore_text)(JNIEnv * env, jobject thiz) } fz_always(ctx) { - fz_drop_text_page(ctx, text); - fz_drop_text_sheet(ctx, sheet); + fz_drop_stext_page(ctx, text); + fz_drop_stext_sheet(ctx, sheet); fz_drop_device(ctx, dev); } fz_catch(ctx) @@ -1417,8 +1417,8 @@ JNI_FN(MuPDFCore_text)(JNIEnv * env, jobject thiz) JNIEXPORT jbyteArray JNICALL JNI_FN(MuPDFCore_textAsHtml)(JNIEnv * env, jobject thiz) { - fz_text_sheet *sheet = NULL; - fz_text_page *text = NULL; + fz_stext_sheet *sheet = NULL; + fz_stext_page *text = NULL; fz_device *dev = NULL; fz_matrix ctm; globals *glo = get_globals(env, thiz); @@ -1440,9 +1440,9 @@ JNI_FN(MuPDFCore_textAsHtml)(JNIEnv * env, jobject thiz) int b, l, s, c; ctm = fz_identity; - sheet = fz_new_text_sheet(ctx); - text = fz_new_text_page(ctx); - dev = fz_new_text_device(ctx, sheet, text); + sheet = fz_new_stext_sheet(ctx); + text = fz_new_stext_page(ctx); + dev = fz_new_stext_device(ctx, sheet, text); fz_run_page(ctx, pc->page, dev, &ctm, NULL); fz_drop_device(ctx, dev); dev = NULL; @@ -1462,10 +1462,10 @@ JNI_FN(MuPDFCore_textAsHtml)(JNIEnv * env, jobject thiz) //fz_printf(ctx, out, "p{margin:0;padding:0;}\n"); fz_printf(ctx, out, "</style>\n"); fz_printf(ctx, out, "<body style=\"margin:0\"><div style=\"padding:10px\" id=\"content\">"); - fz_print_text_page_html(ctx, out, text); + fz_print_stext_page_html(ctx, out, text); fz_printf(ctx, out, "</div></body>\n"); fz_printf(ctx, out, "<style>\n"); - fz_print_text_sheet(ctx, out, sheet); + fz_print_stext_sheet(ctx, out, sheet); fz_printf(ctx, out, "</style>\n</html>\n"); fz_drop_output(ctx, out); out = NULL; @@ -1478,8 +1478,8 @@ JNI_FN(MuPDFCore_textAsHtml)(JNIEnv * env, jobject thiz) } fz_always(ctx) { - fz_drop_text_page(ctx, text); - fz_drop_text_sheet(ctx, sheet); + fz_drop_stext_page(ctx, text); + fz_drop_stext_sheet(ctx, sheet); fz_drop_device(ctx, dev); fz_drop_output(ctx, out); fz_drop_buffer(ctx, buf); diff --git a/platform/ios/Classes/MuPageViewNormal.m b/platform/ios/Classes/MuPageViewNormal.m index 429785fe..f82c3413 100644 --- a/platform/ios/Classes/MuPageViewNormal.m +++ b/platform/ios/Classes/MuPageViewNormal.m @@ -56,8 +56,8 @@ static NSArray *enumerateAnnotations(fz_document *doc, fz_page *page) static NSArray *enumerateWords(fz_document *doc, fz_page *page) { - fz_text_sheet *sheet = NULL; - fz_text_page *text = NULL; + fz_stext_sheet *sheet = NULL; + fz_stext_page *text = NULL; fz_device *dev = NULL; NSMutableArray *lns = [NSMutableArray array]; NSMutableArray *wds; @@ -74,16 +74,16 @@ static NSArray *enumerateWords(fz_document *doc, fz_page *page) { int b, l, c; - sheet = fz_new_text_sheet(ctx); - text = fz_new_text_page(ctx); - dev = fz_new_text_device(ctx, sheet, text); + sheet = fz_new_stext_sheet(ctx); + text = fz_new_stext_page(ctx); + dev = fz_new_stext_device(ctx, sheet, text); fz_run_page(ctx, page, dev, &fz_identity, NULL); fz_drop_device(ctx, dev); dev = NULL; for (b = 0; b < text->len; b++) { - fz_text_block *block; + fz_stext_block *block; if (text->blocks[b].type != FZ_PAGE_BLOCK_TEXT) continue; @@ -92,8 +92,8 @@ static NSArray *enumerateWords(fz_document *doc, fz_page *page) for (l = 0; l < block->len; l++) { - fz_text_line *line = &block->lines[l]; - fz_text_span *span; + fz_stext_line *line = &block->lines[l]; + fz_stext_span *span; wds = [NSMutableArray array]; if (!wds) @@ -107,11 +107,11 @@ static NSArray *enumerateWords(fz_document *doc, fz_page *page) { for (c = 0; c < span->len; c++) { - fz_text_char *ch = &span->text[c]; + fz_stext_char *ch = &span->text[c]; fz_rect bbox; CGRect rect; - fz_text_char_bbox(ctx, &bbox, span, c); + fz_stext_char_bbox(ctx, &bbox, span, c); rect = CGRectMake(bbox.x0, bbox.y0, bbox.x1 - bbox.x0, bbox.y1 - bbox.y0); if (ch->c != ' ') @@ -138,8 +138,8 @@ static NSArray *enumerateWords(fz_document *doc, fz_page *page) } fz_always(ctx); { - fz_drop_text_page(ctx, text); - fz_drop_text_sheet(ctx, sheet); + fz_drop_stext_page(ctx, text); + fz_drop_stext_sheet(ctx, sheet); fz_drop_device(ctx, dev); } fz_catch(ctx) diff --git a/platform/ios/Classes/MuPageViewReflow.m b/platform/ios/Classes/MuPageViewReflow.m index 44f4f4ae..2c093fd9 100644 --- a/platform/ios/Classes/MuPageViewReflow.m +++ b/platform/ios/Classes/MuPageViewReflow.m @@ -5,8 +5,8 @@ NSString *textAsHtml(fz_document *doc, int pageNum) { NSString *str = nil; fz_page *page = NULL; - fz_text_sheet *sheet = NULL; - fz_text_page *text = NULL; + fz_stext_sheet *sheet = NULL; + fz_stext_page *text = NULL; fz_device *dev = NULL; fz_matrix ctm; fz_buffer *buf = NULL; @@ -22,9 +22,9 @@ NSString *textAsHtml(fz_document *doc, int pageNum) fz_try(ctx) { ctm = fz_identity; - sheet = fz_new_text_sheet(ctx); - text = fz_new_text_page(ctx); - dev = fz_new_text_device(ctx, sheet, text); + sheet = fz_new_stext_sheet(ctx); + text = fz_new_stext_page(ctx); + dev = fz_new_stext_device(ctx, sheet, text); page = fz_load_page(ctx, doc, pageNum); fz_run_page(ctx, page, dev, &ctm, NULL); fz_drop_device(ctx, dev); @@ -45,10 +45,10 @@ NSString *textAsHtml(fz_document *doc, int pageNum) //fz_printf(ctx, out, "p{margin:0;padding:0;}\n"); fz_printf(ctx, out, "</style>\n"); fz_printf(ctx, out, "<body style=\"margin:0\"><div style=\"padding:10px\" id=\"content\">"); - fz_print_text_page_html(ctx, out, text); + fz_print_stext_page_html(ctx, out, text); fz_printf(ctx, out, "</div></body>\n"); fz_printf(ctx, out, "<style>\n"); - fz_print_text_sheet(ctx, out, sheet); + fz_print_stext_sheet(ctx, out, sheet); fz_printf(ctx, out, "</style>\n</html>\n"); out = NULL; @@ -57,8 +57,8 @@ NSString *textAsHtml(fz_document *doc, int pageNum) } fz_always(ctx) { - fz_drop_text_page(ctx, text); - fz_drop_text_sheet(ctx, sheet); + fz_drop_stext_page(ctx, text); + fz_drop_stext_sheet(ctx, sheet); fz_drop_device(ctx, dev); fz_drop_output(ctx, out); fz_drop_buffer(ctx, buf); diff --git a/platform/ios/common.m b/platform/ios/common.m index 6f62329a..6ee3653f 100644 --- a/platform/ios/common.m +++ b/platform/ios/common.m @@ -21,16 +21,16 @@ int search_page(fz_document *doc, int number, char *needle, fz_cookie *cookie) { fz_page *page = fz_load_page(ctx, doc, number); - fz_text_sheet *sheet = fz_new_text_sheet(ctx); - fz_text_page *text = fz_new_text_page(ctx); - fz_device *dev = fz_new_text_device(ctx, sheet, text); + fz_stext_sheet *sheet = fz_new_stext_sheet(ctx); + fz_stext_page *text = fz_new_stext_page(ctx); + fz_device *dev = fz_new_stext_device(ctx, sheet, text); fz_run_page(ctx, page, dev, &fz_identity, cookie); fz_drop_device(ctx, dev); - hit_count = fz_search_text_page(ctx, text, needle, hit_bbox, nelem(hit_bbox)); + hit_count = fz_search_stext_page(ctx, text, needle, hit_bbox, nelem(hit_bbox)); - fz_drop_text_page(ctx, text); - fz_drop_text_sheet(ctx, sheet); + fz_drop_stext_page(ctx, text); + fz_drop_stext_sheet(ctx, sheet); fz_drop_page(ctx, page); return hit_count; diff --git a/platform/x11/pdfapp.c b/platform/x11/pdfapp.c index 5a036d04..be8ab751 100644 --- a/platform/x11/pdfapp.c +++ b/platform/x11/pdfapp.c @@ -479,10 +479,10 @@ void pdfapp_close(pdfapp_t *app) fz_drop_display_list(app->ctx, app->annotations_list); app->annotations_list = NULL; - fz_drop_text_page(app->ctx, app->page_text); + fz_drop_stext_page(app->ctx, app->page_text); app->page_text = NULL; - fz_drop_text_sheet(app->ctx, app->page_sheet); + fz_drop_stext_sheet(app->ctx, app->page_sheet); app->page_sheet = NULL; fz_drop_link(app->ctx, app->page_links); @@ -660,8 +660,8 @@ static void pdfapp_loadpage(pdfapp_t *app, int no_cache) fz_drop_display_list(app->ctx, app->page_list); fz_drop_display_list(app->ctx, app->annotations_list); - fz_drop_text_page(app->ctx, app->page_text); - fz_drop_text_sheet(app->ctx, app->page_sheet); + fz_drop_stext_page(app->ctx, app->page_text); + fz_drop_stext_sheet(app->ctx, app->page_sheet); fz_drop_link(app->ctx, app->page_links); fz_drop_page(app->ctx, app->page); @@ -879,12 +879,12 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai app->hit_count = 0; /* Extract text */ - app->page_sheet = fz_new_text_sheet(app->ctx); - app->page_text = fz_new_text_page(app->ctx); + app->page_sheet = fz_new_stext_sheet(app->ctx); + app->page_text = fz_new_stext_page(app->ctx); if (app->page_list || app->annotations_list) { - tdev = fz_new_text_device(app->ctx, app->page_sheet, app->page_text); + tdev = fz_new_stext_device(app->ctx, app->page_sheet, app->page_text); pdfapp_runpage(app, tdev, &fz_identity, &fz_infinite_rect, &cookie); fz_drop_device(app->ctx, tdev); } @@ -1060,7 +1060,7 @@ static void pdfapp_search_in_direction(pdfapp_t *app, enum panning *panto, int d pdfapp_showpage(app, 1, 0, 0, 0, 1); } - app->hit_count = fz_search_text_page(app->ctx, app->page_text, app->search, app->hit_bbox, nelem(app->hit_bbox)); + app->hit_count = fz_search_stext_page(app->ctx, app->page_text, app->search, app->hit_bbox, nelem(app->hit_bbox)); if (app->hit_count > 0) { *panto = dir == 1 ? PAN_TO_TOP : PAN_TO_BOTTOM; @@ -1884,7 +1884,7 @@ void pdfapp_oncopy(pdfapp_t *app, unsigned short *ucsbuf, int ucslen) { fz_rect hitbox; fz_matrix ctm; - fz_text_page *page = app->page_text; + fz_stext_page *page = app->page_text; int c, i, p, need_newline; int block_num; @@ -1900,9 +1900,9 @@ void pdfapp_oncopy(pdfapp_t *app, unsigned short *ucsbuf, int ucslen) for (block_num = 0; block_num < page->len; block_num++) { - fz_text_line *line; - fz_text_block *block; - fz_text_span *span; + fz_stext_line *line; + fz_stext_block *block; + fz_stext_span *span; if (page->blocks[block_num].type != FZ_PAGE_BLOCK_TEXT) continue; @@ -1916,7 +1916,7 @@ void pdfapp_oncopy(pdfapp_t *app, unsigned short *ucsbuf, int ucslen) { for (i = 0; i < span->len; i++) { - fz_text_char_bbox(app->ctx, &hitbox, span, i); + fz_stext_char_bbox(app->ctx, &hitbox, span, i); fz_transform_rect(&hitbox, &ctm); c = span->text[i].c; if (c < 32) diff --git a/platform/x11/pdfapp.h b/platform/x11/pdfapp.h index 6a81f871..803ca351 100644 --- a/platform/x11/pdfapp.h +++ b/platform/x11/pdfapp.h @@ -86,8 +86,8 @@ struct pdfapp_s fz_rect page_bbox; fz_display_list *page_list; fz_display_list *annotations_list; - fz_text_page *page_text; - fz_text_sheet *page_sheet; + fz_stext_page *page_text; + fz_stext_sheet *page_sheet; fz_link *page_links; int errored; int incomplete; diff --git a/source/fitz/stext-device.c b/source/fitz/stext-device.c index dc375c71..4e14b298 100644 --- a/source/fitz/stext-device.c +++ b/source/fitz/stext-device.c @@ -18,17 +18,17 @@ #include FT_FREETYPE_H #include FT_ADVANCES_H -typedef struct fz_text_device_s fz_text_device; +typedef struct fz_stext_device_s fz_stext_device; typedef struct span_soup_s span_soup; -struct fz_text_device_s +struct fz_stext_device_s { fz_device super; - fz_text_sheet *sheet; - fz_text_page *page; + fz_stext_sheet *sheet; + fz_stext_page *page; span_soup *spans; - fz_text_span *cur_span; + fz_stext_span *cur_span; int lastchar; }; @@ -47,11 +47,11 @@ add_point_to_rect(fz_rect *a, const fz_point *p) } fz_rect * -fz_text_char_bbox(fz_context *ctx, fz_rect *bbox, fz_text_span *span, int i) +fz_stext_char_bbox(fz_context *ctx, fz_rect *bbox, fz_stext_span *span, int i) { fz_point a, d; const fz_point *max; - fz_text_char *ch; + fz_stext_char *ch; if (!span || i >= span->len) { @@ -94,7 +94,7 @@ fz_text_char_bbox(fz_context *ctx, fz_rect *bbox, fz_text_span *span, int i) } static void -add_bbox_to_span(fz_text_span *span) +add_bbox_to_span(fz_stext_span *span) { fz_point a, d; fz_rect *bbox = &span->bbox; @@ -133,7 +133,7 @@ add_bbox_to_span(fz_text_span *span) struct span_soup_s { int len, cap; - fz_text_span **spans; + fz_stext_span **spans; }; static span_soup * @@ -162,7 +162,7 @@ free_span_soup(fz_context *ctx, span_soup *soup) } static void -add_span_to_soup(fz_context *ctx, span_soup *soup, fz_text_span *span) +add_span_to_soup(fz_context *ctx, span_soup *soup, fz_stext_span *span) { if (span == NULL) return; @@ -176,12 +176,12 @@ add_span_to_soup(fz_context *ctx, span_soup *soup, fz_text_span *span) soup->spans[soup->len++] = span; } -static fz_text_line * -push_span(fz_context *ctx, fz_text_device *tdev, fz_text_span *span, int new_line, float distance) +static fz_stext_line * +push_span(fz_context *ctx, fz_stext_device *tdev, fz_stext_span *span, int new_line, float distance) { - fz_text_line *line; - fz_text_block *block; - fz_text_page *page = tdev->page; + fz_stext_line *line; + fz_stext_block *block; + fz_stext_page *page = tdev->page; int prev_not_text = 0; if (page->len == 0 || page->blocks[page->len-1].type != FZ_PAGE_BLOCK_TEXT) @@ -200,7 +200,7 @@ push_span(fz_context *ctx, fz_text_device *tdev, fz_text_span *span, int new_lin page->blocks = fz_resize_array(ctx, page->blocks, newcap, sizeof(*page->blocks)); page->cap = newcap; } - block = fz_malloc_struct(ctx, fz_text_block); + block = fz_malloc_struct(ctx, fz_stext_block); page->blocks[page->len].type = FZ_PAGE_BLOCK_TEXT; page->blocks[page->len].u.text = block; block->cap = 0; @@ -250,7 +250,7 @@ push_span(fz_context *ctx, fz_text_device *tdev, fz_text_span *span, int new_lin #if defined(DEBUG_SPANS) || defined(DEBUG_ALIGN) || defined(DEBUG_INDENTS) static void -dump_span(fz_text_span *s) +dump_span(fz_stext_span *s) { int i; for (i=0; i < s->len; i++) @@ -262,12 +262,12 @@ dump_span(fz_text_span *s) #ifdef DEBUG_ALIGN static void -dump_line(fz_text_line *line) +dump_line(fz_stext_line *line) { int i; for (i=0; i < line->len; i++) { - fz_text_span *s = line->spans[i]; + fz_stext_span *s = line->spans[i]; if (s->spacing > 1) printf(" "); dump_span(s); @@ -277,11 +277,11 @@ dump_line(fz_text_line *line) #endif static void -strain_soup(fz_context *ctx, fz_text_device *tdev) +strain_soup(fz_context *ctx, fz_stext_device *tdev) { span_soup *soup = tdev->spans; - fz_text_line *last_line = NULL; - fz_text_span *last_span = NULL; + fz_stext_line *last_line = NULL; + fz_stext_span *last_span = NULL; int span_num; if (soup == NULL) @@ -290,7 +290,7 @@ strain_soup(fz_context *ctx, fz_text_device *tdev) /* Really dumb implementation to match what we had before */ for (span_num=0; span_num < soup->len; span_num++) { - fz_text_span *span = soup->spans[span_num]; + fz_stext_span *span = soup->spans[span_num]; int new_line = 1; float distance = 0; float spacing = 0; @@ -379,19 +379,19 @@ strain_soup(fz_context *ctx, fz_text_device *tdev) } } -fz_text_sheet * -fz_new_text_sheet(fz_context *ctx) +fz_stext_sheet * +fz_new_stext_sheet(fz_context *ctx) { - fz_text_sheet *sheet = fz_malloc(ctx, sizeof *sheet); + fz_stext_sheet *sheet = fz_malloc(ctx, sizeof *sheet); sheet->maxid = 0; sheet->style = NULL; return sheet; } void -fz_drop_text_sheet(fz_context *ctx, fz_text_sheet *sheet) +fz_drop_stext_sheet(fz_context *ctx, fz_stext_sheet *sheet) { - fz_text_style *style; + fz_stext_style *style; if (sheet == NULL) return; @@ -399,7 +399,7 @@ fz_drop_text_sheet(fz_context *ctx, fz_text_sheet *sheet) style = sheet->style; while (style) { - fz_text_style *next = style->next; + fz_stext_style *next = style->next; fz_drop_font(ctx, style->font); fz_free(ctx, style); style = next; @@ -407,11 +407,11 @@ fz_drop_text_sheet(fz_context *ctx, fz_text_sheet *sheet) fz_free(ctx, sheet); } -static fz_text_style * -fz_lookup_text_style_imp(fz_context *ctx, fz_text_sheet *sheet, +static fz_stext_style * +fz_lookup_stext_style_imp(fz_context *ctx, fz_stext_sheet *sheet, float size, fz_font *font, int wmode, int script) { - fz_text_style *style; + fz_stext_style *style; for (style = sheet->style; style; style = style->next) { @@ -436,8 +436,8 @@ fz_lookup_text_style_imp(fz_context *ctx, fz_text_sheet *sheet, return style; } -static fz_text_style * -fz_lookup_text_style(fz_context *ctx, fz_text_sheet *sheet, fz_text *text, const fz_matrix *ctm, +static fz_stext_style * +fz_lookup_stext_style(fz_context *ctx, fz_stext_sheet *sheet, fz_text *text, const fz_matrix *ctm, fz_colorspace *colorspace, float *color, float alpha, fz_stroke_state *stroke) { float size = 1.0f; @@ -452,13 +452,13 @@ fz_lookup_text_style(fz_context *ctx, fz_text_sheet *sheet, fz_text *text, const fz_concat(&trm, &tm, ctm); size = fz_matrix_expansion(&trm); } - return fz_lookup_text_style_imp(ctx, sheet, size, font, wmode, 0); + return fz_lookup_stext_style_imp(ctx, sheet, size, font, wmode, 0); } -fz_text_page * -fz_new_text_page(fz_context *ctx) +fz_stext_page * +fz_new_stext_page(fz_context *ctx) { - fz_text_page *page = fz_malloc(ctx, sizeof(*page)); + fz_stext_page *page = fz_malloc(ctx, sizeof(*page)); page->mediabox = fz_empty_rect; page->len = 0; page->cap = 0; @@ -468,9 +468,9 @@ fz_new_text_page(fz_context *ctx) } static void -fz_drop_text_line_contents(fz_context *ctx, fz_text_line *line) +fz_drop_stext_line_contents(fz_context *ctx, fz_stext_line *line) { - fz_text_span *span, *next; + fz_stext_span *span, *next; for (span = line->first_span; span; span=next) { next = span->next; @@ -480,13 +480,13 @@ fz_drop_text_line_contents(fz_context *ctx, fz_text_line *line) } static void -fz_drop_text_block(fz_context *ctx, fz_text_block *block) +fz_drop_stext_block(fz_context *ctx, fz_stext_block *block) { - fz_text_line *line; + fz_stext_line *line; if (block == NULL) return; for (line = block->lines; line < block->lines + block->len; line++) - fz_drop_text_line_contents(ctx, line); + fz_drop_stext_line_contents(ctx, line); fz_free(ctx, block->lines); fz_free(ctx, block); } @@ -502,7 +502,7 @@ fz_drop_image_block(fz_context *ctx, fz_image_block *block) } void -fz_drop_text_page(fz_context *ctx, fz_text_page *page) +fz_drop_stext_page(fz_context *ctx, fz_stext_page *page) { fz_page_block *block; if (page == NULL) @@ -512,7 +512,7 @@ fz_drop_text_page(fz_context *ctx, fz_text_page *page) switch (block->type) { case FZ_PAGE_BLOCK_TEXT: - fz_drop_text_block(ctx, block->u.text); + fz_drop_stext_block(ctx, block->u.text); break; case FZ_PAGE_BLOCK_IMAGE: fz_drop_image_block(ctx, block->u.image); @@ -523,10 +523,10 @@ fz_drop_text_page(fz_context *ctx, fz_text_page *page) fz_free(ctx, page); } -static fz_text_span * -fz_new_text_span(fz_context *ctx, const fz_point *p, int wmode, const fz_matrix *trm) +static fz_stext_span * +fz_new_stext_span(fz_context *ctx, const fz_point *p, int wmode, const fz_matrix *trm) { - fz_text_span *span = fz_malloc_struct(ctx, fz_text_span); + fz_stext_span *span = fz_malloc_struct(ctx, fz_stext_span); span->ascender_max = 0; span->descender_min = 0; span->cap = 0; @@ -546,12 +546,12 @@ fz_new_text_span(fz_context *ctx, const fz_point *p, int wmode, const fz_matrix } static void -add_char_to_span(fz_context *ctx, fz_text_span *span, int c, fz_point *p, fz_point *max, fz_text_style *style) +add_char_to_span(fz_context *ctx, fz_stext_span *span, int c, fz_point *p, fz_point *max, fz_stext_style *style) { if (span->len == span->cap) { int newcap = (span->cap ? span->cap * 2 : 16); - span->text = fz_resize_array(ctx, span->text, newcap, sizeof(fz_text_char)); + span->text = fz_resize_array(ctx, span->text, newcap, sizeof(fz_stext_char)); span->cap = newcap; span->bbox = fz_empty_rect; } @@ -567,7 +567,7 @@ add_char_to_span(fz_context *ctx, fz_text_span *span, int c, fz_point *p, fz_poi } static void -fz_add_text_char_imp(fz_context *ctx, fz_text_device *dev, fz_text_style *style, int c, fz_matrix *trm, float adv, int wmode) +fz_add_stext_char_imp(fz_context *ctx, fz_stext_device *dev, fz_stext_style *style, int c, fz_matrix *trm, float adv, int wmode) { int can_append = 1; int add_space = 0; @@ -690,7 +690,7 @@ fz_add_text_char_imp(fz_context *ctx, fz_text_device *dev, fz_text_style *style, /* Start a new span */ add_span_to_soup(ctx, dev->spans, dev->cur_span); dev->cur_span = NULL; - dev->cur_span = fz_new_text_span(ctx, &p, wmode, trm); + dev->cur_span = fz_new_stext_span(ctx, &p, wmode, trm); dev->cur_span->spacing = 0; } if (add_space) @@ -704,47 +704,47 @@ fz_add_text_char_imp(fz_context *ctx, fz_text_device *dev, fz_text_style *style, } static void -fz_add_text_char(fz_context *ctx, fz_text_device *dev, fz_text_style *style, int c, fz_matrix *trm, float adv, int wmode) +fz_add_stext_char(fz_context *ctx, fz_stext_device *dev, fz_stext_style *style, int c, fz_matrix *trm, float adv, int wmode) { switch (c) { case -1: /* ignore when one unicode character maps to multiple glyphs */ break; case 0xFB00: /* ff */ - fz_add_text_char_imp(ctx, dev, style, 'f', trm, adv/2, wmode); - fz_add_text_char_imp(ctx, dev, style, 'f', trm, adv/2, wmode); + fz_add_stext_char_imp(ctx, dev, style, 'f', trm, adv/2, wmode); + fz_add_stext_char_imp(ctx, dev, style, 'f', trm, adv/2, wmode); break; case 0xFB01: /* fi */ - fz_add_text_char_imp(ctx, dev, style, 'f', trm, adv/2, wmode); - fz_add_text_char_imp(ctx, dev, style, 'i', trm, adv/2, wmode); + fz_add_stext_char_imp(ctx, dev, style, 'f', trm, adv/2, wmode); + fz_add_stext_char_imp(ctx, dev, style, 'i', trm, adv/2, wmode); break; case 0xFB02: /* fl */ - fz_add_text_char_imp(ctx, dev, style, 'f', trm, adv/2, wmode); - fz_add_text_char_imp(ctx, dev, style, 'l', trm, adv/2, wmode); + fz_add_stext_char_imp(ctx, dev, style, 'f', trm, adv/2, wmode); + fz_add_stext_char_imp(ctx, dev, style, 'l', trm, adv/2, wmode); break; case 0xFB03: /* ffi */ - fz_add_text_char_imp(ctx, dev, style, 'f', trm, adv/3, wmode); - fz_add_text_char_imp(ctx, dev, style, 'f', trm, adv/3, wmode); - fz_add_text_char_imp(ctx, dev, style, 'i', trm, adv/3, wmode); + fz_add_stext_char_imp(ctx, dev, style, 'f', trm, adv/3, wmode); + fz_add_stext_char_imp(ctx, dev, style, 'f', trm, adv/3, wmode); + fz_add_stext_char_imp(ctx, dev, style, 'i', trm, adv/3, wmode); break; case 0xFB04: /* ffl */ - fz_add_text_char_imp(ctx, dev, style, 'f', trm, adv/3, wmode); - fz_add_text_char_imp(ctx, dev, style, 'f', trm, adv/3, wmode); - fz_add_text_char_imp(ctx, dev, style, 'l', trm, adv/3, wmode); + fz_add_stext_char_imp(ctx, dev, style, 'f', trm, adv/3, wmode); + fz_add_stext_char_imp(ctx, dev, style, 'f', trm, adv/3, wmode); + fz_add_stext_char_imp(ctx, dev, style, 'l', trm, adv/3, wmode); break; case 0xFB05: /* long st */ case 0xFB06: /* st */ - fz_add_text_char_imp(ctx, dev, style, 's', trm, adv/2, wmode); - fz_add_text_char_imp(ctx, dev, style, 't', trm, adv/2, wmode); + fz_add_stext_char_imp(ctx, dev, style, 's', trm, adv/2, wmode); + fz_add_stext_char_imp(ctx, dev, style, 't', trm, adv/2, wmode); break; default: - fz_add_text_char_imp(ctx, dev, style, c, trm, adv, wmode); + fz_add_stext_char_imp(ctx, dev, style, c, trm, adv, wmode); break; } } static void -fz_text_extract(fz_context *ctx, fz_text_device *dev, fz_text *text, const fz_matrix *ctm, fz_text_style *style) +fz_stext_extract(fz_context *ctx, fz_stext_device *dev, fz_text *text, const fz_matrix *ctm, fz_stext_style *style) { fz_font *font = text->font; FT_Face face = font->ft_face; @@ -810,13 +810,13 @@ fz_text_extract(fz_context *ctx, fz_text_device *dev, fz_text *text, const fz_ma if (multi == 1) { - fz_add_text_char(ctx, dev, style, text->items[i].ucs, &trm, adv, text->wmode); + fz_add_stext_char(ctx, dev, style, text->items[i].ucs, &trm, adv, text->wmode); } else { for (j = 0; j < multi; j++) { - fz_add_text_char(ctx, dev, style, text->items[i + j].ucs, &trm, adv/multi, text->wmode); + fz_add_stext_char(ctx, dev, style, text->items[i + j].ucs, &trm, adv/multi, text->wmode); } i += j - 1; } @@ -826,58 +826,58 @@ fz_text_extract(fz_context *ctx, fz_text_device *dev, fz_text *text, const fz_ma } static void -fz_text_fill_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm, +fz_stext_fill_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm, fz_colorspace *colorspace, float *color, float alpha) { - fz_text_device *tdev = (fz_text_device*)dev; - fz_text_style *style; - style = fz_lookup_text_style(ctx, tdev->sheet, text, ctm, colorspace, color, alpha, NULL); - fz_text_extract(ctx, tdev, text, ctm, style); + fz_stext_device *tdev = (fz_stext_device*)dev; + fz_stext_style *style; + style = fz_lookup_stext_style(ctx, tdev->sheet, text, ctm, colorspace, color, alpha, NULL); + fz_stext_extract(ctx, tdev, text, ctm, style); } static void -fz_text_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_state *stroke, const fz_matrix *ctm, +fz_stext_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_state *stroke, const fz_matrix *ctm, fz_colorspace *colorspace, float *color, float alpha) { - fz_text_device *tdev = (fz_text_device*)dev; - fz_text_style *style; - style = fz_lookup_text_style(ctx, tdev->sheet, text, ctm, colorspace, color, alpha, stroke); - fz_text_extract(ctx, tdev, text, ctm, style); + fz_stext_device *tdev = (fz_stext_device*)dev; + fz_stext_style *style; + style = fz_lookup_stext_style(ctx, tdev->sheet, text, ctm, colorspace, color, alpha, stroke); + fz_stext_extract(ctx, tdev, text, ctm, style); } static void -fz_text_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm, int accumulate) +fz_stext_clip_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm, int accumulate) { - fz_text_device *tdev = (fz_text_device*)dev; - fz_text_style *style; - style = fz_lookup_text_style(ctx, tdev->sheet, text, ctm, NULL, NULL, 0, NULL); - fz_text_extract(ctx, tdev, text, ctm, style); + fz_stext_device *tdev = (fz_stext_device*)dev; + fz_stext_style *style; + style = fz_lookup_stext_style(ctx, tdev->sheet, text, ctm, NULL, NULL, 0, NULL); + fz_stext_extract(ctx, tdev, text, ctm, style); } static void -fz_text_clip_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_state *stroke, const fz_matrix *ctm) +fz_stext_clip_stroke_text(fz_context *ctx, fz_device *dev, fz_text *text, fz_stroke_state *stroke, const fz_matrix *ctm) { - fz_text_device *tdev = (fz_text_device*)dev; - fz_text_style *style; - style = fz_lookup_text_style(ctx, tdev->sheet, text, ctm, NULL, NULL, 0, stroke); - fz_text_extract(ctx, tdev, text, ctm, style); + fz_stext_device *tdev = (fz_stext_device*)dev; + fz_stext_style *style; + style = fz_lookup_stext_style(ctx, tdev->sheet, text, ctm, NULL, NULL, 0, stroke); + fz_stext_extract(ctx, tdev, text, ctm, style); } static void -fz_text_ignore_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm) +fz_stext_ignore_text(fz_context *ctx, fz_device *dev, fz_text *text, const fz_matrix *ctm) { - fz_text_device *tdev = (fz_text_device*)dev; - fz_text_style *style; - style = fz_lookup_text_style(ctx, tdev->sheet, text, ctm, NULL, NULL, 0, NULL); - fz_text_extract(ctx, tdev, text, ctm, style); + fz_stext_device *tdev = (fz_stext_device*)dev; + fz_stext_style *style; + style = fz_lookup_stext_style(ctx, tdev->sheet, text, ctm, NULL, NULL, 0, NULL); + fz_stext_extract(ctx, tdev, text, ctm, style); } static void -fz_text_fill_image_mask(fz_context *ctx, fz_device *dev, fz_image *img, const fz_matrix *ctm, +fz_stext_fill_image_mask(fz_context *ctx, fz_device *dev, fz_image *img, const fz_matrix *ctm, fz_colorspace *cspace, float *color, float alpha) { - fz_text_device *tdev = (fz_text_device*)dev; - fz_text_page *page = tdev->page; + fz_stext_device *tdev = (fz_stext_device*)dev; + fz_stext_page *page = tdev->page; fz_image_block *block; /* If the alpha is less than 50% then it's probably a watermark or @@ -909,9 +909,9 @@ fz_text_fill_image_mask(fz_context *ctx, fz_device *dev, fz_image *img, const fz } static void -fz_text_fill_image(fz_context *ctx, fz_device *dev, fz_image *img, const fz_matrix *ctm, float alpha) +fz_stext_fill_image(fz_context *ctx, fz_device *dev, fz_image *img, const fz_matrix *ctm, float alpha) { - fz_text_fill_image_mask(ctx, dev, img, ctm, NULL, NULL, alpha); + fz_stext_fill_image_mask(ctx, dev, img, ctm, NULL, NULL, alpha); } static int @@ -948,11 +948,11 @@ fz_bidi_direction(int bidiclass, int curdir) } static void -fz_bidi_reorder_run(fz_text_span *span, int a, int b, int dir) +fz_bidi_reorder_run(fz_stext_span *span, int a, int b, int dir) { if (a < b && dir == -1) { - fz_text_char c; + fz_stext_char c; int m = a + (b - a) / 2; while (a < m) { @@ -966,7 +966,7 @@ fz_bidi_reorder_run(fz_text_span *span, int a, int b, int dir) } static void -fz_bidi_reorder_span(fz_text_span *span) +fz_bidi_reorder_span(fz_stext_span *span) { int a, b, dir, curdir; @@ -986,12 +986,12 @@ fz_bidi_reorder_span(fz_text_span *span) } static void -fz_bidi_reorder_text_page(fz_context *ctx, fz_text_page *page) +fz_bidi_reorder_stext_page(fz_context *ctx, fz_stext_page *page) { fz_page_block *pageblock; - fz_text_block *block; - fz_text_line *line; - fz_text_span *span; + fz_stext_block *block; + fz_stext_line *line; + fz_stext_span *span; for (pageblock = page->blocks; pageblock < page->blocks + page->len; pageblock++) if (pageblock->type == FZ_PAGE_BLOCK_TEXT) @@ -1001,13 +1001,13 @@ fz_bidi_reorder_text_page(fz_context *ctx, fz_text_page *page) } static void -fz_text_begin_page(fz_context *ctx, fz_device *dev, const fz_rect *mediabox, const fz_matrix *ctm) +fz_stext_begin_page(fz_context *ctx, fz_device *dev, const fz_rect *mediabox, const fz_matrix *ctm) { - fz_text_device *tdev = (fz_text_device*)dev; + fz_stext_device *tdev = (fz_stext_device*)dev; if (tdev->page->len) { - tdev->page->next = fz_new_text_page(ctx); + tdev->page->next = fz_new_stext_page(ctx); tdev->page = tdev->page->next; } @@ -1016,9 +1016,9 @@ fz_text_begin_page(fz_context *ctx, fz_device *dev, const fz_rect *mediabox, con } static void -fz_text_end_page(fz_context *ctx, fz_device *dev) +fz_stext_end_page(fz_context *ctx, fz_device *dev) { - fz_text_device *tdev = (fz_text_device*)dev; + fz_stext_device *tdev = (fz_stext_device*)dev; add_span_to_soup(ctx, tdev->spans, tdev->cur_span); tdev->cur_span = NULL; @@ -1030,33 +1030,33 @@ fz_text_end_page(fz_context *ctx, fz_device *dev) /* TODO: smart sorting of blocks in reading order */ /* TODO: unicode NFC normalization */ - fz_bidi_reorder_text_page(ctx, tdev->page); + fz_bidi_reorder_stext_page(ctx, tdev->page); } static void -fz_text_drop_imp(fz_context *ctx, fz_device *dev) +fz_stext_drop_imp(fz_context *ctx, fz_device *dev) { - fz_text_device *tdev = (fz_text_device*)dev; + fz_stext_device *tdev = (fz_stext_device*)dev; free_span_soup(ctx, tdev->spans); } fz_device * -fz_new_text_device(fz_context *ctx, fz_text_sheet *sheet, fz_text_page *page) +fz_new_stext_device(fz_context *ctx, fz_stext_sheet *sheet, fz_stext_page *page) { - fz_text_device *dev = fz_new_device(ctx, sizeof *dev); + fz_stext_device *dev = fz_new_device(ctx, sizeof *dev); dev->super.hints = FZ_IGNORE_IMAGE | FZ_IGNORE_SHADE; - dev->super.drop_imp = fz_text_drop_imp; - dev->super.begin_page = fz_text_begin_page; - dev->super.end_page = fz_text_end_page; - dev->super.fill_text = fz_text_fill_text; - dev->super.stroke_text = fz_text_stroke_text; - dev->super.clip_text = fz_text_clip_text; - dev->super.clip_stroke_text = fz_text_clip_stroke_text; - dev->super.ignore_text = fz_text_ignore_text; - dev->super.fill_image = fz_text_fill_image; - dev->super.fill_image_mask = fz_text_fill_image_mask; + dev->super.drop_imp = fz_stext_drop_imp; + dev->super.begin_page = fz_stext_begin_page; + dev->super.end_page = fz_stext_end_page; + dev->super.fill_text = fz_stext_fill_text; + dev->super.stroke_text = fz_stext_stroke_text; + dev->super.clip_text = fz_stext_clip_text; + dev->super.clip_stroke_text = fz_stext_clip_stroke_text; + dev->super.ignore_text = fz_stext_ignore_text; + dev->super.fill_image = fz_stext_fill_image; + dev->super.fill_image_mask = fz_stext_fill_image_mask; dev->sheet = sheet; dev->page = page; diff --git a/source/fitz/stext-output.c b/source/fitz/stext-output.c index f090020d..bd348af1 100644 --- a/source/fitz/stext-output.c +++ b/source/fitz/stext-output.c @@ -29,7 +29,7 @@ static int font_is_italic(fz_font *font) } static void -fz_print_style_begin(fz_context *ctx, fz_output *out, fz_text_style *style) +fz_print_style_begin(fz_context *ctx, fz_output *out, fz_stext_style *style) { int script = style->script; fz_printf(ctx, out, "<span class=\"s%d\">", style->id); @@ -40,7 +40,7 @@ fz_print_style_begin(fz_context *ctx, fz_output *out, fz_text_style *style) } static void -fz_print_style_end(fz_context *ctx, fz_output *out, fz_text_style *style) +fz_print_style_end(fz_context *ctx, fz_output *out, fz_stext_style *style) { int script = style->script; while (script-- > 0) @@ -51,7 +51,7 @@ fz_print_style_end(fz_context *ctx, fz_output *out, fz_text_style *style) } static void -fz_print_style(fz_context *ctx, fz_output *out, fz_text_style *style) +fz_print_style(fz_context *ctx, fz_output *out, fz_stext_style *style) { char *s = strchr(style->font->name, '+'); s = s ? s + 1 : style->font->name; @@ -65,9 +65,9 @@ fz_print_style(fz_context *ctx, fz_output *out, fz_text_style *style) } void -fz_print_text_sheet(fz_context *ctx, fz_output *out, fz_text_sheet *sheet) +fz_print_stext_sheet(fz_context *ctx, fz_output *out, fz_stext_sheet *sheet) { - fz_text_style *style; + fz_stext_style *style; for (style = sheet->style; style; style = style->next) fz_print_style(ctx, out, style); } @@ -111,12 +111,12 @@ send_data_base64(fz_context *ctx, fz_output *out, fz_buffer *buffer) } void -fz_print_text_page_html(fz_context *ctx, fz_output *out, fz_text_page *page) +fz_print_stext_page_html(fz_context *ctx, fz_output *out, fz_stext_page *page) { int block_n, line_n, ch_n; - fz_text_style *style = NULL; - fz_text_line *line; - fz_text_span *span; + fz_stext_style *style = NULL; + fz_stext_line *line; + fz_stext_span *span; void *last_region = NULL; fz_printf(ctx, out, "<div class=\"page\">\n"); @@ -127,7 +127,7 @@ fz_print_text_page_html(fz_context *ctx, fz_output *out, fz_text_page *page) { case FZ_PAGE_BLOCK_TEXT: { - fz_text_block * block = page->blocks[block_n].u.text; + fz_stext_block * block = page->blocks[block_n].u.text; fz_printf(ctx, out, "<div class=\"block\"><p>\n"); for (line_n = 0; line_n < block->len; line_n++) { @@ -169,7 +169,7 @@ fz_print_text_page_html(fz_context *ctx, fz_output *out, fz_text_page *page) /* Now output the span to contain this entire column */ fz_printf(ctx, out, "<div class=\"cell\" style=\""); { - fz_text_span *sn; + fz_stext_span *sn; for (sn = span->next; sn; sn = sn->next) { if (sn->column != lastcol) @@ -197,7 +197,7 @@ fz_print_text_page_html(fz_context *ctx, fz_output *out, fz_text_page *page) fz_printf(ctx, out, "<sup>"); for (ch_n = 0; ch_n < span->len; ch_n++) { - fz_text_char *ch = &span->text[ch_n]; + fz_stext_char *ch = &span->text[ch_n]; if (style != ch->style) { if (style) @@ -275,7 +275,7 @@ fz_print_text_page_html(fz_context *ctx, fz_output *out, fz_text_page *page) } void -fz_print_text_page_xml(fz_context *ctx, fz_output *out, fz_text_page *page) +fz_print_stext_page_xml(fz_context *ctx, fz_output *out, fz_stext_page *page) { int block_n; @@ -289,24 +289,24 @@ fz_print_text_page_xml(fz_context *ctx, fz_output *out, fz_text_page *page) { case FZ_PAGE_BLOCK_TEXT: { - fz_text_block *block = page->blocks[block_n].u.text; - fz_text_line *line; + fz_stext_block *block = page->blocks[block_n].u.text; + fz_stext_line *line; char *s; fz_printf(ctx, out, "<block bbox=\"%g %g %g %g\">\n", block->bbox.x0, block->bbox.y0, block->bbox.x1, block->bbox.y1); for (line = block->lines; line < block->lines + block->len; line++) { - fz_text_span *span; + fz_stext_span *span; fz_printf(ctx, out, "<line bbox=\"%g %g %g %g\">\n", line->bbox.x0, line->bbox.y0, line->bbox.x1, line->bbox.y1); for (span = line->first_span; span; span = span->next) { - fz_text_style *style = NULL; + fz_stext_style *style = NULL; int char_num; for (char_num = 0; char_num < span->len; char_num++) { - fz_text_char *ch = &span->text[char_num]; + fz_stext_char *ch = &span->text[char_num]; if (ch->style != style) { if (style) @@ -322,7 +322,7 @@ fz_print_text_page_xml(fz_context *ctx, fz_output *out, fz_text_page *page) } { fz_rect rect; - fz_text_char_bbox(ctx, &rect, span, char_num); + fz_stext_char_bbox(ctx, &rect, span, char_num); fz_printf(ctx, out, "<char bbox=\"%g %g %g %g\" x=\"%g\" y=\"%g\" c=\"", rect.x0, rect.y0, rect.x1, rect.y1, ch->p.x, ch->p.y); } @@ -360,7 +360,7 @@ fz_print_text_page_xml(fz_context *ctx, fz_output *out, fz_text_page *page) } void -fz_print_text_page(fz_context *ctx, fz_output *out, fz_text_page *page) +fz_print_stext_page(fz_context *ctx, fz_output *out, fz_stext_page *page) { int block_n; @@ -370,15 +370,15 @@ fz_print_text_page(fz_context *ctx, fz_output *out, fz_text_page *page) { case FZ_PAGE_BLOCK_TEXT: { - fz_text_block *block = page->blocks[block_n].u.text; - fz_text_line *line; - fz_text_char *ch; + fz_stext_block *block = page->blocks[block_n].u.text; + fz_stext_line *line; + fz_stext_char *ch; char utf[10]; int i, n; for (line = block->lines; line < block->lines + block->len; line++) { - fz_text_span *span; + fz_stext_span *span; for (span = line->first_span; span; span = span->next) { for (ch = span->text; ch < span->text + span->len; ch++) diff --git a/source/fitz/stext-paragraph.c b/source/fitz/stext-paragraph.c index adab5623..cbf7c925 100644 --- a/source/fitz/stext-paragraph.c +++ b/source/fitz/stext-paragraph.c @@ -15,7 +15,7 @@ typedef struct line_height_s { float height; int count; - fz_text_style *style; + fz_stext_style *style; } line_height; typedef struct line_heights_s @@ -44,7 +44,7 @@ free_line_heights(line_heights *lh) } static void -insert_line_height(line_heights *lh, fz_text_style *style, float height) +insert_line_height(line_heights *lh, fz_stext_style *style, float height) { int i; @@ -88,13 +88,13 @@ cull_line_heights(line_heights *lh) printf("Before culling:\n"); for (i = 0; i < lh->len; i++) { - fz_text_style *style = lh->lh[i].style; + fz_stext_style *style = lh->lh[i].style; printf("style=%x height=%g count=%d\n", style, lh->lh[i].height, lh->lh[i].count); } #endif for (i = 0; i < lh->len; i++) { - fz_text_style *style = lh->lh[i].style; + fz_stext_style *style = lh->lh[i].style; int count = lh->lh[i].count; int max = i; @@ -127,14 +127,14 @@ cull_line_heights(line_heights *lh) printf("After culling:\n"); for (i = 0; i < lh->len; i++) { - fz_text_style *style = lh->lh[i].style; + fz_stext_style *style = lh->lh[i].style; printf("style=%x height=%g count=%d\n", style, lh->lh[i].height, lh->lh[i].count); } #endif } static float -line_height_for_style(line_heights *lh, fz_text_style *style) +line_height_for_style(line_heights *lh, fz_stext_style *style) { int i; @@ -147,10 +147,10 @@ line_height_for_style(line_heights *lh, fz_text_style *style) } static void -split_block(fz_context *ctx, fz_text_page *page, int block_num, int linenum) +split_block(fz_context *ctx, fz_stext_page *page, int block_num, int linenum) { int split_len; - fz_text_block *block, *block2; + fz_stext_block *block, *block2; if (page->len == page->cap) { @@ -162,7 +162,7 @@ split_block(fz_context *ctx, fz_text_page *page, int block_num, int linenum) memmove(page->blocks+block_num+1, page->blocks+block_num, (page->len - block_num)*sizeof(*page->blocks)); page->len++; - block2 = fz_malloc_struct(ctx, fz_text_block); + block2 = fz_malloc_struct(ctx, fz_stext_block); block = page->blocks[block_num].u.text; page->blocks[block_num+1].type = FZ_PAGE_BLOCK_TEXT; @@ -172,11 +172,11 @@ split_block(fz_context *ctx, fz_text_page *page, int block_num, int linenum) block2->cap = 0; block2->len = 0; block2->lines = NULL; - block2->lines = fz_malloc_array(ctx, split_len, sizeof(fz_text_line)); + block2->lines = fz_malloc_array(ctx, split_len, sizeof(fz_stext_line)); block2->cap = block2->len; block2->len = split_len; block->len = linenum; - memcpy(block2->lines, block->lines + linenum, split_len * sizeof(fz_text_line)); + memcpy(block2->lines, block->lines + linenum, split_len * sizeof(fz_stext_line)); block2->lines[0].distance = 0; } @@ -252,10 +252,10 @@ is_roman(int c) #endif static int -is_list_entry(fz_text_line *line, fz_text_span *span, int *char_num_ptr) +is_list_entry(fz_stext_line *line, fz_stext_span *span, int *char_num_ptr) { int char_num; - fz_text_char *chr; + fz_stext_char *chr; /* First, skip over any whitespace */ for (char_num = 0; char_num < span->len; char_num++) @@ -288,7 +288,7 @@ is_list_entry(fz_text_line *line, fz_text_span *span, int *char_num_ptr) int met_char = is_latin_char(chr->c); for (cn = char_num+1; cn < span->len; cn++) { - fz_text_char *chr2 = &span->text[cn]; + fz_stext_char *chr2 = &span->text[cn]; if (is_latin_char(chr2->c) && !met_char) { @@ -315,7 +315,7 @@ is_list_entry(fz_text_line *line, fz_text_span *span, int *char_num_ptr) int cn = char_num; for (cn = char_num+1; cn < span->len; cn++) { - fz_text_char *chr2 = &span->text[cn]; + fz_stext_char *chr2 = &span->text[cn]; if (!is_roman(chr2->c) && !is_unicode_wspace(chr2->c)) break; @@ -622,7 +622,7 @@ static void region_mask_merge(region_mask *rm1, const region_mask *rm2, int newl rm1->len = newlen; } -static region_mask *region_masks_match(const region_masks *rms, const region_mask *rm, fz_text_line *line, region_mask *prev_match) +static region_mask *region_masks_match(const region_masks *rms, const region_mask *rm, fz_stext_line *line, region_mask *prev_match) { int i; float best_score = 9999999; @@ -969,7 +969,7 @@ is_unicode_hyphenatable(int c) } static void -dehyphenate(fz_text_span *s1, fz_text_span *s2) +dehyphenate(fz_stext_span *s1, fz_stext_span *s2) { int i; @@ -992,14 +992,14 @@ dehyphenate(fz_text_span *s1, fz_text_span *s2) #ifdef DEBUG_ALIGN static void -dump_span(fz_text_span *span) +dump_span(fz_stext_span *span) { } static void -dump_line(fz_text_line *line) +dump_line(fz_stext_line *line) { - fz_text_span *span; + fz_stext_span *span; if (!line) return; @@ -1017,10 +1017,10 @@ dump_line(fz_text_line *line) #endif void -fz_analyze_text(fz_context *ctx, fz_text_sheet *sheet, fz_text_page *page) +fz_analyze_text(fz_context *ctx, fz_stext_sheet *sheet, fz_stext_page *page) { - fz_text_line *line; - fz_text_span *span; + fz_stext_line *line; + fz_stext_span *span; line_heights *lh; region_masks *rms; int block_num; @@ -1034,7 +1034,7 @@ fz_analyze_text(fz_context *ctx, fz_text_sheet *sheet, fz_text_page *page) lh = new_line_heights(ctx); for (block_num = 0; block_num < page->len; block_num++) { - fz_text_block *block; + fz_stext_block *block; if (page->blocks[block_num].type != FZ_PAGE_BLOCK_TEXT) continue; @@ -1045,7 +1045,7 @@ fz_analyze_text(fz_context *ctx, fz_text_sheet *sheet, fz_text_page *page) /* For every style in the line, add lineheight to the * record for that style. FIXME: This is a nasty n^2 * algorithm at the moment. */ - fz_text_style *style = NULL; + fz_stext_style *style = NULL; if (line->distance == 0) continue; @@ -1059,7 +1059,7 @@ fz_analyze_text(fz_context *ctx, fz_text_sheet *sheet, fz_text_page *page) for (; char_num < span->len; char_num++) { - fz_text_char *chr = &span->text[char_num]; + fz_stext_char *chr = &span->text[char_num]; /* Ignore any whitespace chars */ if (is_unicode_wspace(chr->c)) @@ -1069,13 +1069,13 @@ fz_analyze_text(fz_context *ctx, fz_text_sheet *sheet, fz_text_page *page) { /* Have we had this style before? */ int match = 0; - fz_text_span *span2; + fz_stext_span *span2; for (span2 = line->first_span; span2 != span; span2 = span2->next) { int char_num2; for (char_num2 = 0; char_num2 < span2->len; char_num2++) { - fz_text_char *chr2 = &span2->text[char_num2]; + fz_stext_char *chr2 = &span2->text[char_num2]; if (chr2->style == chr->style) { match = 1; @@ -1085,11 +1085,11 @@ fz_analyze_text(fz_context *ctx, fz_text_sheet *sheet, fz_text_page *page) } if (char_num > 0 && match == 0) { - fz_text_span *span2 = span; + fz_stext_span *span2 = span; int char_num2; for (char_num2 = 0; char_num2 < char_num; char_num2++) { - fz_text_char *chr2 = &span2->text[char_num2]; + fz_stext_char *chr2 = &span2->text[char_num2]; if (chr2->style == chr->style) { match = 1; @@ -1116,7 +1116,7 @@ list_entry: for (block_num = 0; block_num < page->len; block_num++) { int line_num; - fz_text_block *block; + fz_stext_block *block; if (page->blocks[block_num].type != FZ_PAGE_BLOCK_TEXT) continue; @@ -1128,7 +1128,7 @@ list_entry: * is correct for that style. FIXME: We check each style * more than once, currently. */ int ok = 0; /* -1 = early exit, split now. 0 = split. 1 = don't split. */ - fz_text_style *style = NULL; + fz_stext_style *style = NULL; line = &block->lines[line_num]; if (line->distance == 0) @@ -1147,7 +1147,7 @@ list_entry: /* Now we do the rest of the line */ for (; char_num < span->len; char_num++) { - fz_text_char *chr = &span->text[char_num]; + fz_stext_char *chr = &span->text[char_num]; /* Ignore any whitespace chars */ if (is_unicode_wspace(chr->c)) @@ -1193,7 +1193,7 @@ force_paragraph: * normalised baseline vectors. */ for (block_num = 0; block_num < page->len; block_num++) { - fz_text_block *block; + fz_stext_block *block; if (page->blocks[block_num].type != FZ_PAGE_BLOCK_TEXT) continue; @@ -1278,7 +1278,7 @@ force_paragraph: region_mask *prev_match = NULL; for (block_num = 0; block_num < page->len; block_num++) { - fz_text_block *block; + fz_stext_block *block; if (page->blocks[block_num].type != FZ_PAGE_BLOCK_TEXT) continue; @@ -1329,7 +1329,7 @@ force_paragraph: { fz_point *region_min = &span->min; fz_point *region_max = &span->max; - fz_text_span *sn; + fz_stext_span *sn; int col, align; float colw, left; @@ -1374,7 +1374,7 @@ force_paragraph: int line_num; int prev_line_num; - fz_text_block *block; + fz_stext_block *block; if (page->blocks[block_num].type != FZ_PAGE_BLOCK_TEXT) continue; @@ -1383,7 +1383,7 @@ force_paragraph: /* First merge lines. This may leave empty lines behind. */ for (prev_line_num = 0, line_num = 1; line_num < block->len; line_num++) { - fz_text_line *prev_line; + fz_stext_line *prev_line; line = &block->lines[line_num]; if (!line->first_span) continue; @@ -1412,9 +1412,9 @@ force_paragraph: /* Merge line into prev_line */ { - fz_text_span **prev_line_span = &prev_line->first_span; + fz_stext_span **prev_line_span = &prev_line->first_span; int try_dehyphen = -1; - fz_text_span *prev_span = NULL; + fz_stext_span *prev_span = NULL; span = line->first_span; while (span && *prev_line_span) { @@ -1433,7 +1433,7 @@ force_paragraph: else { /* We want to copy span into prev_line. */ - fz_text_span *next = (*prev_line_span)->next; + fz_stext_span *next = (*prev_line_span)->next; if (prev_line_span == &prev_line->first_span) prev_line->first_span = span; @@ -1474,7 +1474,7 @@ force_paragraph: /* Now try to spot indents */ for (line_num = 0; line_num < block->len; line_num++) { - fz_text_span *span_num, *sn; + fz_stext_span *span_num, *sn; int col, count; line = &block->lines[line_num]; diff --git a/source/fitz/stext-search.c b/source/fitz/stext-search.c index 475c0c8a..4afbe6b7 100644 --- a/source/fitz/stext-search.c +++ b/source/fitz/stext-search.c @@ -14,16 +14,16 @@ static inline int iswhite(int c) return c == ' ' || c == '\r' || c == '\n' || c == '\t' || c == 0xA0 || c == 0x2028 || c == 0x2029; } -fz_char_and_box *fz_text_char_at(fz_context *ctx, fz_char_and_box *cab, fz_text_page *page, int idx) +fz_char_and_box *fz_stext_char_at(fz_context *ctx, fz_char_and_box *cab, fz_stext_page *page, int idx) { int block_num; int ofs = 0; for (block_num = 0; block_num < page->len; block_num++) { - fz_text_block *block; - fz_text_line *line; - fz_text_span *span; + fz_stext_block *block; + fz_stext_line *line; + fz_stext_span *span; if (page->blocks[block_num].type != FZ_PAGE_BLOCK_TEXT) continue; @@ -35,7 +35,7 @@ fz_char_and_box *fz_text_char_at(fz_context *ctx, fz_char_and_box *cab, fz_text_ if (idx < ofs + span->len) { cab->c = span->text[idx - ofs].c; - fz_text_char_bbox(ctx, &cab->bbox, span, idx - ofs); + fz_stext_char_bbox(ctx, &cab->bbox, span, idx - ofs); return cab; } ofs += span->len; @@ -55,30 +55,30 @@ fz_char_and_box *fz_text_char_at(fz_context *ctx, fz_char_and_box *cab, fz_text_ return cab; } -static int charat(fz_context *ctx, fz_text_page *page, int idx) +static int charat(fz_context *ctx, fz_stext_page *page, int idx) { fz_char_and_box cab; - return fz_text_char_at(ctx, &cab, page, idx)->c; + return fz_stext_char_at(ctx, &cab, page, idx)->c; } -static fz_rect *bboxat(fz_context *ctx, fz_text_page *page, int idx, fz_rect *bbox) +static fz_rect *bboxat(fz_context *ctx, fz_stext_page *page, int idx, fz_rect *bbox) { fz_char_and_box cab; /* FIXME: Nasty extra copy */ - *bbox = fz_text_char_at(ctx, &cab, page, idx)->bbox; + *bbox = fz_stext_char_at(ctx, &cab, page, idx)->bbox; return bbox; } -static int textlen(fz_context *ctx, fz_text_page *page) +static int textlen(fz_context *ctx, fz_stext_page *page) { int len = 0; int block_num; for (block_num = 0; block_num < page->len; block_num++) { - fz_text_block *block; - fz_text_line *line; - fz_text_span *span; + fz_stext_block *block; + fz_stext_line *line; + fz_stext_span *span; if (page->blocks[block_num].type != FZ_PAGE_BLOCK_TEXT) continue; @@ -95,7 +95,7 @@ static int textlen(fz_context *ctx, fz_text_page *page) return len; } -static int match(fz_context *ctx, fz_text_page *page, const char *s, int n) +static int match(fz_context *ctx, fz_stext_page *page, const char *s, int n) { int orig = n; int c; @@ -126,7 +126,7 @@ static int match(fz_context *ctx, fz_text_page *page, const char *s, int n) } int -fz_search_text_page(fz_context *ctx, fz_text_page *text, const char *needle, fz_rect *hit_bbox, int hit_max) +fz_search_stext_page(fz_context *ctx, fz_stext_page *text, const char *needle, fz_rect *hit_bbox, int hit_max) { int pos, len, i, n, hit_count; @@ -168,12 +168,12 @@ fz_search_text_page(fz_context *ctx, fz_text_page *text, const char *needle, fz_ } int -fz_highlight_selection(fz_context *ctx, fz_text_page *page, fz_rect rect, fz_rect *hit_bbox, int hit_max) +fz_highlight_selection(fz_context *ctx, fz_stext_page *page, fz_rect rect, fz_rect *hit_bbox, int hit_max) { fz_rect linebox, charbox; - fz_text_block *block; - fz_text_line *line; - fz_text_span *span; + fz_stext_block *block; + fz_stext_line *line; + fz_stext_span *span; int i, block_num, hit_count; float x0 = rect.x0; @@ -195,7 +195,7 @@ fz_highlight_selection(fz_context *ctx, fz_text_page *page, fz_rect rect, fz_rec { for (i = 0; i < span->len; i++) { - fz_text_char_bbox(ctx, &charbox, span, i); + fz_stext_char_bbox(ctx, &charbox, span, i); if (charbox.x1 >= x0 && charbox.x0 <= x1 && charbox.y1 >= y0 && charbox.y0 <= y1) { if (charbox.y0 != linebox.y0 || fz_abs(charbox.x0 - linebox.x1) > 5) @@ -220,7 +220,7 @@ fz_highlight_selection(fz_context *ctx, fz_text_page *page, fz_rect rect, fz_rec } char * -fz_copy_selection(fz_context *ctx, fz_text_page *page, fz_rect rect) +fz_copy_selection(fz_context *ctx, fz_stext_page *page, fz_rect rect) { fz_buffer *buffer; fz_rect hitbox; @@ -236,9 +236,9 @@ fz_copy_selection(fz_context *ctx, fz_text_page *page, fz_rect rect) for (block_num = 0; block_num < page->len; block_num++) { - fz_text_block *block; - fz_text_line *line; - fz_text_span *span; + fz_stext_block *block; + fz_stext_line *line; + fz_stext_span *span; if (page->blocks[block_num].type != FZ_PAGE_BLOCK_TEXT) continue; @@ -256,7 +256,7 @@ fz_copy_selection(fz_context *ctx, fz_text_page *page, fz_rect rect) for (i = 0; i < span->len; i++) { - fz_text_char_bbox(ctx, &hitbox, span, i); + fz_stext_char_bbox(ctx, &hitbox, span, i); c = span->text[i].c; if (c < 32) c = '?'; diff --git a/source/fitz/util.c b/source/fitz/util.c index 4d1f60bf..54e5754d 100644 --- a/source/fitz/util.c +++ b/source/fitz/util.c @@ -193,16 +193,16 @@ fz_new_pixmap_from_page_number(fz_context *ctx, fz_document *doc, int number, co return pix; } -fz_text_page * -fz_new_text_page_from_display_list(fz_context *ctx, fz_display_list *list, fz_text_sheet *sheet) +fz_stext_page * +fz_new_stext_page_from_display_list(fz_context *ctx, fz_display_list *list, fz_stext_sheet *sheet) { - fz_text_page *text; + fz_stext_page *text; fz_device *dev; - text = fz_new_text_page(ctx); + text = fz_new_stext_page(ctx); fz_try(ctx) { - dev = fz_new_text_device(ctx, sheet, text); + dev = fz_new_stext_device(ctx, sheet, text); fz_run_display_list(ctx, list, dev, &fz_identity, NULL, NULL); } fz_always(ctx) @@ -211,23 +211,23 @@ fz_new_text_page_from_display_list(fz_context *ctx, fz_display_list *list, fz_te } fz_catch(ctx) { - fz_drop_text_page(ctx, text); + fz_drop_stext_page(ctx, text); fz_rethrow(ctx); } return text; } -fz_text_page * -fz_new_text_page_from_page(fz_context *ctx, fz_page *page, fz_text_sheet *sheet) +fz_stext_page * +fz_new_stext_page_from_page(fz_context *ctx, fz_page *page, fz_stext_sheet *sheet) { - fz_text_page *text; + fz_stext_page *text; fz_device *dev; - text = fz_new_text_page(ctx); + text = fz_new_stext_page(ctx); fz_try(ctx) { - dev = fz_new_text_device(ctx, sheet, text); + dev = fz_new_stext_device(ctx, sheet, text); fz_run_page(ctx, page, dev, &fz_identity, NULL); } fz_always(ctx) @@ -236,22 +236,22 @@ fz_new_text_page_from_page(fz_context *ctx, fz_page *page, fz_text_sheet *sheet) } fz_catch(ctx) { - fz_drop_text_page(ctx, text); + fz_drop_stext_page(ctx, text); fz_rethrow(ctx); } return text; } -fz_text_page * -fz_new_text_page_from_page_number(fz_context *ctx, fz_document *doc, int number, fz_text_sheet *sheet) +fz_stext_page * +fz_new_stext_page_from_page_number(fz_context *ctx, fz_document *doc, int number, fz_stext_sheet *sheet) { fz_page *page; - fz_text_page *text; + fz_stext_page *text; page = fz_load_page(ctx, doc, number); fz_try(ctx) - text = fz_new_text_page_from_page(ctx, page, sheet); + text = fz_new_stext_page_from_page(ctx, page, sheet); fz_always(ctx) fz_drop_page(ctx, page); fz_catch(ctx) @@ -262,42 +262,42 @@ fz_new_text_page_from_page_number(fz_context *ctx, fz_document *doc, int number, int fz_search_display_list(fz_context *ctx, fz_display_list *list, const char *needle, fz_rect *hit_bbox, int hit_max) { - fz_text_sheet *sheet; - fz_text_page *text; + fz_stext_sheet *sheet; + fz_stext_page *text; int count; - sheet = fz_new_text_sheet(ctx); + sheet = fz_new_stext_sheet(ctx); fz_try(ctx) { - text = fz_new_text_page_from_display_list(ctx, list, sheet); - count = fz_search_text_page(ctx, text, needle, hit_bbox, hit_max); + text = fz_new_stext_page_from_display_list(ctx, list, sheet); + count = fz_search_stext_page(ctx, text, needle, hit_bbox, hit_max); } fz_always(ctx) - fz_drop_text_sheet(ctx, sheet); + fz_drop_stext_sheet(ctx, sheet); fz_catch(ctx) fz_rethrow(ctx); - fz_drop_text_page(ctx, text); + fz_drop_stext_page(ctx, text); return count; } int fz_search_page(fz_context *ctx, fz_page *page, const char *needle, fz_rect *hit_bbox, int hit_max) { - fz_text_sheet *sheet; - fz_text_page *text; + fz_stext_sheet *sheet; + fz_stext_page *text; int count; - sheet = fz_new_text_sheet(ctx); + sheet = fz_new_stext_sheet(ctx); fz_try(ctx) { - text = fz_new_text_page_from_page(ctx, page, sheet); - count = fz_search_text_page(ctx, text, needle, hit_bbox, hit_max); + text = fz_new_stext_page_from_page(ctx, page, sheet); + count = fz_search_stext_page(ctx, text, needle, hit_bbox, hit_max); } fz_always(ctx) - fz_drop_text_sheet(ctx, sheet); + fz_drop_stext_sheet(ctx, sheet); fz_catch(ctx) fz_rethrow(ctx); - fz_drop_text_page(ctx, text); + fz_drop_stext_page(ctx, text); return count; } @@ -318,7 +318,7 @@ fz_search_page_number(fz_context *ctx, fz_document *doc, int number, const char } fz_buffer * -fz_new_buffer_from_text_page(fz_context *ctx, fz_text_page *text, const fz_rect *sel, int crlf) +fz_new_buffer_from_stext_page(fz_context *ctx, fz_stext_page *text, const fz_rect *sel, int crlf) { fz_buffer *buf; fz_rect hitbox; @@ -347,9 +347,9 @@ fz_new_buffer_from_text_page(fz_context *ctx, fz_text_page *text, const fz_rect { for (block_num = 0; block_num < text->len; block_num++) { - fz_text_line *line; - fz_text_block *block; - fz_text_span *span; + fz_stext_line *line; + fz_stext_block *block; + fz_stext_span *span; if (text->blocks[block_num].type != FZ_PAGE_BLOCK_TEXT) continue; @@ -363,7 +363,7 @@ fz_new_buffer_from_text_page(fz_context *ctx, fz_text_page *text, const fz_rect for (i = 0; i < span->len; i++) { int c; - fz_text_char_bbox(ctx, &hitbox, span, i); + fz_stext_char_bbox(ctx, &hitbox, span, i); c = span->text[i].c; if (c < 32) c = '?'; @@ -399,42 +399,42 @@ fz_new_buffer_from_text_page(fz_context *ctx, fz_text_page *text, const fz_rect fz_buffer * fz_new_buffer_from_display_list(fz_context *ctx, fz_display_list *list, const fz_rect *sel, int crlf) { - fz_text_sheet *sheet; - fz_text_page *text; + fz_stext_sheet *sheet; + fz_stext_page *text; fz_buffer *buf; - sheet = fz_new_text_sheet(ctx); + sheet = fz_new_stext_sheet(ctx); fz_try(ctx) { - text = fz_new_text_page_from_display_list(ctx, list, sheet); - buf = fz_new_buffer_from_text_page(ctx, text, sel, crlf); + text = fz_new_stext_page_from_display_list(ctx, list, sheet); + buf = fz_new_buffer_from_stext_page(ctx, text, sel, crlf); } fz_always(ctx) - fz_drop_text_sheet(ctx, sheet); + fz_drop_stext_sheet(ctx, sheet); fz_catch(ctx) fz_rethrow(ctx); - fz_drop_text_page(ctx, text); + fz_drop_stext_page(ctx, text); return buf; } fz_buffer * fz_new_buffer_from_page(fz_context *ctx, fz_page *page, const fz_rect *sel, int crlf) { - fz_text_sheet *sheet; - fz_text_page *text; + fz_stext_sheet *sheet; + fz_stext_page *text; fz_buffer *buf; - sheet = fz_new_text_sheet(ctx); + sheet = fz_new_stext_sheet(ctx); fz_try(ctx) { - text = fz_new_text_page_from_page(ctx, page, sheet); - buf = fz_new_buffer_from_text_page(ctx, text, sel, crlf); + text = fz_new_stext_page_from_page(ctx, page, sheet); + buf = fz_new_buffer_from_stext_page(ctx, text, sel, crlf); } fz_always(ctx) - fz_drop_text_sheet(ctx, sheet); + fz_drop_stext_sheet(ctx, sheet); fz_catch(ctx) fz_rethrow(ctx); - fz_drop_text_page(ctx, text); + fz_drop_stext_page(ctx, text); return buf; } diff --git a/source/tools/mudraw.c b/source/tools/mudraw.c index 705cd6eb..b486171a 100644 --- a/source/tools/mudraw.c +++ b/source/tools/mudraw.c @@ -141,7 +141,7 @@ static int bandheight = 0; static int errored = 0; static int append = 0; -static fz_text_sheet *sheet = NULL; +static fz_stext_sheet *sheet = NULL; static fz_colorspace *colorspace; static char *filename; static int files = 0; @@ -331,14 +331,14 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum) else if (output_format == OUT_TEXT || output_format == OUT_HTML || output_format == OUT_STEXT) { - fz_text_page *text = NULL; + fz_stext_page *text = NULL; fz_var(text); fz_try(ctx) { - text = fz_new_text_page(ctx); - dev = fz_new_text_device(ctx, sheet, text); + text = fz_new_stext_page(ctx); + dev = fz_new_stext_device(ctx, sheet, text); if (output_format == OUT_HTML) fz_disable_device_hints(ctx, dev, FZ_IGNORE_IMAGE); if (list) @@ -349,16 +349,16 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum) dev = NULL; if (output_format == OUT_STEXT) { - fz_print_text_page_xml(ctx, out, text); + fz_print_stext_page_xml(ctx, out, text); } else if (output_format == OUT_HTML) { fz_analyze_text(ctx, sheet, text); - fz_print_text_page_html(ctx, out, text); + fz_print_stext_page_html(ctx, out, text); } else if (output_format == OUT_TEXT) { - fz_print_text_page(ctx, out, text); + fz_print_stext_page(ctx, out, text); fz_printf(ctx, out, "\f\n"); } } @@ -366,7 +366,7 @@ static void drawpage(fz_context *ctx, fz_document *doc, int pagenum) { fz_drop_device(ctx, dev); dev = NULL; - fz_drop_text_page(ctx, text); + fz_drop_stext_page(ctx, text); } fz_catch(ctx) { @@ -1046,7 +1046,7 @@ int mudraw_main(int argc, char **argv) fz_printf(ctx, out, "<?xml version=\"1.0\"?>\n"); if (output_format == OUT_TEXT || output_format == OUT_HTML || output_format == OUT_STEXT) - sheet = fz_new_text_sheet(ctx); + sheet = fz_new_stext_sheet(ctx); if (output_format == OUT_HTML) { @@ -1140,11 +1140,11 @@ int mudraw_main(int argc, char **argv) { fz_printf(ctx, out, "</body>\n"); fz_printf(ctx, out, "<style>\n"); - fz_print_text_sheet(ctx, out, sheet); + fz_print_stext_sheet(ctx, out, sheet); fz_printf(ctx, out, "</style>\n"); } - fz_drop_text_sheet(ctx, sheet); + fz_drop_stext_sheet(ctx, sheet); fz_drop_output(ctx, out); out = NULL; |