My notes on Brec Mode for Emacs + upstream `math-preview` patches : privately cf. @ ~/base.brec : where tasked 1. true vertical alignment of in-line images - honouring the image’s `vertical-align` styling property, which Emacs omits to do / otherwise in-line images are not base-aligned with each other, let alone with the surrounding text + test - big fonts (again), and different font formats !! NotoSans-12, scale 1.1, the epsilon equation is too low / yet most other scales are fine - and removing my `math-preview--half-pixel-raise` correction puts it too high! ?+ might `math-preview--half-pixel-raise` need scaling too? - or is this just an artifact of `math-preview--ex-raise` depending on the height of the calibration image? : see `^^! .image-size. yields somewhat different ex sizes$`i !!+ ex:font-height ratio varies across fonts / E.g. NotoSans, where descending images (like `p`) hang too low. Here my SVG test confirms a different ratio - maybe Emacs consults font descriptors for the ration - confirmed: applying the ratio calculated from the SVG test corrects it / for NotoSans-12, 2.93359154929577 instead of 2.0 ?+ will the test work at runtime on the image descriptor (yet unrendered), to yield the correct ratio? : privately see `image-size` @ ~/code/emacs/src/image.c : privately see @ ~/code/emacs/src/frame.h : `FRAME_LINE_HEIGHT` equates to `F->line_height` of frame F, ‘the height of the default font of F’ \ : re `line_height` see `realize_default_face` @ \ ~/code/emacs/src/xfaces.c \\ lost the trace, still unsure how `F->line_height` is calculated ! `image-size` yields somewhat different ex sizes for different sized images, at least in Image Mode \ !! `image-size` uses different ex sizes for the following \ two SVG images \ • 0.46 (6 pixels) for `width='1.0ex' height='1.0ex'`, \ or 46.0 (598) for `width='1.0ex' height='1.0ex'`, \ both yielding an ex height of 0.46 \ : see ~/tmp/ex-size.svg \ !! yet for `width='10ex' height='10ex'`, it yields 0.50; \ and still, for most other values large or small, 0.46! \ • 9.46 (123 pixels) for `width="42.156ex" height="18.935ex"`, \ yielding an ex height of 0.50 \ : see ~/tmp/math-block.svg \ + consider that the 0.46 fraction part shared by the two image \ sizes is equal through all digits of precision! > Eval: (/ (cdr (image-size (image-get-display-property))) HEIGHT) : privately see `Get the image dimensions` @ ~/code/emacs/src/image.c : see `image-size` @ https://www.gnu.org/software/emacs/manual/html_node/elisp/Showing-Images.html : by default, returns the size in ‘canonical character units’ : re `canonical character units` see `frame-char-height` @ https://www.gnu.org/software/emacs/manual/html_node/elisp/Frame-Font.html : ‘The terms *line height* and *canonical character height* are sometimes used instead of “default character height”. ’ : privately see `Handle \`\(raise FACTOR\)'` @ `handle_display_spec` @ ~/code/emacs/src/xdisp.c / here I think `face_id` will be `DEFAULT_FACE_ID`, an `enum` value ?+ of `frame-char-height`, `default-font-height` and `window-font-height` which is most compatible with `handle_display_spec` / all seem to return the same values + compare the code + try setting it as a global constant calculated from a calibration image + consider calling `image-flush` after `image-size` in order to clear the cache / as per the docstring of `image-size` ?+ need this, and my half-pixel constant, be calculated per buffer? if( it works ) + answer that Stack Exchange question asking how to get the ex size of a font when( done ) + restore `init/fonts` or `Emacs.font` / whichever of the two I have temporarily omitted in order to simplify the font changes : re `init/fonts` see ~/.config/emacs/initialization.el : re `Emacs.font` see ~/.Xresources \ + correct my notes claiming a ½ ratio \ : see ~/.config/emacs/initialization.el \ : privately see ~/tmp/z/math-preview.el + test that the half-pixel correction is still needed + confirm that for detached descenders, too - inline equations of some complexity + ask for a merger 2. a user warning in the absence of SVG support 3. postprocessing a) passing `inline` to postprocessers, wherever it makes sense b) image (descriptor) postprocessing / e.g. to set margins/relief not only on block images, but also in-line images 4. context-aware image colouration - honouring the image’s stipulation of `currentColor` paint, which Emacs omits to do 5. context-aware image scaling ∵ Emacs sizes the ex unit (by which the math images stipulate their size) at ½ the nominal height of the default font, as opposed to the context font / this I learned by saving a the source of a math image to an SVG file, opening it with Emacs (Image Mode), and calling `image-size` on it:   (image-size (image-get-display-property) :pixels) / thus 1 ex = ½ em, for already it is documented: ‘One em is equivalent to the height of the font’ : see https://www.gnu.org/software/emacs/manual/html_node/elisp/Image-Descriptors.html \ + mark: the images enlarge the line-spacing of their lines \ / viz. the space beneath their lines \ - yet oddly the enlargement is unaffected by each the following \ • `math-preview-vertical-position` and the resulting raise` display spec, \ which somehow `have the effect of raising the image *within itself* \ / viz. within the outline that appears when the image is cursored, \ or within its own viewbox, which outline/box itself is not raised \ : re `raise` see \ https://www.gnu.org/software/emacs/manual/html_node/elisp/Other-Display-Specs.html \ • image scale \ • `line-spacing` itself \ - no matter how large the spacing, no matter that the outline of the image that \ appears when it is cursored is miniscule in comparison, still the image \ expands the line spacing even further \ ?+ might it be the cursor’s image-outining facility \ - the sqare outline is roughly 1 pixel thick, amounting to an extra 2 pixels of width and \ height, which Emacs might reserve in the layout for its eventual appearance \ / might, that is, if Emacs’s outlines (unlike CSS’s) occupy layout space \ \ - note that the in-line images (only) have a `display` text property of `(space :width 0)` \ \ ?+ what happens if `:height 0` is added to that? \ \\ I cannot see that Math Preview adds that property; maybe Emacs does, automatically \\ apparently fixed by the vertical-alignment patch when( done ) + restore original `math-preview.el` : privately see ~/.config/emacs/elpa/math-preview-20230425.1820/math-preview_OFF.el + remove both `math-preview.el` and `math-preview.elc` : privately see /etc/emacs/math-preview.el : privately see /etc/emacs/math-preview.elc + sync Brec Mode with the imager re bullet punctuation based on Unicode general categories : privately cf. @ ~/base.brec : where tasked \ / see for code examples JMT, which has lots of `(forward-char)` `(backward-char)` \ to refresh my memory \ | both \ - when it comes to terminators, I want the specificity of the category table \ in order to exclude non-atomic punctuation using regexp `\c*` \ + category table first \ + syntax table second, by reference to the category table \ | map all characters using an Emacs category table \ : see https://www.gnu.org/software/emacs/manual/html_node/elisp/Categories.html : \ which shows a pertinent mapping example \ - then use `\c` in the regexp to match by category | remap the syntax table, such that all Unicode punctuation also has Emacs punctuation syntax? \ - then I could use the `skip-syntax-*` functions to easily scan the buffer - use a regexp with syntax character class `[:punct:]` ?+ can I use `map-char-table` to scan the syntax table and make the changes? : see https://emacs.stackexchange.com/questions/80673/map-a-syntax-table-to-unicode-s-general-categories + post my own answer, (also to answer my critic) ' for me, the key to getting started is `map-char-table` ' once [I was] clued in to the presence of this function, it was obvious how to proceed ' it’s basically the whole solution \ ' so, to remap according to Unicode general categories: no-break spaces + Make a no-break space visible only when the cursor enters its line or indent blind. / The mechanism desired here might be an overlay property. : see https://www.gnu.org/software/emacs/manual/html_node/elisp/Overlay-Properties.html : see https://www.gnu.org/software/emacs/manual/html_node/elisp/Displaying-Faces.html + First verify from the Web images that I can live with invisible no-break spaces. / I have not tried. + Make this behaviour customizeable. fontification in a bullet - Alone a face test suffices to guard the application of `brec-bullet-nobreak-space` only because already the bullet fontifier detects and refuses to face misplaced no-break spaces as bullet constituents. : see `NBB` @ `NOTES` @ non-fractal brec-mode.el - Otherwise the guard would *also* have to test for an alphanumeric predecessor. : privately e.g. ~/work/Breccia/Emacs/._/brec-mode-boneyard.el   ;; In a free-form bullet.   ((and face (memq face '(brec-alarm-bullet brec-plain-bullet brec-task-bullet)))   (if (let ((b (char-before p)) b-type)   (when b   (setq b-type (get-char-code-property b 'general-category))   (or (string= "Ll" b) (string= "Lu" b) (string= "Nd" b)))); Alphanumeric.   (setq found t brec-f 'brec-forbidden-whitespace); No-break space after an alphanumeric.   (setq found t brec-f 'brec-bullet-nobreak-space)))))))))) image-file references, replacement by source-file references - Prompt the user first. - Suggest the alternative of qualifying the image-file reference as `non-fractal`. : cf. ~/work/Breccia/Web/imager/BreccianFileTranslator.java : `warn_imageFileReference` - Offer a substitution, if one is known. : see `^*identification, fractum identifiers based on proven fractum locants$` @ ~/work/Breccia/Web/imager/notes.brec : for proven locants to use as substitutes ∵ Image-file references are to be discouraged in favour of source-file references. : e.g. ~/work/Breccia/Web/imager/BreccianFileTranslator.java : `warn_imageFileReference`