summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2016-01-29 14:10:53 +0000
committerRobin Watts <robin.watts@artifex.com>2016-02-04 13:21:11 +0000
commitd96bd69b94c12906473a4721c2c2dc5941923253 (patch)
tree6101971a4f96dbb5a6c4d189e1dd8ae5cf62cbcf /include
parent5d840271f62c5a51bb83d561181de860086bb6be (diff)
downloadmupdf-d96bd69b94c12906473a4721c2c2dc5941923253.tar.xz
Make HTML layout use harfbuzz for shaping.
fz_fonts gain a 'shaper' field that will be filled in as required. Use a void * rather than an hb_font_t to avoid polluting top level include space. Harfbuff handles mirroring for us, so lose the 'mirror' fields. This simplifies our wrappers around the 'standard' bidi code in that we don't need to split fragments upon mirroring. We do need to split our fragments at script changes though as harfbuzz only operates on a single font at a time. Update the html flow structure so that each flow node contains details of the the direction specified for it in the markup, the language specified for it in the markup and the script detected by the bidi code. Get the bidi code to pass out the script for each fragment as part of the callback and populate that field in the node. Ensure that we pass in the markup direction to the bidi splitting code as the 'base' direction. When feeding the bidi code, rather than feeding it paragraphs at a time, break those paragraphs if different parts of them have different marked up directions.
Diffstat (limited to 'include')
-rw-r--r--include/mupdf/fitz/bidi.h7
-rw-r--r--include/mupdf/fitz/font.h3
-rw-r--r--include/mupdf/html.h18
3 files changed, 23 insertions, 5 deletions
diff --git a/include/mupdf/fitz/bidi.h b/include/mupdf/fitz/bidi.h
index dfa439f3..8428ffc1 100644
--- a/include/mupdf/fitz/bidi.h
+++ b/include/mupdf/fitz/bidi.h
@@ -10,8 +10,6 @@
* Processes Unicode text by arranging the characters into an order suitable
* for display. E.g. Hebrew text will be arranged from right-to-left and
* any English within the text will remain in the left-to-right order.
- * Characters such as parenthesis will be substituted for their mirrored
- * equivalents if they are part of text which must be reversed.
*
* This is an implementation of the Unicode Bidirectional Algorithm which
* can be found here: http://www.unicode.org/reports/tr9/ and is based
@@ -55,14 +53,15 @@ enum
* as right-to-left
* @param char_r2l true if characters within block should be laid out
* as right-to-left
- * @param mirror The mirror code of the fragment if it exists
+ * @param script the script in use for this fragment (other than common
+ * or inherited)
* @param arg data from caller of Bidi_fragmentText
*/
typedef void (fz_bidi_fragment_callback)(const uint32_t *fragment,
size_t fragmentLen,
int block_r2l,
int char_r2l,
- uint32_t mirror,
+ int script,
void *arg);
/**
diff --git a/include/mupdf/fitz/font.h b/include/mupdf/fitz/font.h
index 47866f9e..0de3e00e 100644
--- a/include/mupdf/fitz/font.h
+++ b/include/mupdf/fitz/font.h
@@ -68,6 +68,9 @@ struct fz_font_s
/* cached encoding lookup */
uint16_t *encoding_cache[256];
+
+ /* Shaping information */
+ void *shaper;
};
/* common CJK font collections */
diff --git a/include/mupdf/html.h b/include/mupdf/html.h
index 4969e15c..c734ea0d 100644
--- a/include/mupdf/html.h
+++ b/include/mupdf/html.h
@@ -221,11 +221,27 @@ enum
*/
struct fz_html_flow_s
{
+ /* What type of node */
unsigned int type : 2;
+
+ /* Whether this should expand during justification */
unsigned int expand : 1;
+
+ /* Whether the chars should be laid out r2l or l2r */
unsigned int char_r2l : 1;
+
+ /* Whether this block should stack with its neighbours r2l or l2r */
unsigned int block_r2l : 1;
- unsigned int mirror : 1;
+
+ /* Whether the markup specifies a given direction. */
+ unsigned int markup_r2l : 2;
+
+ /* Whether the markup specifies a given language. */
+ unsigned int markup_lang : 8;
+
+ /* The script detected by the bidi code. */
+ unsigned int script : 8;
+
float x, y, w, h, em;
fz_css_style *style;
union {