diff options
| author | Po Lu | 2022-06-20 02:16:34 +0000 |
|---|---|---|
| committer | Po Lu | 2022-06-20 02:16:34 +0000 |
| commit | 382f7920abcf7df46b5b44462c6c71de54454b0e (patch) | |
| tree | 62bd89a944b4bbed4da9f0c8760653450d23d1c8 /src | |
| parent | 9a6b6b1887c62b2f5aee75e213bd1f62bc6577f6 (diff) | |
| download | emacs-382f7920abcf7df46b5b44462c6c71de54454b0e.tar.gz emacs-382f7920abcf7df46b5b44462c6c71de54454b0e.zip | |
Respect `:antialias' on Haiku
* src/haiku_font_support.cc (BFont_find): Pass through
FSPEC_ANTIALIAS.
(be_set_font_antialiasing): New function.
* src/haiku_support.h (enum haiku_font_specification): New enum
FSPEC_ANTIALIAS.
(struct haiku_font_pattern): New field `use_antialiasing'.
* src/haikufont.c (haikufont_pattern_to_entity)
(haikufont_spec_or_entity_to_pattern, haikufont_open): Respect
antialiasing.
(syms_of_haikufont): New defsym `:indices'.
Diffstat (limited to 'src')
| -rw-r--r-- | src/haiku_font_support.cc | 23 | ||||
| -rw-r--r-- | src/haiku_support.h | 6 | ||||
| -rw-r--r-- | src/haikufont.c | 110 |
3 files changed, 97 insertions, 42 deletions
diff --git a/src/haiku_font_support.cc b/src/haiku_font_support.cc index ca6aaf71204..d824cc59ae2 100644 --- a/src/haiku_font_support.cc +++ b/src/haiku_font_support.cc | |||
| @@ -598,6 +598,12 @@ BFont_find (struct haiku_font_pattern *pt) | |||
| 598 | p->last = NULL; | 598 | p->last = NULL; |
| 599 | p->next_family = r; | 599 | p->next_family = r; |
| 600 | r = p; | 600 | r = p; |
| 601 | |||
| 602 | if (pt->specified & FSPEC_ANTIALIAS) | ||
| 603 | { | ||
| 604 | p->specified |= FSPEC_ANTIALIAS; | ||
| 605 | p->use_antialiasing = pt->use_antialiasing; | ||
| 606 | } | ||
| 601 | } | 607 | } |
| 602 | else if (sty_count) | 608 | else if (sty_count) |
| 603 | { | 609 | { |
| @@ -623,6 +629,12 @@ BFont_find (struct haiku_font_pattern *pt) | |||
| 623 | p->family_index = fi; | 629 | p->family_index = fi; |
| 624 | p->style_index = si; | 630 | p->style_index = si; |
| 625 | 631 | ||
| 632 | if (pt->specified & FSPEC_ANTIALIAS) | ||
| 633 | { | ||
| 634 | p->specified |= FSPEC_ANTIALIAS; | ||
| 635 | p->use_antialiasing = pt->use_antialiasing; | ||
| 636 | } | ||
| 637 | |||
| 626 | if (p->specified & FSPEC_SLANT | 638 | if (p->specified & FSPEC_SLANT |
| 627 | && (p->slant == SLANT_OBLIQUE | 639 | && (p->slant == SLANT_OBLIQUE |
| 628 | || p->slant == SLANT_ITALIC)) | 640 | || p->slant == SLANT_ITALIC)) |
| @@ -916,3 +928,14 @@ be_find_font_indices (struct haiku_font_pattern *pattern, | |||
| 916 | 928 | ||
| 917 | return 1; | 929 | return 1; |
| 918 | } | 930 | } |
| 931 | |||
| 932 | void | ||
| 933 | be_set_font_antialiasing (void *font, bool antialias_p) | ||
| 934 | { | ||
| 935 | BFont *font_object; | ||
| 936 | |||
| 937 | font_object = (BFont *) font; | ||
| 938 | font_object->SetFlags (antialias_p | ||
| 939 | ? B_FORCE_ANTIALIASING | ||
| 940 | : B_DISABLE_ANTIALIASING); | ||
| 941 | } | ||
diff --git a/src/haiku_support.h b/src/haiku_support.h index 7f8d471b650..97c2b6904af 100644 --- a/src/haiku_support.h +++ b/src/haiku_support.h | |||
| @@ -271,6 +271,7 @@ enum haiku_font_specification | |||
| 271 | FSPEC_WIDTH = 1 << 7, | 271 | FSPEC_WIDTH = 1 << 7, |
| 272 | FSPEC_LANGUAGE = 1 << 8, | 272 | FSPEC_LANGUAGE = 1 << 8, |
| 273 | FSPEC_INDICES = 1 << 9, | 273 | FSPEC_INDICES = 1 << 9, |
| 274 | FSPEC_ANTIALIAS = 1 << 10, | ||
| 274 | }; | 275 | }; |
| 275 | 276 | ||
| 276 | typedef char haiku_font_family_or_style[64]; | 277 | typedef char haiku_font_family_or_style[64]; |
| @@ -390,6 +391,10 @@ struct haiku_font_pattern | |||
| 390 | 391 | ||
| 391 | /* Temporary field used during font enumeration. */ | 392 | /* Temporary field used during font enumeration. */ |
| 392 | int oblique_seen_p; | 393 | int oblique_seen_p; |
| 394 | |||
| 395 | /* Whether or not to enable antialising in the font. This field is | ||
| 396 | special in that it's not handled by `BFont_open_pattern'. */ | ||
| 397 | int use_antialiasing; | ||
| 393 | }; | 398 | }; |
| 394 | 399 | ||
| 395 | struct haiku_scroll_bar_value_event | 400 | struct haiku_scroll_bar_value_event |
| @@ -684,6 +689,7 @@ extern const char *be_find_setting (const char *); | |||
| 684 | extern haiku_font_family_or_style *be_list_font_families (size_t *); | 689 | extern haiku_font_family_or_style *be_list_font_families (size_t *); |
| 685 | extern void be_font_style_to_flags (char *, struct haiku_font_pattern *); | 690 | extern void be_font_style_to_flags (char *, struct haiku_font_pattern *); |
| 686 | extern void *be_open_font_at_index (int, int, float); | 691 | extern void *be_open_font_at_index (int, int, float); |
| 692 | extern void be_set_font_antialiasing (void *, bool); | ||
| 687 | extern int be_get_ui_color (const char *, uint32_t *); | 693 | extern int be_get_ui_color (const char *, uint32_t *); |
| 688 | 694 | ||
| 689 | extern void BMessage_delete (void *); | 695 | extern void BMessage_delete (void *); |
diff --git a/src/haikufont.c b/src/haikufont.c index 54f11c6e413..77aa4006310 100644 --- a/src/haikufont.c +++ b/src/haikufont.c | |||
| @@ -381,54 +381,67 @@ haikufont_maybe_handle_special_family (Lisp_Object family, | |||
| 381 | static Lisp_Object | 381 | static Lisp_Object |
| 382 | haikufont_pattern_to_entity (struct haiku_font_pattern *ptn) | 382 | haikufont_pattern_to_entity (struct haiku_font_pattern *ptn) |
| 383 | { | 383 | { |
| 384 | Lisp_Object ent; | 384 | Lisp_Object entity, extras; |
| 385 | |||
| 386 | entity = font_make_entity (); | ||
| 387 | extras = Qnil; | ||
| 388 | |||
| 389 | ASET (entity, FONT_TYPE_INDEX, Qhaiku); | ||
| 390 | ASET (entity, FONT_FOUNDRY_INDEX, Qhaiku); | ||
| 391 | ASET (entity, FONT_FAMILY_INDEX, Qdefault); | ||
| 392 | ASET (entity, FONT_ADSTYLE_INDEX, Qnil); | ||
| 393 | ASET (entity, FONT_REGISTRY_INDEX, Qiso10646_1); | ||
| 394 | ASET (entity, FONT_SIZE_INDEX, make_fixnum (0)); | ||
| 395 | ASET (entity, FONT_AVGWIDTH_INDEX, make_fixnum (0)); | ||
| 396 | ASET (entity, FONT_SPACING_INDEX, make_fixnum (FONT_SPACING_MONO)); | ||
| 397 | |||
| 398 | /* FONT_EXTRA_INDEX in a font entity can contain a cons of two | ||
| 399 | numbers (STYLE . IDX) under the key :indices that tell Emacs how | ||
| 400 | to open a font. */ | ||
| 401 | if (ptn->specified & FSPEC_INDICES) | ||
| 402 | extras = Fcons (Fcons (QCindices, | ||
| 403 | Fcons (make_fixnum (ptn->family_index), | ||
| 404 | make_fixnum (ptn->style_index))), | ||
| 405 | extras); | ||
| 385 | 406 | ||
| 386 | ent = font_make_entity (); | 407 | if (ptn->specified & FSPEC_ANTIALIAS) |
| 387 | ASET (ent, FONT_TYPE_INDEX, Qhaiku); | 408 | extras = Fcons (Fcons (QCantialias, |
| 388 | ASET (ent, FONT_FOUNDRY_INDEX, Qhaiku); | 409 | ptn->use_antialiasing ? Qt : Qnil), |
| 389 | ASET (ent, FONT_FAMILY_INDEX, Qdefault); | 410 | extras); |
| 390 | ASET (ent, FONT_ADSTYLE_INDEX, Qnil); | ||
| 391 | ASET (ent, FONT_REGISTRY_INDEX, Qiso10646_1); | ||
| 392 | ASET (ent, FONT_SIZE_INDEX, make_fixnum (0)); | ||
| 393 | ASET (ent, FONT_AVGWIDTH_INDEX, make_fixnum (0)); | ||
| 394 | ASET (ent, FONT_SPACING_INDEX, make_fixnum (FONT_SPACING_MONO)); | ||
| 395 | 411 | ||
| 396 | /* FONT_EXTRA_INDEX in a font entity can be a cons of two numbers | 412 | ASET (entity, FONT_EXTRA_INDEX, extras); |
| 397 | (STYLE . IDX) that tell Emacs how to open a font. */ | ||
| 398 | if (ptn->specified & FSPEC_INDICES) | ||
| 399 | ASET (ent, FONT_EXTRA_INDEX, | ||
| 400 | Fcons (make_fixnum (ptn->family_index), | ||
| 401 | make_fixnum (ptn->style_index))); | ||
| 402 | 413 | ||
| 403 | FONT_SET_STYLE (ent, FONT_WIDTH_INDEX, Qnormal); | 414 | FONT_SET_STYLE (entity, FONT_WIDTH_INDEX, Qnormal); |
| 404 | FONT_SET_STYLE (ent, FONT_WEIGHT_INDEX, Qnormal); | 415 | FONT_SET_STYLE (entity, FONT_WEIGHT_INDEX, Qnormal); |
| 405 | FONT_SET_STYLE (ent, FONT_SLANT_INDEX, Qnormal); | 416 | FONT_SET_STYLE (entity, FONT_SLANT_INDEX, Qnormal); |
| 406 | 417 | ||
| 407 | if (ptn->specified & FSPEC_FAMILY) | 418 | if (ptn->specified & FSPEC_FAMILY) |
| 408 | ASET (ent, FONT_FAMILY_INDEX, intern (ptn->family)); | 419 | ASET (entity, FONT_FAMILY_INDEX, intern (ptn->family)); |
| 409 | else | 420 | else |
| 410 | ASET (ent, FONT_FAMILY_INDEX, Qdefault); | 421 | ASET (entity, FONT_FAMILY_INDEX, Qdefault); |
| 411 | 422 | ||
| 412 | if (ptn->specified & FSPEC_STYLE) | 423 | if (ptn->specified & FSPEC_STYLE) |
| 413 | ASET (ent, FONT_ADSTYLE_INDEX, intern (ptn->style)); | 424 | ASET (entity, FONT_ADSTYLE_INDEX, intern (ptn->style)); |
| 414 | else | 425 | else |
| 415 | { | 426 | { |
| 416 | if (ptn->specified & FSPEC_WEIGHT) | 427 | if (ptn->specified & FSPEC_WEIGHT) |
| 417 | FONT_SET_STYLE (ent, FONT_WEIGHT_INDEX, | 428 | FONT_SET_STYLE (entity, FONT_WEIGHT_INDEX, |
| 418 | haikufont_weight_to_lisp (ptn->weight)); | 429 | haikufont_weight_to_lisp (ptn->weight)); |
| 419 | if (ptn->specified & FSPEC_SLANT) | 430 | if (ptn->specified & FSPEC_SLANT) |
| 420 | FONT_SET_STYLE (ent, FONT_SLANT_INDEX, | 431 | FONT_SET_STYLE (entity, FONT_SLANT_INDEX, |
| 421 | haikufont_slant_to_lisp (ptn->slant)); | 432 | haikufont_slant_to_lisp (ptn->slant)); |
| 422 | if (ptn->specified & FSPEC_WIDTH) | 433 | if (ptn->specified & FSPEC_WIDTH) |
| 423 | FONT_SET_STYLE (ent, FONT_WIDTH_INDEX, | 434 | FONT_SET_STYLE (entity, FONT_WIDTH_INDEX, |
| 424 | haikufont_width_to_lisp (ptn->width)); | 435 | haikufont_width_to_lisp (ptn->width)); |
| 425 | } | 436 | } |
| 426 | 437 | ||
| 427 | if (ptn->specified & FSPEC_SPACING) | 438 | if (ptn->specified & FSPEC_SPACING) |
| 428 | ASET (ent, FONT_SPACING_INDEX, | 439 | ASET (entity, FONT_SPACING_INDEX, |
| 429 | make_fixnum (ptn->mono_spacing_p ? | 440 | make_fixnum (ptn->mono_spacing_p |
| 430 | FONT_SPACING_MONO : FONT_SPACING_PROPORTIONAL)); | 441 | ? FONT_SPACING_MONO |
| 431 | return ent; | 442 | : FONT_SPACING_PROPORTIONAL)); |
| 443 | |||
| 444 | return entity; | ||
| 432 | } | 445 | } |
| 433 | 446 | ||
| 434 | static void | 447 | static void |
| @@ -613,6 +626,13 @@ haikufont_spec_or_entity_to_pattern (Lisp_Object ent, int list_p, | |||
| 613 | } | 626 | } |
| 614 | } | 627 | } |
| 615 | 628 | ||
| 629 | tem = assq_no_quit (QCantialias, AREF (ent, FONT_EXTRA_INDEX)); | ||
| 630 | if (CONSP (tem)) | ||
| 631 | { | ||
| 632 | ptn->specified |= FSPEC_ANTIALIAS; | ||
| 633 | ptn->use_antialiasing = !NILP (XCDR (tem)); | ||
| 634 | } | ||
| 635 | |||
| 616 | tem = AREF (ent, FONT_REGISTRY_INDEX); | 636 | tem = AREF (ent, FONT_REGISTRY_INDEX); |
| 617 | if (SYMBOLP (tem)) | 637 | if (SYMBOLP (tem)) |
| 618 | haikufont_apply_registry (ptn, tem); | 638 | haikufont_apply_registry (ptn, tem); |
| @@ -732,10 +752,10 @@ haikufont_open (struct frame *f, Lisp_Object font_entity, int x) | |||
| 732 | struct haiku_font_pattern ptn; | 752 | struct haiku_font_pattern ptn; |
| 733 | struct font *font; | 753 | struct font *font; |
| 734 | void *be_font; | 754 | void *be_font; |
| 735 | Lisp_Object font_object, tem, extra; | 755 | Lisp_Object font_object, tem, extra, indices, antialias; |
| 736 | int px_size, min_width, max_width, | 756 | int px_size, min_width, max_width; |
| 737 | avg_width, height, space_width, ascent, | 757 | int avg_width, height, space_width, ascent; |
| 738 | descent, underline_pos, underline_thickness; | 758 | int descent, underline_pos, underline_thickness; |
| 739 | 759 | ||
| 740 | if (x <= 0) | 760 | if (x <= 0) |
| 741 | { | 761 | { |
| @@ -746,15 +766,21 @@ haikufont_open (struct frame *f, Lisp_Object font_entity, int x) | |||
| 746 | 766 | ||
| 747 | extra = AREF (font_entity, FONT_EXTRA_INDEX); | 767 | extra = AREF (font_entity, FONT_EXTRA_INDEX); |
| 748 | 768 | ||
| 769 | indices = assq_no_quit (QCindices, extra); | ||
| 770 | antialias = assq_no_quit (QCantialias, extra); | ||
| 771 | |||
| 772 | if (CONSP (indices)) | ||
| 773 | indices = XCDR (indices); | ||
| 774 | |||
| 749 | /* If the font's indices is already available, open the font using | 775 | /* If the font's indices is already available, open the font using |
| 750 | those instead. */ | 776 | those instead. */ |
| 751 | 777 | ||
| 752 | if (CONSP (extra) && FIXNUMP (XCAR (extra)) | 778 | if (CONSP (indices) && FIXNUMP (XCAR (indices)) |
| 753 | && FIXNUMP (XCDR (extra))) | 779 | && FIXNUMP (XCDR (indices))) |
| 754 | { | 780 | { |
| 755 | block_input (); | 781 | block_input (); |
| 756 | be_font = be_open_font_at_index (XFIXNUM (XCAR (extra)), | 782 | be_font = be_open_font_at_index (XFIXNUM (XCAR (indices)), |
| 757 | XFIXNUM (XCDR (extra)), x); | 783 | XFIXNUM (XCDR (indices)), x); |
| 758 | unblock_input (); | 784 | unblock_input (); |
| 759 | 785 | ||
| 760 | if (!be_font) | 786 | if (!be_font) |
| @@ -778,13 +804,8 @@ haikufont_open (struct frame *f, Lisp_Object font_entity, int x) | |||
| 778 | 804 | ||
| 779 | block_input (); | 805 | block_input (); |
| 780 | 806 | ||
| 781 | /* `font_make_object' tries to treat the extra data as an alist. | ||
| 782 | There is never any real data here, so clear that field. */ | ||
| 783 | |||
| 784 | ASET (font_entity, FONT_EXTRA_INDEX, Qnil); | ||
| 785 | font_object = font_make_object (VECSIZE (struct haikufont_info), | 807 | font_object = font_make_object (VECSIZE (struct haikufont_info), |
| 786 | font_entity, x); | 808 | font_entity, x); |
| 787 | ASET (font_entity, FONT_EXTRA_INDEX, extra); | ||
| 788 | 809 | ||
| 789 | ASET (font_object, FONT_TYPE_INDEX, Qhaiku); | 810 | ASET (font_object, FONT_TYPE_INDEX, Qhaiku); |
| 790 | font_info = (struct haikufont_info *) XFONT_OBJECT (font_object); | 811 | font_info = (struct haikufont_info *) XFONT_OBJECT (font_object); |
| @@ -799,6 +820,9 @@ haikufont_open (struct frame *f, Lisp_Object font_entity, int x) | |||
| 799 | font_info->be_font = be_font; | 820 | font_info->be_font = be_font; |
| 800 | font_info->glyphs = xzalloc (0x100 * sizeof *font_info->glyphs); | 821 | font_info->glyphs = xzalloc (0x100 * sizeof *font_info->glyphs); |
| 801 | 822 | ||
| 823 | if (CONSP (antialias)) | ||
| 824 | be_set_font_antialiasing (be_font, !NILP (XCDR (antialias))); | ||
| 825 | |||
| 802 | font->pixel_size = 0; | 826 | font->pixel_size = 0; |
| 803 | font->driver = &haikufont_driver; | 827 | font->driver = &haikufont_driver; |
| 804 | font->encoding_charset = -1; | 828 | font->encoding_charset = -1; |
| @@ -1270,6 +1294,8 @@ syms_of_haikufont (void) | |||
| 1270 | DEFSYM (Qko, "ko"); | 1294 | DEFSYM (Qko, "ko"); |
| 1271 | DEFSYM (Qjp, "jp"); | 1295 | DEFSYM (Qjp, "jp"); |
| 1272 | 1296 | ||
| 1297 | DEFSYM (QCindices, ":indices"); | ||
| 1298 | |||
| 1273 | #ifdef USE_BE_CAIRO | 1299 | #ifdef USE_BE_CAIRO |
| 1274 | Fput (Qhaiku, Qfont_driver_superseded_by, Qftcr); | 1300 | Fput (Qhaiku, Qfont_driver_superseded_by, Qftcr); |
| 1275 | #endif | 1301 | #endif |