Annotation: Support for get/set rich media attributes on text
Adobe supply this kind of widget in their UI to style annotation text:
However we are unable to read/write to these rich media objects.
@ccxvii I think the "text alignment" value that is often required is the text alignment set from this kind of rich media.
If I try getQuadding() with the current API on annotation text which has its text alignment changed this way it always returns 0.
We support rendering rich media styled text in mupdf core, BUT ONLY IF it is built to include the HTML engine.
-
We do not build the HTML engine for WASM, as this adds a lot of bloat to the binary.
-
The rich style property (RS) is essentially a string of CSS property syntax, which is applied to the rich content (RC) which is a subset of HTML syntax. In theory any changes to the RS and RC should also be reflected into the basic non-rich style properties that we already support. This is not an easy task, because to do so we'd need to parse, generate, and EDIT both CSS and HTML content using the proposed functions.
Parsing we can currently do with the HTML engine, but only enough to get us rendered content. Editing the HTML and CSS is far out of scope for our HTML layout engine.
I suggest we close this as WONTFIX.
Is there currently a way of adding text alignment properties to the insertText() method? It doesn't look like from the docs. A nice implementation with using the already present type Point = [x: number, y: number] would be to:
- Align left naturally uses
xas the starting point - Align center uses
xas the middle point that is based on the full width of the text. (Ifxis 100 and the text width is 25, then 12.5 of the text goes before thexand the remaining goes after) - Align right uses
xas the right most place for the text. (Ifxis 100 and the text width is 25, then no text is present afterx === 100and the right most part of the last char of the text is atx === 100
Something like:
mupdfJSPage.insertText("Hello world!",
[100,100],
alignRight,
"Times-Roman",
24);
Not really interested in this one but
- Justify would need a (
xandmax width) OR (x1andx2) approach I think? The former might be better to avoid confusion and still rely on the currently implemented point parameter
Is there currently a way of adding text alignment properties to the insertText() method? It doesn't look like from the docs. A nice implementation with using the already present type Point = [x: number, y: number] would be to:
* **Align left** naturally uses `x` as the starting point * **Align center** uses `x` as the middle point that is based on the full width of the text. (If `x` is 100 and the text width is 25, then 12.5 of the text goes before the `x` and the remaining goes after) * **Align right** uses `x` as the right most place for the text. (If `x` is 100 and the text width is 25, then no text is present after `x === 100` and the right most part of the last char of the text is at `x === 100`Something like:
mupdfJSPage.insertText("Hello world!", [100,100], alignRight, "Times-Roman", 24);Not really interested in this one but
* **Justify** would need a (`x` and `max width`) OR (`x1` and `x2`) approach I think? The former might be better to avoid confusion and still rely on the currently implemented point parameter
I need this as well. Would there maybe be a way to calculate the width of a single glyph of a specified font family and size? If so, then this would be implementable by summing together the glyph widths + the letter spacing * (glyph count - 1), which would yield the entire width and then just subtracting this entire width from the x coordinate.