diff options
| author | Eli Zaretskii | 2014-12-18 18:07:26 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2014-12-18 18:07:26 +0200 |
| commit | b1978229162b0d4c3b14d8ad8bff383eb3511969 (patch) | |
| tree | d441fe077f75d8b962a24536edcc09f7af65a26d /src | |
| parent | 687ae680bd12b0353e313808253e7a07c0828ebe (diff) | |
| download | emacs-b1978229162b0d4c3b14d8ad8bff383eb3511969.tar.gz emacs-b1978229162b0d4c3b14d8ad8bff383eb3511969.zip | |
Allow querying font by name for its height and other info. (Bug#19395)
src/font.c (Ffont_info): Add more font information to the vector
returned by the function, inspired by query-font. Doc fix.
doc/lispref/display.texi (Low-Level Font): Document font-info and query-font.
lisp/international/mule-diag.el (describe-font-internal): Display
additional info returned by font-info.
lisp/linum.el (linum--face-width): Rename from linum--face-height,
and use the new functionality of font-info.
(linum-update-window): Use linum--face-width and frame-char-width,
instead of approximating with height.
etc/NEWS: Mention the enhancement in font-info.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/font.c | 47 |
2 files changed, 49 insertions, 4 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 16e99aec99a..2b125d52723 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,9 @@ | |||
| 1 | 2014-12-18 Eli Zaretskii <eliz@gnu.org> | ||
| 2 | |||
| 3 | * font.c (Ffont_info): Add more font information to the vector | ||
| 4 | returned by the function, inspired by query-font. Doc fix. | ||
| 5 | (Bug#19395) | ||
| 6 | |||
| 1 | 2014-12-18 Stefan Monnier <monnier@iro.umontreal.ca> | 7 | 2014-12-18 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 8 | ||
| 3 | * keyboard.c (input_was_pending): New var. | 9 | * keyboard.c (input_was_pending): New var. |
diff --git a/src/font.c b/src/font.c index 70e63164a34..d10d2280a5b 100644 --- a/src/font.c +++ b/src/font.c | |||
| @@ -4921,8 +4921,11 @@ If FRAME is omitted or nil, use the selected frame. */) | |||
| 4921 | DEFUN ("font-info", Ffont_info, Sfont_info, 1, 2, 0, | 4921 | DEFUN ("font-info", Ffont_info, Sfont_info, 1, 2, 0, |
| 4922 | doc: /* Return information about a font named NAME on frame FRAME. | 4922 | doc: /* Return information about a font named NAME on frame FRAME. |
| 4923 | If FRAME is omitted or nil, use the selected frame. | 4923 | If FRAME is omitted or nil, use the selected frame. |
| 4924 | The returned value is a vector of OPENED-NAME, FULL-NAME, SIZE, | 4924 | |
| 4925 | HEIGHT, BASELINE-OFFSET, RELATIVE-COMPOSE, and DEFAULT-ASCENT, | 4925 | The returned value is a vector: |
| 4926 | [ OPENED-NAME FULL-NAME SIZE HEIGHT BASELINE-OFFSET RELATIVE-COMPOSE | ||
| 4927 | DEFAULT-ASCENT MAX-WIDTH ASCENT DESCENT SPACE-WIDTH AVERAGE-WIDTH | ||
| 4928 | CAPABILITY ] | ||
| 4926 | where | 4929 | where |
| 4927 | OPENED-NAME is the name used for opening the font, | 4930 | OPENED-NAME is the name used for opening the font, |
| 4928 | FULL-NAME is the full name of the font, | 4931 | FULL-NAME is the full name of the font, |
| @@ -4930,7 +4933,33 @@ where | |||
| 4930 | HEIGHT is the pixel-height of the font (i.e., ascent + descent), | 4933 | HEIGHT is the pixel-height of the font (i.e., ascent + descent), |
| 4931 | BASELINE-OFFSET is the upward offset pixels from ASCII baseline, | 4934 | BASELINE-OFFSET is the upward offset pixels from ASCII baseline, |
| 4932 | RELATIVE-COMPOSE and DEFAULT-ASCENT are the numbers controlling | 4935 | RELATIVE-COMPOSE and DEFAULT-ASCENT are the numbers controlling |
| 4933 | how to compose characters. | 4936 | how to compose characters, |
| 4937 | MAX-WIDTH is the maximum advance width of the font, | ||
| 4938 | ASCENT, DESCENT, SPACE-WIDTH, AVERAGE-WIDTH are metrics of the font | ||
| 4939 | in pixels, | ||
| 4940 | FILENAME is the font file name, a string (or nil if the font backend | ||
| 4941 | doesn't provide a file name). | ||
| 4942 | CAPABILITY is a list whose first element is a symbol representing the | ||
| 4943 | font format, one of x, opentype, truetype, type1, pcf, or bdf. | ||
| 4944 | The remaining elements describe the details of the font capabilities, | ||
| 4945 | as follows: | ||
| 4946 | |||
| 4947 | If the font is OpenType font, the form of the list is | ||
| 4948 | \(opentype GSUB GPOS) | ||
| 4949 | where GSUB shows which "GSUB" features the font supports, and GPOS | ||
| 4950 | shows which "GPOS" features the font supports. Both GSUB and GPOS are | ||
| 4951 | lists of the form: | ||
| 4952 | \((SCRIPT (LANGSYS FEATURE ...) ...) ...) | ||
| 4953 | |||
| 4954 | where | ||
| 4955 | SCRIPT is a symbol representing OpenType script tag. | ||
| 4956 | LANGSYS is a symbol representing OpenType langsys tag, or nil | ||
| 4957 | representing the default langsys. | ||
| 4958 | FEATURE is a symbol representing OpenType feature tag. | ||
| 4959 | |||
| 4960 | If the font is not an OpenType font, there are no elements | ||
| 4961 | in CAPABILITY except the font format symbol. | ||
| 4962 | |||
| 4934 | If the named font is not yet loaded, return nil. */) | 4963 | If the named font is not yet loaded, return nil. */) |
| 4935 | (Lisp_Object name, Lisp_Object frame) | 4964 | (Lisp_Object name, Lisp_Object frame) |
| 4936 | { | 4965 | { |
| @@ -4966,7 +4995,7 @@ If the named font is not yet loaded, return nil. */) | |||
| 4966 | return Qnil; | 4995 | return Qnil; |
| 4967 | font = XFONT_OBJECT (font_object); | 4996 | font = XFONT_OBJECT (font_object); |
| 4968 | 4997 | ||
| 4969 | info = make_uninit_vector (7); | 4998 | info = make_uninit_vector (14); |
| 4970 | ASET (info, 0, AREF (font_object, FONT_NAME_INDEX)); | 4999 | ASET (info, 0, AREF (font_object, FONT_NAME_INDEX)); |
| 4971 | ASET (info, 1, AREF (font_object, FONT_FULLNAME_INDEX)); | 5000 | ASET (info, 1, AREF (font_object, FONT_FULLNAME_INDEX)); |
| 4972 | ASET (info, 2, make_number (font->pixel_size)); | 5001 | ASET (info, 2, make_number (font->pixel_size)); |
| @@ -4974,6 +5003,16 @@ If the named font is not yet loaded, return nil. */) | |||
| 4974 | ASET (info, 4, make_number (font->baseline_offset)); | 5003 | ASET (info, 4, make_number (font->baseline_offset)); |
| 4975 | ASET (info, 5, make_number (font->relative_compose)); | 5004 | ASET (info, 5, make_number (font->relative_compose)); |
| 4976 | ASET (info, 6, make_number (font->default_ascent)); | 5005 | ASET (info, 6, make_number (font->default_ascent)); |
| 5006 | ASET (info, 7, make_number (font->max_width)); | ||
| 5007 | ASET (info, 8, make_number (font->ascent)); | ||
| 5008 | ASET (info, 9, make_number (font->descent)); | ||
| 5009 | ASET (info, 10, make_number (font->space_width)); | ||
| 5010 | ASET (info, 11, make_number (font->average_width)); | ||
| 5011 | ASET (info, 12, AREF (font_object, FONT_FILE_INDEX)); | ||
| 5012 | if (font->driver->otf_capability) | ||
| 5013 | ASET (info, 13, Fcons (Qopentype, font->driver->otf_capability (font))); | ||
| 5014 | else | ||
| 5015 | ASET (info, 13, Qnil); | ||
| 4977 | 5016 | ||
| 4978 | #if 0 | 5017 | #if 0 |
| 4979 | /* As font_object is still in FONT_OBJLIST of the entity, we can't | 5018 | /* As font_object is still in FONT_OBJLIST of the entity, we can't |