aboutsummaryrefslogtreecommitdiffstats
path: root/src/sfnt.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* ; Add 2026 to copyright years.Sean Whitton2026-01-011-1/+1
|
* Avoid reserved names in sfnt.cPo Lu2025-03-091-4/+4
| | | | | * src/sfnt.c (_MIN, _MAX): Rename to INS_MIN and INS_MAX. (sfnt_interpret_run): Adjust accordingly.
* Update copyright year to 2025Paul Eggert2025-01-011-1/+1
| | | | Run "TZ=UTC0 admin/update-copyright".
* Correct Android failure to open an old CJK fontPo Lu2024-08-201-7/+12
| | | | | | * src/sfnt.c (sfnt_read_cmap_format_2): Properly compute subtable count, and append the empty table at position 0. (sfnt_lookup_glyph_2): Update commentary.
* Fix format 2 cmap handling in sfnt.cPip Cet2024-08-111-5/+5
| | | | | | | | This code is untested as no font with a format 2 cmap could be found. * src/sfnt.c (sfnt_lookup_glyph_2): Fix typos. Assume single-byte encodings use character codes 0, 1, ..., 255 rather than 0, 256, ..., 65280.
* Fix coordinate transformations in sfnt.cPip Cet2024-08-111-4/+8
| | | | | | | | Backport. * src/sfnt.c (sfnt_transform_coordinates): (sfnt_transform_f26dot6): Fix calculation of transformed coordinates in the very rare case of arbitrary transformation matrices.
* Revert "Remove redundant byte-swapping boundary"Po Lu2024-08-031-3/+17
| | | | | | | | 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>.
* ; Fix typosStefan Kangas2024-07-181-1/+1
|
* ; Stylistic adjustments to sfnt.cPo Lu2024-05-201-2/+4
| | | | | * src/sfnt.c (sfnt_map_table, sfnt_read_table): Adapt to coding style of another project using this module.
* Pacify -Wanalyzer-null-dereference in sfnt.cPaul Eggert2024-05-191-21/+13
| | | | | | | * src/sfnt.c (sfnt_map_table, sfnt_read_table) (sfnt_read_cvar_table): Pacify GCC -Wanalyzer-null-dereference. The change to sfnt_read_cvar_table fixes what appears to be an actual null-dereference bug.
* Simplify 32-bit Android bit fiddlingPaul Eggert2024-05-181-40/+2
| | | | | | | | * src/sfnt.c: Include stdbit.h. (sfnt_count_leading_zero_bits) [!INT64_MAX]: Remove this function, which was confusingly named as it actually returned 31 minus the number of leading zero bits. (sfnt_multiply_divide_2) [!INT64_MAX]: Use stdc_leading_zeros instead.
* Remove redundant byte-swapping boundaryPo Lu2024-04-041-17/+3
| | | | | | | * src/sfnt.c (sfnt_read_OS_2_table): * src/sfnt.h (struct sfnt_OS_2_table): Don't redundantly realign after s_family_class.
* Don't respect ROUND_XY_TO_GRID when decomposing uninterpreted glyphPo Lu2024-02-051-8/+2
| | | | | * src/sfnt.c (sfnt_decompose_compound_glyph): Remove useless code; don't pretend to round glyph coordinates.
* ; * src/sfnt.c: Fix standalone compilation.Po Lu2024-01-291-2/+3
|
* Prefer C23 ckd_* to Gnulib *_WRAPV and *_OK macrosPaul Eggert2024-01-281-152/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | | * src/alloc.c (android_make_lisp_symbol) [HAVE_ANDROID && !__clang__]: * src/android.c (android_blit_copy, android_blit_xor) (android_get_image): * src/androidmenu.c (android_menu_show): * src/androidselect.c (Fandroid_get_clipboard_data) (android_notifications_notify_1): * src/androidterm.c (android_decode_utf16) (android_text_to_string): * src/haiku_select.cc (be_display_notification): * src/sfnt.c (sfnt_read_cmap_format_8, sfnt_read_cmap_format_12) (sfnt_read_cmap_format_14, sfnt_read_cmap_table_1) (sfnt_expand_compound_glyph_context, sfnt_poly_edges_exact) (sfnt_read_meta_table, sfnt_read_ttc_header) (sfnt_read_cvt_table, sfnt_read_fpgm_table) (sfnt_read_prep_table, sfnt_make_interpreter) (sfnt_interpret_simple_glyph, sfnt_interpret_compound_glyph_2) (sfnt_interpret_compound_glyph, sfnt_read_default_uvs_table) (sfnt_read_nondefault_uvs_table, sfnt_create_uvs_context) (sfnt_read_fvar_table, sfnt_read_gvar_table) (sfnt_read_avar_table, sfnt_read_cvar_table): * src/sfntfont-android.c (GET_SCANLINE_BUFFER): * src/textconv.c (really_commit_text, really_set_composing_text) (really_replace_text, get_surrounding_text): Prefer C2x stdckdint.h macros to intprops.h macros.
* Correct crash when executing IP within twilight zonePo Lu2024-01-231-0/+12
| | | | | | * src/sfnt.c (sfnt_address_zp2, sfnt_address_zp1) (sfnt_address_zp0): Don't save into X or Y if the zone is set to the twilight zone and they are NULL.
* * src/sfnt.c (sfnt_mul_f26dot6_fixed): Correct typo in last change.Po Lu2024-01-231-1/+1
|
* Do not overwrite flags of succeeding points during generic movePo Lu2024-01-221-0/+6
| | | | | * src/sfnt.c (sfnt_move): Save FLAGS and restore it after X axis movement loop.
* Correct values of INSTCTRL flags testedPo Lu2024-01-221-46/+36
| | | | | | | | | * src/sfnt.c (sfnt_mul_f26dot6_round): New function. (sfnt_mul_f26dot6_fixed): Replace by call to sfnt_mul_fixed_round. (MUL): Round result, as the Apple and MS scalers do. (sfnt_interpret_control_value_program): The instruction control flag which reverts CVT modifications is 2, not 4.
* Be more systematic about parens in C source codePaul Eggert2024-01-201-1/+1
| | | | | | | | | Be more systematic about putting space before paren in calls, and in avoiding unnecessary parentheses in macros. This was partly inspired by my wading through gcc -E output while debugging something else, and seeing too many parens. This patch does not change the generated .o files on my platform.
* Round projs computed executing IP/ISECT instructions and improve IUPPo Lu2024-01-201-31/+75
| | | | | | | | | | | * src/sfnt.c (sfnt_multiply_divide_rounded): New function. (sfnt_multiply_divide_signed): Always round values, as fonts which rely on IP to move points in concert with prior motion and subsequently round such points with MDAP are sensitive to minor deviations in the behavior of the former instruction. (load_unscaled): New macro. (IUP_SINGLE_PAIR, sfnt_interpret_iup_1): Compute ratio w/ unscaled points if possible.
* Increase accuracy of IP instructionPo Lu2024-01-171-3/+83
| | | | | | * src/sfnt.c (sfnt_interpret_ip): Avoid precision loss by retrieving original positions from the unscaled outline, whenever possible.
* Correct implementations of FLIPRGON and FLIPRGOFFPo Lu2024-01-141-5/+5
| | | | | | | * src/sfnt.c (sfnt_interpret_fliprgoff) (sfnt_interpret_fliprgon): Reorder arguments to match the order in which arguments are popped by macro wrappers. Fix sundry typos.
* ; Minor edits to PROBLEMS and sfnt.cPo Lu2024-01-101-2/+0
| | | | | | | * etc/PROBLEMS: Improve description of issues with Droid Sans Mono. * src/sfnt.c (sfnt_poly_edges_exact): Remove extraneous undef.
* ; Fix a crash in sfnt_read_fvar_tablePo Lu2024-01-081-1/+1
| | | | | * src/sfnt.c (sfnt_read_fvar_table): Derive padding from correct type.
* Properly instruct Italic Arial or BS Mono at small PPEM sizesPo Lu2024-01-081-37/+124
| | | | | | | | | | | | | | | | | | | | | * 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.
* Properly parse TTC tables with digital signaturesPo Lu2024-01-061-3/+3
| | | | | * src/sfnt.c (sfnt_read_ttc_header): Don't inadvertently overwrite first two offsets while reading the digital signature.
* Don't magnify extent of shifts by variable glyph interpolationPo Lu2024-01-031-8/+14
| | | | | | | | | * src/sfnt.c (sfnt_infer_deltas_2): Correctly index x_coordinates and y_coordinates computing deltas for plain shift. (sfnt_vary_simple_glyph): Copy glyph contents to original_x and original_y not the first time is create, but before each tuple is applied.
* Improve rounding of projection vector versorsPo Lu2024-01-021-5/+21
| | | | | | | * src/sfnt.c (sfnt_short_frac_dot): New function. (sfnt_validate_gs): Guarantee dot product of freedom and projection vectors are properly rounded. If the final product is short of 1/16th of a vector, reset it to an entire vector.
* ; Add 2024 to copyright yearsPo Lu2024-01-021-1/+1
|
* Bring GX point interpolation further into standards compliancePo Lu2024-01-011-269/+182
| | | | | | | | | | * src/sfnt.c (sfnt_infer_deltas_2): New function; factor much of sfnt_infer_deltas_1 into this function, then modify its treatment of untouched points positioned at their reference points to align with standard GX treatment. (sfnt_infer_deltas_1): Remove all code not concerning anchor point discovery. (main): Adjust tests.
* Obey USE_MY_METRICS in compound glyphsPo Lu2023-12-291-78/+222
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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.
* Apply TTF advance width rounding to uninstructed glyphsPo Lu2023-12-251-7/+10
| | | | | | | | | * src/sfnt.c (sfnt_scale_metrics): * src/sfntfont.c (sfntfont_get_glyph_outline): Round advance and floor lbearing scaling glyph metrics. (sfntfont_measure_pcm): Don't round or truncate metrics which have already been.
* Optimize font edge filling loopPo Lu2023-12-251-54/+33
| | | | | | | * src/sfnt.c (sfnt_fedge_sort): Delete function. (sfnt_poly_edges_exact): Don't sort edges, iterate through each instead. (main): Adjust tests.
* ; * src/sfnt.c (sfnt_interpret_compound_glyph_2): Reword a comment.Eli Zaretskii2023-12-231-1/+1
|
* Respect glyph metrics modified by instruction codePo Lu2023-12-231-15/+49
| | | | | | | | | | | | | | | | | | | | * 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.
* Properly instruct compound glyphs with compound componentsPo Lu2023-12-221-24/+10
| | | | | | * src/sfnt.c (sfnt_interpret_compound_glyph_2): Don't grow the compound decomposition context for saving compound points into, since the space for them already exists.
* Implement an undocumented TrueType "feature"Po Lu2023-12-211-1/+33
| | | | | | | * src/sfnt.c (sfnt_move): Correct commentary. (sfnt_interpret_control_value_program): Reset dual projection, freedom and projection vectors, in addition to the reference points, zone pointers and loop counter.
* * src/sfnt.c (GETINFO): Implement undocumented selector bit 5.Po Lu2023-12-211-2/+8
|
* Accept empty contours in glyphsPo Lu2023-12-211-2/+4
| | | | | * src/sfnt.c (sfnt_decompose_glyph_1, sfnt_decompose_glyph_2): Accept empty contours, for they are not invalid, just redundant.
* Improve efficiency of operations involving font interpreter scalePo Lu2023-12-191-20/+21
| | | | | | | | | | * src/sfnt.c (sfnt_mul_f26dot6_fixed): Correct rounding constant. (sfnt_make_interpreter, SSW, WCVTF, sfnt_compute_phantom_points) (sfnt_interpret_simple_glyph, sfnt_interpret_compound_glyph_1) (sfnt_vary_interpreter, sfnt_check_ssw): Account for the fractional bits in a f26dot6 when computing the interpreter scale factor.
* Properly sign-extend freedom and projection vector valuesPo Lu2023-12-191-4/+4
| | | | * src/sfnt.c (GPV, GFV): Cast versors to int32_t.
* Further corrections to font scalingPo Lu2023-12-191-22/+41
| | | | | | | | | | | * src/sfnt.c (sfnt_dot_fix_14): Correct typo in final division. (sfnt_compute_phantom_points): New parameters S1 and S2, into which unrounded phantom point coordinates are saved. (sfnt_interpret_simple_glyph, sfnt_interpret_compound_glyph_2) (sfnt_interpret_compound_glyph_1): Adjust correspondingly. * src/sfntfont.c (sfntfont_get_glyph_outline): Delete redundant branch.
* Further fixes for problems uncovered by the previous fixPo Lu2023-12-181-9/+14
| | | | | | | * src/sfnt.c (sfnt_deltap): Enable deltap instructions again, since they now serve a purpose. (sfnt_compute_phantom_points): Round phantom points to match the behavior of other TrueType scalers.
* ; * src/sfnt.c: Fix typo.Po Lu2023-12-181-1/+1
|
* * src/sfnt.c (sfnt_interpret_mdap): Correct MDAP opcode.Po Lu2023-12-181-4/+4
|
* Fix typo in earlier changesPo Lu2023-12-181-5/+5
| | | | | | * src/sfnt.c (sfnt_poly_edges_exact): Don't overwrite the remainder of an ascending edge with its covered height. (main): Adjust tests.
* Enable the new font scalerPo Lu2023-12-181-29/+67
| | | | | | | | | | | | | | | | * 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.c: Fix typos.Po Lu2023-12-171-2/+2
|
* Introduce the rudiments of a new font rasterizerPo Lu2023-12-171-14/+913
| | | | | | | | | | | | | * src/sfnt.c (xzalloc): New function. (sfnt_poly_edges): Remove redundant statement. (sfnt_add, sfnt_sub, sfnt_mul): Move macro definitions above the new scaler. (sfnt_build_outline_fedges, sfnt_insert_raster_step) (sfnt_fedge_sort, sfnt_poly_edges_exact, sfnt_compute_fill) (sfnt_poly_steps, sfnt_raster_steps, sfnt_raster_edges_exact) (sfnt_raster_glyph_outline_exact): New functions, presently disabled. (sfnt_x_raster, main): Introduce new tests.