aboutsummaryrefslogtreecommitdiffstats
path: root/src/sfnt.h (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Update copyright year to 2025Paul Eggert2025-01-011-1/+1
| | | | Run "TZ=UTC0 admin/update-copyright".
* Revert "Remove redundant byte-swapping boundary"Po Lu2024-08-031-0/+2
| | | | | | | | This reverts commit daefd6771a4879bb8e71ea67f69522700155df01. * src/sfnt.c (sfnt_read_OS_2_table): Restore realignment after s_family_class, as it occupies byte 32, not 34. Reported by Pip Cet <pipcet@protonmail.com>.
* Remove redundant byte-swapping boundaryPo Lu2024-04-041-2/+0
| | | | | | | * src/sfnt.c (sfnt_read_OS_2_table): * src/sfnt.h (struct sfnt_OS_2_table): Don't redundantly realign after s_family_class.
* ; Spelling fixesPaul Eggert2024-01-301-1/+1
|
* Properly instruct Italic Arial or BS Mono at small PPEM sizesPo Lu2024-01-081-0/+4
| | | | | | | | | | | | | | | | | | | | | * src/sfnt.c (sfnt_read_simple_glyph): Correct alignment errors. (PUSH2_UNCHECKED): Don't shift negative signed value to the left. (SLOOP): Permit LOOP to be set to 0, which inhibits the execution of instructions it affects. (sfnt_address_zp2, sfnt_address_zp1, sfnt_address_zp0): Permit X and Y to be NULL. (sfnt_dot_fix_14): Guarantee that the final value is rounded to negative infinity, not zero. (sfnt_project_zp1_zp0_org): New function. (sfnt_interpret_mdrp): Avoid rounding issues by computing original distance from unscaled coordinates, if at all possible. (sfnt_interpret_simple_glyph, sfnt_interpret_compound_glyph_2): Set zone->simple. (all_tests) <LOOP>: Update test. (sfnt_identify_instruction, main): Adjust tests. * src/sfnt.h (struct sfnt_interpreter_zone): New field simple.
* ; Add 2024 to copyright yearsPo Lu2024-01-021-1/+1
|
* Obey USE_MY_METRICS in compound glyphsPo Lu2023-12-291-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/sfnt.c (struct sfnt_compound_glyph_context): New fields holding the positions of both phantom points. (sfnt_decompose_compound_glyph): New argument METRICS_RETURN; return the metrics of components with USE_MY_METRICS within this field. (sfnt_decompose_glyph): New argument METRICS_RETURN, which serves the same purpose. (sfnt_build_glyph_outline): Apply glyph advance and origin distortion to METRICS, and return the metrics as altered by compound glyphs in there. (sfnt_lookup_glyph_metrics): Trim away two unused parameters, PIXEL_SIZE and HEAD, whose functionality has been superseeded by sfnt_scale_metrics and the implicit scaling the interpreter performs. (sfnt_interpret_compound_glyph_2): Save phantom points within fields provided to that end in CONTEXT. (sfnt_interpret_compound_glyph_1): Save and source phantom points for each glyph to and from the context. (sfnt_test_get_metrics, main): Adjust tests correspondingly. * src/sfnt.h: Update prototypes. * src/sfntfont.c (sfntfont_get_metrics): Remove obsolete parameters. (sfntfont_get_glyph_outline): Don't change temp by the metrics distortions, which is now the task of sfnt_decompose_glyph.
* Consistently round glyph advances in the SFNT font backendPo Lu2023-12-261-0/+1
| | | | | | | | | | | * src/sfnt.h (SFNT_ROUND_FIXED): New macro. * src/sfntfont.c (sfntfont_get_glyph_outline): Don't apply advance width distortion before the glyph is instructed or decomposed. Round advance width as measured between both phantom points subsequent to instruction code execution. (sfntfont_draw): Don't take the advance's ceiling when advancing origin point.
* Respect glyph metrics modified by instruction codePo Lu2023-12-231-1/+1
| | | | | | | | | | | | | | | | | | | | * src/sfnt.c (sfnt_read_glyph): Clear advance and origin distortion returning an empty glyph. (sfnt_build_instructed_outline): New parameter *ADVANCE_WIDTH, in which the glyph's advance width is saved. (sfnt_interpret_compound_glyph_1): Refine commentary. (sfnt_verbose, main): Adjust tests. * src/sfnt.h: Update prototypes correspondingly. * src/sfntfont.c (sfntfont_get_glyph_outline): If an instructed outline is available, derive the advance and lbearing from the measurements within. (sfntfont_probe_widths): Call sfntfont_measure_pcm to establish average widths. (sfntfont_open): Do so after instruction code initialization completes. (sfntfont_measure_pcm): Revise commentary.
* Enable the new font scalerPo Lu2023-12-181-0/+1
| | | | | | | | | | | | | | | | * src/sfnt.c (sfnt_curve_is_flat): Tighten threshold for flat curves. (sfnt_insert_raster_step): Rewrite loop for clarity. (sfnt_poly_set_steps): New function; fill small spans with a plain unexceptional loop rather than memset. (sfnt_poly_steps): Call that function. (sfnt_verbose, main): Adjust tests such that the scaler can be selected at runtime. * src/sfnt.h: Update prototypes. * src/sfntfont.c (sfntfont_get_glyph_raster) (syms_of_sfntfont) <sfnt_raster_glyphs_exactly>: New variable.
* * src/sfnt.h (sfnt_coerce_fixed): New macro.Po Lu2023-12-171-1/+2
|
* ; Fix typosStefan Kangas2023-12-101-1/+1
|
* Ascertain font spacing from post table if presentPo Lu2023-10-301-0/+48
| | | | | | | | | | | | | | | * src/sfnt.c (sfnt_table_names): Introduce name of post table. (sfnt_read_post_table): New function. (main): New tests. * src/sfnt.h (struct sfnt_post_table): New struct. * src/sfntfont.c (sfnt_enum_font_1): Read post table, and set spacing from its is_fixed_pitch value. (sfntfont_list_1): Compare spacing between both fonts if supplied in the font spec. (sfntfont_open): Set FONT_FILE_INDEX as well as FONT_FULLNAME_INDEX.
* Enumerate default UVS glyphsPo Lu2023-10-221-0/+6
| | | | | | | | | | | | | * src/sfnt.c (sfnt_compare_unicode_value_range) (sfnt_is_character_default): New functions. (sfnt_test_uvs): Print and verify the default UVS table. * src/sfnt.h: Update prototypes. * src/sfntfont.c (sfntfont_get_variation_glyphs): Index the cmap with the default glyph, and insert it within VARIATIONS if character is present within a selector record's default UVS table.
* Extract font foundry metadata from the OS/2 tablePo Lu2023-09-121-0/+88
| | | | | | | | | | | | | | | | * src/sfnt.c (sfnt_table_names): Append an entry for OS/2 tables. (sfnt_read_OS_2_table): New function. (main): Introduce a new test for the OS/2 table reader. * src/sfnt.h (sfnt_read_OS_2_table): New declaration. * src/sfntfont.c (sfnt_decode_foundry_name): Delete function. (sfnt_enum_font_1): Read the font's OS/2 table and extract the foundry name from there. Use `misc' if absent. (sfntfont_desc_to_entity, sfntfont_open): Cease interning desc->designer, as that is now a symbol. (syms_of_sfntfont) <Qmisc>: New defsym Qmisc. (bug#65865)
* Properly parse format 4 cmap tablesPo Lu2023-08-241-0/+3
| | | | | | | | | | | | | * src/sfnt.c (sfnt_read_cmap_format_4): Read range_shift field propery. Prior to this, it would be inadvertently treated as an entry within the segment end code array, which only functioned by happenstance. (sfnt_lookup_glyph_4): Remove workaround grounded upon an erroneous interpretation of the bug fixed by the aformentioned change. * src/sfnt.h (struct sfnt_cmap_format_4): Introduce previously absent `range_shift' field.
* Update Android portPo Lu2023-08-201-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | * src/sfnt.c (sfnt_decompose_compound_glyph): New argument GET_METRICS. Call this function to retrieve glyph metrics used to compute phantom points when a component glyph's anchor point is one. (sfnt_decompose_glyph, sfnt_build_glyph_outline): Plumb GET_METRICS these two functions. (sfnt_interpret_shc): Don't shift the provided reference point. (sfnt_transform_f26dot6): Eschew looping through X and Y if no offsets are provided. (sfnt_interpret_compound_glyph_2): Discontinue initializing phantom points here. (sfnt_interpret_compound_glyph_1): Do not incorporate phantom points into the ultimately produced glyph outline. Correctly provide for phantom childanchor points. (sfnt_test_get_metrics, main): Update tests. * src/sfnt.h: Update prototypes. * src/sfntfont.c (struct sfntfont_get_glyph_outline_dcontext): New fields `hmtx', `hhea' and `maxp'. (sfntfont_get_metrics): New function. (sfntfont_get_glyph_outline): Provide new tables and the new callback function.
* Fix display of compound glyphs that employ simple transformsPo Lu2023-08-161-7/+7
| | | | | | | | | | | | | | | | | | * src/sfnt.c (sfnt_transform_coordinates): Always compute an affine transform matrix except if no scale is provided at all. Unconditionally apply x_off and y_off. (sfnt_decompose_compound_glyph): Delete arguments OF_X and OFF_Y. Apply component offsets after writing simple glyph contours. (sfnt_decompose_glyph): Modify for new calling convention. (sfnt_transform_f26dot6): Modify analogously to sfnt_decompose_compound_glyph. Also correct anchor offset computation to scale the unscaled component anchor coordinates by the interpreter scale. (sfnt_interpret_compound_glyph_1): Also modify for new calling convention. * src/sfnt.h (struct sfnt_compound_glyph_component): <u>: Make scale fields signed.
* ; Fix FSF address in some files' copyright noticesPo Lu2023-08-131-2/+1
| | | | | | | | | | * src/sfnt.c: * src/sfnt.h: * src/sfntfont-android.c: * src/sfntfont.c: * src/sfntfont.h: Replace the old FSF address with a link to gnu.org/licenses. These addresses were inadvertently imported when sfnt.c was copied to src.
* ; * src/sfnt.h: Fix typo.Po Lu2023-03-301-1/+1
|
* Update Android portPo Lu2023-03-301-0/+7
| | | | | | | | | | | | | | | | | | * src/sfnt.c (sfnt_make_interpreter): New argument `fvar'. Set axis count. (SCANCTRL): Implement selector bit 8. (GXAXIS): New instruction. (SFVTPV): Validate graphics state after changing freedom vector. (sfnt_line_to_vector): Implement `original'. (sfnt_move): Remove redundant division. (sfnt_interpret_run): Implement distortable font related GXAXIS instruction (0x91). (sfnt_vary_interpreter): Set naxis and norm_coords. (sfnt_make_test_interpreter, pushb_test_args, pushw_test_args) (sfnt_name_instruction, main): Adjust accordingly. * src/sfnt.h (struct sfnt_interpreter, PROTOTYPE): * src/sfntfont.c (sfntfont_setup_interpreter, sfntfont_open): Set up distortion information.
* Correctly round lbearing valuesPo Lu2023-03-281-3/+2
| | | | | | * src/sfnt.h (SFNT_ROUND_FIXED): * src/sfntfont.c (sfntfont_probe_widths): (sfntfont_measure_pcm): Round lbearing properly.
* Refactor sfntfont.cPo Lu2023-03-271-4/+2
| | | | | | | | | | | | | | | | | * src/sfnt.c (sfnt_build_glyph_outline): Take scale, not head and pixel size. (sfnt_scale_metrics_to_pixel_size): Delete function. (sfnt_get_scale): New function. (main): Update tests. * src/sfnt.h (PROTOTYPE): Update prototypes. * src/sfntfont.c (struct sfnt_outline_cache) (sfntfont_get_glyph_outline, struct sfnt_font_info) (sfntfont_open): Save scale in font information and use it. (sfntfont_measure_instructed_pcm): Delete function. (sfntfont_measure_pcm): Make this the only ``measure pcm'' function. (sfntfont_draw): Rely on sfntfont_get_glyph_outline for the scale.
* Update Android portPo Lu2023-03-261-142/+441
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/sfnt.c (sfnt_table_names): Add avar. (sfnt_read_glyph): Clear distortion fields. (sfnt_build_glyph_outline): Calculate the outline origin point. (sfnt_prepare_raster): Apply the origin point to the X axis offset. (sfnt_scale_metrics_to_pixel_size): New function. (sfnt_build_instructed_outline): Use instructed origin phantom point to determine the outline origin. (sfnt_compute_phantom_points): Apply origin and advance distortion. (struct sfnt_variation_axis, struct sfnt_instance) (struct sfnt_fvar_table, sfnt_read_fvar_table) (struct sfnt_gvar_table, sfnt_read_gvar_table) (sfnt_read_avar_table, struct sfnt_blend, sfnt_init_blend) (sfnt_free_blend, sfnt_normalize_blend, struct sfnt_tuple_header) (struct sfnt_gvar_glyph_header, sfnt_read_packed_deltas) (sfnt_compute_tuple_scale, sfnt_read_cvar_table) (sfnt_infer_deltas_1, sfnt_vary_simple_glyph, sfnt_infer_deltas) (sfnt_vary_glyph, sfnt_vary_compound_glyph) (sfnt_vary_interpreter): New functions. Add structs to sfntfont.h. (struct sfnt_test_dcontext, sfnt_test_get_glyph, main): Test distortable font handling. * src/sfnt.h (SFNT_ENABLE_HINTING): (enum sfnt_table): (struct sfnt_glyph): (struct sfnt_glyph_outline): (struct sfnt_raster): (struct sfnt_default_uvs_table): (struct sfnt_unicode_value_range): (struct sfnt_nondefault_uvs_table): (struct sfnt_uvs_mapping): (struct sfnt_mapped_variation_selector_record): (struct sfnt_table_offset_rec): (struct sfnt_uvs_context): (struct sfnt_mapped_table): (struct sfnt_variation_axis): (struct sfnt_instance): (struct sfnt_fvar_table): (struct sfnt_short_frac_correspondence): (struct sfnt_short_frac_segment): (struct sfnt_avar_table): (struct sfnt_tuple_variation): (struct sfnt_cvar_table): (struct sfnt_gvar_table): (struct sfnt_blend): (struct sfnt_metrics_distortion): (PROTOTYPE): Update prototypes. * src/sfntfont.c (sfntfont_get_glyph_outline): (sfntfont_measure_pcm): Adjust calls.
* Update Android portPo Lu2023-03-241-7/+17
| | | | | | | | | | | | | | | | | | | | | * src/sfnt.c (sfnt_table_names): Add fvar, gvar, cvar. (sfnt_read_maxp_table): Call xmalloc, not malloc. (sfnt_read_simple_glyph): Avoid use-after-free if simple is invalid. (sfnt_fill_span): Fix max coverage. (sfnt_normalize_vector): Fail if magnitude is zero. (sfnt_measure_distance): Fix opcode order. (sfnt_dot_fix_14): Fix implementation. (struct sfnt_variation_axis, struct sfnt_instance) (struct sfnt_fvar_table, struct sfnt_gvar_table) (sfnt_read_fvar_table, sfnt_read_gvar_table, struct sfnt_blend) (sfnt_init_blend, sfnt_free_blend, sfnt_normalize_blend) (struct sfnt_tuple_header, struct sfnt_gvar_glyph_header) (sfnt_read_packed_points, sfnt_read_packed_deltas) (sfnt_compute_tuple_scale, sfnt_infer_deltas_1, sfnt_infer_deltas) (sfnt_vary_glyph): Add WIP variation glyph implementation. * src/sfnt.h (enum sfnt_table, struct sfnt_simple_glyph): Likewise.
* Update Android portPo Lu2023-03-201-1/+164
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * configure.ac: Add support for HarfBuzz on Android. * java/INSTALL: Document where to get Emacs with HarfBuzz. * lisp/subr.el (overriding-text-conversion-style, y-or-n-p): Correctly set text conversion style if y-or-n-p is called inside the minibuffer. * src/sfnt.c (sfnt_read_cmap_format_8) (sfnt_read_cmap_format_12): Fix typos. (sfnt_read_24, sfnt_read_cmap_format_14): New function. (sfnt_read_cmap_table_1, sfnt_read_cmap_table): Handle format 14 cmap tables. (sfnt_read_default_uvs_table, sfnt_read_nondefault_uvs_table) (sfnt_compare_table_offsets, sfnt_create_uvs_context) (sfnt_free_uvs_context, sfnt_compare_uvs_mapping) (sfnt_variation_glyph_for_char, sfnt_map_table, sfnt_unmap_table) (sfnt_read_table, sfnt_test_uvs): New functions. (main): Add UVS tests. * src/sfnt.h (struct sfnt_cmap_format_14) (struct sfnt_variation_selector_record) (struct sfnt_default_uvs_table, struct sfnt_unicode_value_range) (struct sfnt_nondefault_uvs_table, struct sfnt_uvs_mapping) (struct sfnt_mapped_variation_selector_record) (struct sfnt_table_offset_rec, struct sfnt_uvs_context) (struct sfnt_mapped_table): New structures. Update prototypes. * src/sfntfont-android.c (android_sfntfont_driver): Register HarfBuzz callbacks where required. * src/sfntfont.c (sfntfont_select_cmap): Look for a format 14 table. Save it in new arg FORMAT14. (sfntfont_read_cmap): Adjust accordingly. (struct sfnt_font_info): New field `uvs'. New fields `hb_font', `fd' and `directory'. (sfntfont_open): Open uvs context. Under HarfBuzz, don't close the fd or subtable, but save them in the font info instead. (sfntfont_close): Free UVS context. Close font fd and table directory and HarfBuzz font. (sfntfont_draw): Handle case where s->padding_p. (sfntfont_get_variation_glyphs): New function. (sfntfont_unmap_blob, sfntfont_get_font_table) (sfntfont_begin_hb_font): New functions. * src/sfntfont.h: Update prototypes. * src/textconv.c (Fset_text_conversion_style): Fix doc string.
* Update Android portPo Lu2023-02-181-0/+9
| | | | | | | | | | | | | | | | * configure.ac: Check for madvise. * lisp/international/fontset.el (script-representative-chars): Improve detection of CJK fonts. * src/pdumper.c (dump_discard_mem): Use madvise if possible. * src/sfnt.c (sfnt_map_glyf_table, sfnt_unmap_glyf_table): New functions. * src/sfnt.h (struct sfnt_glyf_table): New field. * src/sfntfont.c (struct sfnt_font_info, sfntfont_open) (sfntfont_close, sfntfont_detect_sigbus): Allow mmapping fonts if possible. * src/sfntfont.h: Update prototypes. * src/sysdep.c (handle_sigbus, init_sigbus, init_signals): Initialize SIGBUS correctly.
* Implement instructing compound glyphsPo Lu2023-02-091-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | * src/sfnt.c (sfnt_read_simple_glyph, sfnt_read_compound_glyph) (sfnt_read_glyph): Take size_t offsets. (struct sfnt_compound_glyph_context) (sfnt_expand_compound_glyph_context) (sfnt_decompose_compound_glyph): Take size_t contour offsets. (sfnt_decompose_glyph): Always close contour even if the first point isn't on-curve. (sfnt_build_outline_edges): Fix coding style. (sfnt_interpret_iup): Skip phantom points during IUP. (sfnt_decompose_instructed_outline): Clarify documentation. Always close contour even if the first point isn't on-curve. (struct sfnt_test_dcontext, sfnt_test_move_to, sfnt_test_line_to) (sfnt_test_curve_to, sfnt_transform_f26dot6, sfnt_test_get_glyph) (sfnt_test_free_glyph, sfnt_test_span, sfnt_test_edge_ignore) (sfnt_interpret_compound_glyph_2, sfnt_test_edges, main): Update tests. * src/sfnt.h: Export new function. * src/sfntfont.c (sfntfont_get_glyph_outline): Handle compound glyphs. (sfntfont_measure_instructed_pcm, sfntfont_measure_pcm) (sfntfont_draw): Update accordingly.
* Improve text display on Android portPo Lu2023-02-081-1/+482
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/sfnt.c (sfnt_build_glyph_outline): Clear build_outline_context. (sfnt_poly_coverage): Extend coverage map. (sfnt_prepare_raster): Always floor coordinates, since the increase in coverage makes this hack unnecessary. (sfnt_build_outline_edges): Likewise. (sfnt_compare_edges): Remove function. (sfnt_edge_sort): New function. Since edges are already partially sorted, and there are not many, insertion sort suffices. (sfnt_poly_edges): Use sfnt_edge_sort. (sfnt_fill_span): Stop rounding x0 and x1 to the grid, and make coverage computation static. (sfnt_lookup_glyph_metrics): Fix return code for unscaled metrics. (sfnt_scale_metrics): New function. (SFNT_ENABLE_HINTING): Remove define. (struct sfnt_cvt_table, struct sfnt_fpgm_table) (struct sfnt_prep_table): Move to sfnt.h. (sfnt_read_cvt_table): (sfnt_read_fpgm_table, sfnt_read_prep_table): Make TEST_STATIC. (struct sfnt_unit_vector, struct sfnt_interpreter_definition) (struct sfnt_interpreter_zone, struct sfnt_graphics_state): (struct sfnt_interpreter): Move to sfnt.h. (sfnt_make_interpreter): Make TEST_STATIC. (POP, PUSH, DELTAP1, DELTAP2, DELTAP3): When TEST, define to regular push and pop. (sfnt_deltac): (sfnt_deltap): Fix order of arguments. (IUP_SINGLE_PAIR): Fix interpolation loop wraparound. (sfnt_interpret_font_program): (sfnt_interpret_control_value_program): Make TEST_STATIC. (struct sfnt_instructed_outline): Move to sfnt.h. (sfnt_build_instructed_outline): Make TEST_STATIC. (sfnt_interpret_simple_glyph): (sfnt_x_raster): (sfnt_test_raster): (all_tests): (sfnt_verbose): (main): Improve test code. * src/sfnt.h (SFNT_ENABLE_HINTING, struct sfnt_cvt_table) (struct sfnt_fpgm_table, struct sfnt_prep_table) (struct sfnt_unit_vector, struct sfnt_interpreter_definition) (struct sfnt_interpreter_zone, struct sfnt_graphics_state) (struct sfnt_interpreter, struct sfnt_instructed_outline) (PROTOTYPE): New definitions. * src/sfntfont-android.c (sfntfont_android_put_glyphs): Make coordinate generation more straightforward. * src/sfntfont.c (sfntfont_get_glyph_outline): New arguments INTERPRETER and METRICS. (struct sfnt_font_info): New tables. (sfntfont_setup_interpreter): New function. (sfntfont_open): Avoid memory leak. Set up interpreter. (sfntfont_measure_instructed_pcm): New function. (sfntfont_measure_pcm): Delegate to measure_instructed_pcm where appropriate. (sfntfont_close): Free new tables. (sfntfont_draw): Scale metrics properly.
* Remove bresenham stuffPo Lu2023-02-071-14/+1
| | | | | | | * src/sfnt.c (sfnt_step_edge, sfnt_step_edge_n) (sfnt_build_outline_edges, sfnt_test_edge, main): * src/sfnt.h (struct sfnt_edge): Stop using error corrected line drawing, as it's actually slower.
* Update Android portPo Lu2023-02-071-8/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * INSTALL.android: Describe patches for BoringSSL on ARM. * src/sfnt.c (sfnt_build_glyph_outline): Remove redundant multiplication. (sfnt_prepare_raster): Update offset calculation for changes. (sfnt_step_edge, sfnt_step_edge_n): Handle bresenham terms. (sfnt_build_outline_edges): Don't subtract floored xmin, just xmin. (sfnt_saturate_short): Make clang generate better code. (sfnt_fill_span): Stop rounding coordinates. (sfnt_poly_span): Poly consecutive on transitions all in one go. (sfnt_lookup_glyph_metrics): Remove redundant multiplication. (struct sfnt_interpreter): New hooks for debugging. (sfnt_large_integer_add): New function. (sfnt_mul_f26dot6_fixed): Round product. (sfnt_make_interpreter): Remove redundant multiplication. (CHECK_STACK_ELEMENTS, POP_UNCHECKED, PUSH_UNCHECKED): New macros. (MOVE, POP, SWAP, CINDEX, RS, RCVT, LT, LTEQ, GT, GTEQ, EQ, NEQ) (EVEN, AND, OR, NOT, ADD, SUB, DIV, MUL, ABS, NEG, FLOOR, CEILING) (GETINFO, ROLL, _MAX, _MIN, ROUND, NROUND, GC, MD): Don't check SP redundantly, especially when pushing an element right after popping one. (sfnt_move_glyph_zone): Don't touch points by passing NULL as flags. (sfnt_direct_move_zp2): Touch P in the directions of the movement. (sfnt_interpret_scfs): Fix coding style. (sfnt_interpret_simple_glyph): Don't round Y coordinates. (sfnt_test_span, sfnt_test_edges, sfnt_debug_edges, sfnt_test_edge) (sfnt_x_raster, sfnt_test_raster, rcvt_test_args) (deltac1_test_args, deltac2_test_args, deltac3_test_args) (roll_1_test_args, sfnt_run_hook, sfnt_identify_instruction) (sfnt_verbose, main): Improve debug code and tests. * src/sfnt.h (struct sfnt_edge): Add bresenham terms.
* Update Android portPo Lu2023-02-061-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/sfnt.c (struct sfnt_build_glyph_outline_context) (sfnt_build_glyph_outline, sfnt_fill_span): Improve glyph appearance by rounding coordinate values. (struct sfnt_interpreter): New fields `twilight_original_x', `twilight_original_y'. (sfnt_make_interpreter): Set new fields. (DELTAP1, DELTAP2, DELTAP3, SVTCAy, SPVTL, SFVTL, MD): Implement instructions. (sfnt_save_projection_vector): New argument `dual_only'. All callers changed. (sfnt_address_zp2, sfnt_address_zp1, sfnt_address_zp0): Obtain original positions in the twilight zone as well. (sfnt_check_zp1, sfnt_interpret_fliprgoff, sfnt_interpret_fliprgon) (sfnt_interpret_flippt, sfnt_interpret_scfs, sfnt_interpret_miap) (sfnt_interpret_alignrp, sfnt_line_to_vector, P) (sfnt_interpret_msirp, sfnt_interpret_ip, sfnt_interpret_call) (load_point, sfnt_interpret_iup_1, sfnt_interpret_iup) (sfnt_interpret_run, struct sfnt_scaled_outline) (struct sfnt_instructed_outline, sfnt_decompose_instructed_outline) (sfnt_build_instructed_outline, sfnt_compute_phantom_points) (sfnt_interpret_simple_glyph, all_tests, sfnt_setup_debugger) (sfnt_name_instruction, sfnt_draw_debugger, sfnt_run_hook) (sfnt_verbose, main): Make glyph instructing work. * src/sfnt.h (SFNT_POLY_ROUND): New enumerator.
* Update Android portPo Lu2023-02-021-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * src/sfnt.c (xmalloc, xrealloc): Improve behavior upon allocation failures during test. (sfnt_table_names): Add prep. (sfnt_transform_coordinates): Allow applying offsets during coordinate transform. (sfnt_decompose_compound_glyph): Defer offset computation until any component compound glyph is loaded, then apply it during the transform process. (sfnt_multiply_divide): Make available everywhere. Implement on 64 bit systems. (sfnt_multiply_divide_signed): New function. (sfnt_mul_fixed): Fix division overflow. (sfnt_curve_to_and_build_1, sfnt_build_glyph_outline): Remove outdated comment. (sfnt_build_outline_edges): Fix coding style. (sfnt_lookup_glyph_metrics): Allow looking up metrics without scaling. (struct sfnt_cvt_table): Fix type of cvt values. (struct sfnt_prep_table): New structure. (sfnt_read_cvt_table): Read cvt values in terms of fwords, not longs (as Apple's doc seems to say). (sfnt_read_fpgm_table): Fix memory allocation for font program table. (sfnt_read_prep_table): New function. (struct sfnt_interpreter_zone): New structure. (struct sfnt_interpreter_graphics_state): New fields `project', `move', `vector_dot_product'. Rename to `sfnt_graphics_state'. (struct sfnt_interpreter, sfnt_mul_f26dot6): Stop doing rounding division. (sfnt_init_graphics_state): (sfnt_make_interpreter): (MOVE): (SSW): (RAW): (SDS): (ADD): (SUB): (ABS): (NEG): (WCVTF): (_MIN): (S45ROUND): (SVTCAx): (sfnt_set_srounding_state): (sfnt_skip_code): (sfnt_interpret_unimplemented): (sfnt_interpret_fdef): (sfnt_interpret_idef): (sfnt_interpret_if): (sfnt_interpret_else): (sfnt_round_none): (sfnt_round_to_grid): (sfnt_round_to_double_grid): (sfnt_round_down_to_grid): (sfnt_round_up_to_grid): (sfnt_round_to_half_grid): (sfnt_round_super): (sfnt_validate_gs): (sfnt_interpret_run): (sfnt_interpret_font_program): (struct sfnt_test_dcontext): (sfnt_test_move_to): (sfnt_test_line_to): (sfnt_test_curve_to): (sfnt_test_get_glyph): (sfnt_test_free_glyph): (sfnt_test_span): (sfnt_test_edge_ignore): (sfnt_test_edge): (sfnt_test_raster): (test_interpreter_profile): (test_cvt_values): (test_interpreter_cvt): (test_interpreter_head): (sfnt_make_test_interpreter): (struct sfnt_interpreter_test): (sfnt_run_interpreter_test): (struct sfnt_generic_test_args): (sfnt_generic_check): (sfnt_check_srp0): (sfnt_check_szp0): (sfnt_check_sloop): (struct sfnt_rounding_test_args): (sfnt_check_rounding): (sfnt_check_smd): (sfnt_check_scvtci): (sfnt_check_sswci): (sfnt_check_ssw): (sfnt_check_flipon): (sfnt_check_flipoff): (npushb_test_args): (npushw_test_args): (pushb_test_args): (pushw_test_args): (stack_overflow_test_args): (stack_underflow_test_args): (rtg_test_args): (rtg_symmetric_test_args): (rtg_1_test_args): (rtg_1_symmetric_test_args): (rthg_test_args): (rthg_1_test_args): (rtdg_test_args): (rtdg_1_test_args): (rtdg_2_test_args): (rtdg_3_test_args): (else_test_args): (jmpr_test_args): (dup_test_args): (pop_test_args): (clear_test_args): (swap_test_args): (depth_test_args): (cindex_test_args): (mindex_test_args): (raw_test_args): (loopcall_test_args): (call_test_args): (fdef_test_args): (fdef_1_test_args): (endf_test_args): (ws_test_args): (rs_test_args): (wcvtp_test_args): (rcvt_test_args): (mppem_test_args): (mps_test_args): (debug_test_args): (lt_test_args): (all_tests): (main): Implement more instructions. * src/sfnt.h (enum sfnt_table, struct sfnt_glyph_metrics): Add new tables. Add comment.
* Update Android portPo Lu2023-01-301-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * cross/ndk-build/ndk-build-shared-library.mk: ($(call objname,$(LOCAL_MODULE),$(basename $(1)))): * cross/ndk-build/ndk-build-static-library.mk: ($(call objname,$(LOCAL_MODULE),$(basename $(1)))): Revert broken typo fixes. * src/sfnt.c (TEST_STATIC): Define ARRAYELTS. (sfnt_table_names): New CVT and FPGM tables. (sfnt_decompose_compound_glyph, sfnt_decompose_glyph) (struct sfnt_large_integer, sfnt_multiply_divide_1) (sfnt_count_leading_zero_bits, sfnt_multiply_divide_2) (sfnt_multiply_divide, sfnt_mul_fixed, sfnt_div_fixed) (sfnt_ceil_fixed, sfnt_build_glyph_outline): Fix fixed point multiplication routines on systems without 64 bit long long type. (SFNT_ENABLE_HINTING, struct sfnt_test_dcontext, sfnt_test_move_to) (sfnt_test_line_to, sfnt_test_curve_to, sfnt_test_get_glyph) (sfnt_test_free_glyph, sfnt_test_span, sfnt_test_edge_ignore) (sfnt_read_cvt_table, sfnt_test_edge, sfnt_test_raster) (sfnt_read_fpgm_table, struct sfnt_unit_vector) (struct sfnt_interpreter_definition) (struct sfnt_interpreter_graphics_state, struct sfnt_interpreter) (sfnt_div_f26dot6, sfnt_mul_f26dot6, sfnt_floor_f26dot6) (sfnt_ceil_f26dot6, sfnt_round_f26dot6, sfnt_init_graphics_state) (sfnt_make_interpreter, enum sfnt_interpreter_run_context) (sfnt_interpret_trap, STACKSIZE, sfnt_set_srounding_state) (sfnt_skip_code, sfnt_interpret_unimplemented, sfnt_interpret_fdef) (sfnt_interpret_idef, sfnt_interpret_if, sfnt_interpret_else) (sfnt_round_none, sfnt_round_to_grid, sfnt_round_to_double_grid) (sfnt_round_down_to_grid, sfnt_round_up_to_grid) (sfnt_round_to_half_grid, sfnt_round_super, sfnt_validate_gs) (sfnt_interpret_run, sfnt_interpret_font_program) (test_interpreter_profile, test_cvt_values, test_interpreter_cvt) (test_interpreter_head, sfnt_make_test_interpreter) (struct sfnt_interpreter_test, sfnt_run_interpreter_test) (struct sfnt_generic_test_args, sfnt_generic_check) (sfnt_check_srp0, sfnt_check_szp0, sfnt_check_sloop) (struct sfnt_rounding_test_args, sfnt_check_rounding) (sfnt_check_smd, sfnt_check_scvtci, sfnt_check_sswci) (sfnt_check_ssw, sfnt_check_flipon, sfnt_check_flipoff) (npushb_test_args, npushw_test_args, pushb_test_args) (pushw_test_args, stack_overflow_test_args) (stack_underflow_test_args, rtg_test_args, rtg_symmetric_test_args) (rtg_1_test_args, rtg_1_symmetric_test_args, rthg_test_args) (rthg_1_test_args, rtdg_test_args, rtdg_1_test_args) (rtdg_2_test_args, rtdg_3_test_args, else_test_args) (jmpr_test_args, dup_test_args, pop_test_args, clear_test_args) (swap_test_args, depth_test_args, cindex_test_args) (mindex_test_args, raw_test_args, loopcall_test_args) (call_test_args, fdef_test_args, fdef_1_test_args, endf_test_args) (ws_test_args, rs_test_args, wcvtp_test_args, rcvt_test_args) (mppem_test_args, mps_test_args, debug_test_args, lt_test_args) (all_tests, main): Check in WIP hinting code. * src/sfnt.h (enum sfnt_table): Add `cvt ' and `fpgm' tables.
* Update Android portPo Lu2023-01-171-0/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * doc/emacs/android.texi (Android Fonts): Document that TTC format fonts are now supported. * doc/emacs/emacs.texi (Top): Fix menus. * doc/lispref/commands.texi (Touchscreen Events) (Key Sequence Input): Document changes to touchscreen events. * etc/DEBUG: Describe how to debug 64 bit binaries on Android. * java/org/gnu/emacs/EmacsCopyArea.java (perform): Explicitly recycle copy bitmap. * java/org/gnu/emacs/EmacsDialog.java (EmacsDialog): New class. * java/org/gnu/emacs/EmacsDrawRectangle.java (perform): Use 5 point PolyLine like X, because Android behaves like Postscript on some devices and X elsewhere. * java/org/gnu/emacs/EmacsFillRectangle.java (perform): Explicitly recycle copy bitmap. * java/org/gnu/emacs/EmacsPixmap.java (destroyHandle): Explicitly recycle bitmap and GC if it is big. * java/org/gnu/emacs/EmacsView.java (EmacsView): Make `bitmapDirty' a boolean. (handleDirtyBitmap): Reimplement in terms of that boolean. Explicitly recycle old bitmap and GC. (onLayout): Fix lock up. (onDetachedFromWindow): Recycle bitmap and GC. * java/org/gnu/emacs/EmacsWindow.java (requestViewLayout): Update call to explicitlyDirtyBitmap. * src/android.c (android_run_select_thread, android_select): Really fix android_select. (android_build_jstring): New function. * src/android.h: Update prototypes. * src/androidmenu.c (android_process_events_for_menu): Totally unblock input before process_pending_signals. (android_menu_show): Remove redundant unblock_input and debugging code. (struct android_emacs_dialog, android_init_emacs_dialog) (android_dialog_show, android_popup_dialog, init_androidmenu): Implement popup dialogs on Android. * src/androidterm.c (android_update_tools) (handle_one_android_event, android_frame_up_to_date): Allow tapping tool bar items. (android_create_terminal): Add dialog hook. (android_wait_for_event): Adjust call to android_select. * src/androidterm.h (struct android_touch_point): New field `tool_bar_p'. * src/keyboard.c (read_key_sequence, head_table) (syms_of_keyboard): Prefix touchscreen events with posn. * src/keyboard.h (EVENT_HEAD): Handle touchscreen events. * src/process.c (wait_reading_process_output): Adjust call to android_select. * src/sfnt.c (sfnt_read_table_directory): If the first long turns out to be ttcf, return -1. (sfnt_read_ttc_header): New function. (main): Test TTC support. * src/sfnt.h (struct sfnt_ttc_header): New structure. (enum sfnt_ttc_tag): New enum. * src/sfntfont-android.c (struct sfntfont_android_scanline_buffer): New structure. (GET_SCANLINE_BUFFER): New macro. Try to avoid so much malloc upon accessing the scanline buffer. (sfntfont_android_put_glyphs): Do not use SAFE_ALLOCA to allocate the scaline buffer. (Fandroid_enumerate_fonts): Enumerate ttc fonts too. * src/sfntfont.c (struct sfnt_font_desc): New field `offset'. (sfnt_enum_font_1): Split out enumeration code from sfnt_enum_font. (sfnt_enum_font): Read TTC tables and enumerate each font therein. (sfntfont_open): Seek to the offset specified. * xcompile/Makefile.in (maintainer-clean): Fix depends here.
* Bring up the sfnt-android font driverPo Lu2023-01-111-24/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * configure.ac (ANDROID_CFLAGS): Add sfnt-related font objects to ANDROID_OBJ when not building stubs. * lisp/startup.el (android-fonts-enumerated): New variable. (normal-top-level): Set it. Also enumerate fonts as early as possible upon startup. * src/alloc.c (cleanup_vector): Only finalize Android font entities. (garbage_collect): Mark sfntfont.c. * src/android.c (struct android_emacs_drawable): New field `damage_rect'. (android_init_emacs_drawable): Initialize Lorg/gnu/emacs/EmacsDrawable;#damageRect(Landroid/graphics/rect;)V. (android_create_gc): Initialize cached GC fields. (android_free_gc): Free cached GC clip rectangles. (android_change_gc): Cache fields as appropriate. (android_set_clip_rectangles): Set cached clip rectangles for easy access from C. (android_get_gc_values): Use cached values. (android_get_image): Remove obsolete comment. (android_lock_bitmap, android_damage_window): New functions that don't parallel anything on X. * src/android.h: Update prototypes. * src/androidfns.c (android_default_font_parameter): Set Droid Sans Mono as the default monospace font. (Fx_create_frame): Register the sfntfont driver. * src/androidgui.h (struct android_gc): Add C side caches for clip rectangles and the foreground and background colors. * src/androidterm.h: Update prototypes. * src/dispextern.h (struct gui_box): New struct. (gui_union_rectangles): New function. * src/emacs.c (android_emacs_init): Initialize Android font stuff late. * src/font.c (font_make_entity): Clear `is_android' field on Android. (font_make_entity_android): Set `is_android' field. * src/font.h (struct font_entity): New field `is_android'. * src/print.c (print_vectorlike): Don't print private data, which could include Lisp_Misc. * src/sfnt.c (sfnt_read_cmap_format_0, sfnt_read_cmap_format_2) (sfnt_read_cmap_format_4, sfnt_read_cmap_format_6) (sfnt_read_cmap_format_8, sfnt_read_cmap_format_12): Remove buggy pragmas. (sfnt_lookup_glyph_4_1): New function. (sfnt_lookup_glyph_4): Handle malformed lookup tables found on Android. (sfnt_lookup_glyph): Fix overflow problems in glyph checks. (sfnt_read_glyph): Handle empty glyphs. This implements some behavior which everyone else seems to as well, but I can't find documented in the TrueType Reference Manual. (sfnt_free_glyph): Export correctly. (sfnt_transform_coordinates): Make faster. (sfnt_lerp_half): Fix lerping in some cases. (sfnt_decompose_glyph): Handle empty glyphs correctly. Close contours manually instead of waiting for the edge building process to do that. This lets curves be handled correctly. (struct sfnt_build_glyph_outline_context): Move internal struct back to sfnt.c. (sfnt_build_append): Fix detection of initial entry. (sfnt_curve_to_and_build_1): Fix De Casteljau implementation. (sfnt_curve_to_and_build): Use fixed point arithmetic to scale outlines. (sfnt_build_glyph_outline): Clear reference counts. Use fixed point arithmetic. (sfnt_prepare_raster): Align rasters to 4 bytes, SFNT_POLY_ALIGNMENT. Fix calculation of offx and offy. (sfnt_step_edge_by): Step edge by previously computed step_x. (sfnt_build_outline_edges): Adjust for already closed contours. Ignore edges abandoned after grid fit. Also precompute step_x to avoid multiplication on each span rastered. (sfnt_poly_edges): Improve alignment. (sfnt_fill_span): Rewrite to avoid control flow in while loop. (sfnt_poly_span): Remove unnecessary code. (sfnt_raster_glyph_outline): Use raster stride instead of width. (sfnt_test_edge, sfnt_test_raster, main): Improve debugging code. * src/sfnt.h (struct sfnt_glyph_outline): Add refcount field to outline. (struct sfnt_build_glyph_outline_context): Remove private struct. (struct sfnt_raster): Add refcount field to raster. (struct sfnt_edge): Improve doc. Add `source_x' field used when built with TEST. (SFNT_CEIL_FIXED): New macro. * src/sfntfont-android.c (sfntfont_android_saturate32) (sfntfont_android_scale32, sfntfont_android_mul8x2) (sfntfont_android_blend, U255TO256) (sfntfont_android_composite_bitmap, sfntfont_android_union_boxes) (sfntfont_android_put_glyphs, sfntfont_android_get_cache): New functions. (android_sfntfont_driver): New font driver. (Fandroid_enumerate_fonts): New function. (syms_of_sfntfont_android_for_pdumper, init_sfntfont_android) (syms_of_sfntfont_android): Initialize default fonts, special family mapping and font driver. * src/sfntfont.c (struct sfnt_font_desc): New fields `char_cache', `cmap_invalid' and `subtable'. (sfnt_setup_coding_system): Improve commentary. Add default branch. Fix return value. (sfnt_safe_encode_coding_object_1) (sfnt_safe_encode_coding_object_2): (sfnt_safe_encode_coding_object): Use decode_coding_object instead of encode_coding_object. (sfnt_decode_font_string): Adjust for rename. (sfnt_decode_foundry_name): New function. (sfnt_weight_descriptions, sfnt_slant_descriptions) (sfnt_width_descriptions): Fix definitions. (sfnt_parse_style): Make function work. (sfnt_enum_font): Initialize designer, char-cache and subtable platform ID. (sfntfont_charset_for_name, mark_sfntfont) (sfntfont_charset_for_cmap): New functions. (syms_of_sfntfont): New variable `sfnt-default-family-alist'. * src/sfntfont.h (_SFNTFONT_H_): Update prototypes. * src/xdisp.c (gui_union_rectangles): New function.
* Check in new filesPo Lu2023-01-081-0/+957
* src/sfnt.h: * src/sfntfont-android.c: * src/sfntfont.c: * src/sfntfont.h: New files.