diff options
| author | Eli Zaretskii | 2023-07-31 11:11:23 -0400 |
|---|---|---|
| committer | Eli Zaretskii | 2023-07-31 11:11:23 -0400 |
| commit | 30bcd71476127fa20da37372501637b07cd53d6c (patch) | |
| tree | bdb5c57ee12255ba0de15a57ba90f354e2c326dc /src | |
| parent | 38bbfdee62d9cccaadd76135c396df1a2e5982fa (diff) | |
| parent | 525d05c1b8ac54a4f7ad166b97f2fa913f80e73c (diff) | |
| download | emacs-30bcd71476127fa20da37372501637b07cd53d6c.tar.gz emacs-30bcd71476127fa20da37372501637b07cd53d6c.zip | |
Merge from origin/emacs-29
525d05c1b8a Merge branch 'emacs-29' of git.savannah.gnu.org:/srv/git/...
29ef2157116 ; * lisp/textmodes/paragraphs.el: Remove leftover comment.
80c9f491fc8 Update to Org 9.6.7-5-gd1d0c3
735f3700f65 ; * src/character.c (Fstring_width): Fix last change.
bf83fdba9e3 ; * src/character.c (Fstring_width, Fchar_width): Doc fixes.
1198cdb5567 Merge branch 'emacs-29' of git.sv.gnu.org:/srv/git/emacs ...
2b8796eea19 Fix rx wrong-code bug: ranges starting with ^
ba60070b81c Backport: Fix some tree-sitter :match regexps
092a2ecb083 ; * admin/make-tarball.txt: Update based on latest experi...
7b9e83d3cf9 Fix bug#64923
0002d4f3166 Avoid spurious whitespace in the modeline of emacsclient ...
96d52f89444 Fix function help for advised aliases (bug#64797)
71419a60c37 Avoid crashes due to invalid 'mode-line-format'
b2cb6e82160 ; Better documentation of HOME on MS-Windows
54e98b5f9bd ; Clarify documentation of 'server-after-make-frame-hook'
d13029cdcde Avoid crashes under 'which-key-mode'
cb1f7db2490 ; Minor documentation fixes
4a687bcc20d Bump Emacs version
Diffstat (limited to 'src')
| -rw-r--r-- | src/character.c | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/src/character.c b/src/character.c index 9389e1c0098..f4164360f21 100644 --- a/src/character.c +++ b/src/character.c | |||
| @@ -260,8 +260,12 @@ char_width (int c, struct Lisp_Char_Table *dp) | |||
| 260 | 260 | ||
| 261 | 261 | ||
| 262 | DEFUN ("char-width", Fchar_width, Schar_width, 1, 1, 0, | 262 | DEFUN ("char-width", Fchar_width, Schar_width, 1, 1, 0, |
| 263 | doc: /* Return width of CHAR when displayed in the current buffer. | 263 | doc: /* Return width of CHAR in columns when displayed in the current buffer. |
| 264 | The width is measured by how many columns it occupies on the screen. | 264 | The width of CHAR is measured by how many columns it will occupy on the screen. |
| 265 | This is based on data in `char-width-table', and ignores the actual | ||
| 266 | metrics of the character's glyph as determined by its font. | ||
| 267 | If the display table in effect replaces CHAR on display with | ||
| 268 | something else, the function returns the width of the replacement. | ||
| 265 | Tab is taken to occupy `tab-width' columns. | 269 | Tab is taken to occupy `tab-width' columns. |
| 266 | usage: (char-width CHAR) */) | 270 | usage: (char-width CHAR) */) |
| 267 | (Lisp_Object ch) | 271 | (Lisp_Object ch) |
| @@ -457,20 +461,26 @@ lisp_string_width (Lisp_Object string, ptrdiff_t from, ptrdiff_t to, | |||
| 457 | } | 461 | } |
| 458 | 462 | ||
| 459 | DEFUN ("string-width", Fstring_width, Sstring_width, 1, 3, 0, | 463 | DEFUN ("string-width", Fstring_width, Sstring_width, 1, 3, 0, |
| 460 | doc: /* Return width of STRING when displayed in the current buffer. | 464 | doc: /* Return width of STRING in columns when displayed in the current buffer. |
| 461 | Width is measured by how many columns it occupies on the screen. | 465 | Width of STRING is measured by how many columns it will occupy on the screen. |
| 466 | |||
| 462 | Optional arguments FROM and TO specify the substring of STRING to | 467 | Optional arguments FROM and TO specify the substring of STRING to |
| 463 | consider, and are interpreted as in `substring'. | 468 | consider, and are interpreted as in `substring'. |
| 464 | 469 | ||
| 465 | When calculating width of a multibyte character in STRING, | 470 | Width of each character in STRING is generally taken according to |
| 466 | only the base leading-code is considered; the validity of | 471 | `char-width', but character compositions and the display table in |
| 467 | the following bytes is not checked. Tabs in STRING are always | 472 | effect are taken into consideration. |
| 468 | taken to occupy `tab-width' columns. The effect of faces and fonts | 473 | Tabs in STRING are always assumed to occupy `tab-width' columns, |
| 469 | used for non-Latin and other unusual characters (such as emoji) is | 474 | although they might take fewer columns depending on the column where |
| 470 | ignored as well, as are display properties and invisible text. | 475 | they begin on display. |
| 471 | For these reasons, the results are not generally reliable; | 476 | The effect of faces and fonts, including fonts used for non-Latin and |
| 472 | for accurate dimensions of text as it will be displayed, | 477 | other unusual characters, such as emoji, is ignored, as are display |
| 473 | use `string-pixel-width' or `window-text-pixel-size' instead. | 478 | properties and invisible text. |
| 479 | |||
| 480 | For these reasons, the results are just an approximation, especially | ||
| 481 | on GUI frames; for accurate dimensions of text as it will be | ||
| 482 | displayed, use `string-pixel-width' or `window-text-pixel-size' | ||
| 483 | instead. | ||
| 474 | usage: (string-width STRING &optional FROM TO) */) | 484 | usage: (string-width STRING &optional FROM TO) */) |
| 475 | (Lisp_Object str, Lisp_Object from, Lisp_Object to) | 485 | (Lisp_Object str, Lisp_Object from, Lisp_Object to) |
| 476 | { | 486 | { |