| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 389efd5 commit a7cfac8
21 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,7 @@ | |||
| 1 | + Font hinting factor is deprecated | ||
| 2 | + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 3 | + | ||
| 4 | + Due to internal changes to support complex text rendering, the hinting factor on fonts is | ||
| 5 | + no longer used. Setting the ``text.hinting_factor`` rcParam to any value other than None | ||
| 6 | + is deprecated, and the rcParam will be removed in the future. Likewise, passing the | ||
| 7 | + ``hinting_factor`` argument to the `.FT2Font` constructor is deprecated. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -779,8 +779,8 @@ def __setitem__(self, key, val): | |||
| 779 | 779 | cval = valid_key(val) | |
| 780 | 780 | except ValueError as ve: | |
| 781 | 781 | raise ValueError(f"Key {key}: {ve}") from None | |
| 782 | - if key == "text.kerning_factor" and cval is not None: | ||
| 783 | - _api.warn_deprecated("3.11", name="text.kerning_factor", obj_type="rcParam") | ||
| 782 | + if key in {"text.hinting_factor", "text.kerning_factor"} and cval is not None: | ||
| 783 | + _api.warn_deprecated("3.11", name=key, obj_type="rcParam") | ||
| 784 | 784 | self._set(key, cval) | |
| 785 | 785 | ||
| 786 | 786 | def __getitem__(self, key): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -179,11 +179,9 @@ def _draw_text_glyphs_and_boxes(self, gc, x, y, angle, glyphs, boxes): | |||
| 179 | 179 | load_flags = get_hinting_flag() | |
| 180 | 180 | for font, size, glyph_index, slant, extend, dx, dy in glyphs: # dy is upwards. | |
| 181 | 181 | font.set_size(size, self.dpi) | |
| 182 | - hf = font._hinting_factor | ||
| 183 | 182 | font._set_transform( | |
| 184 | 183 | (0x10000 * np.array([[cos, -sin], [sin, cos]]) | |
| 185 | - @ [[extend, extend * slant], [0, 1]] | ||
| 186 | - @ [[1 / hf, 0], [0, 1]]).round().astype(int), | ||
| 184 | + @ [[extend, extend * slant], [0, 1]]).round().astype(int), | ||
| 187 | 185 | [round(0x40 * (x + dx * cos - dy * sin)), | |
| 188 | 186 | # FreeType's y is upwards. | |
| 189 | 187 | round(0x40 * (self.height - y + dx * sin + dy * cos))] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -597,7 +597,7 @@ def _flush(self): | |||
| 597 | 597 | ||
| 598 | 598 | ||
| 599 | 599 | def _get_pdf_charprocs(font_path, glyph_indices): | |
| 600 | - font = get_font(font_path, hinting_factor=1) | ||
| 600 | + font = get_font(font_path) | ||
| 601 | 601 | conv = 1000 / font.units_per_EM # Conversion to PS units (1/1000's). | |
| 602 | 602 | procs = {} | |
| 603 | 603 | for glyph_index in glyph_indices: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -107,7 +107,7 @@ def _font_to_ps_type3(font_path, subset_index, glyph_indices): | |||
| 107 | 107 | The string representation of a Type 3 font, which can be included | |
| 108 | 108 | verbatim into a PostScript file. | |
| 109 | 109 | """ | |
| 110 | - font = get_font(font_path, hinting_factor=1) | ||
| 110 | + font = get_font(font_path) | ||
| 111 | 111 | ||
| 112 | 112 | preamble = """\ | |
| 113 | 113 | %!PS-Adobe-3.0 Resource-Font | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1026,7 +1026,7 @@ def get_metrics(self, idx): | |||
| 1026 | 1026 | ||
| 1027 | 1027 | class TtfMetrics: | |
| 1028 | 1028 | def __init__(self, filename): | |
| 1029 | - self._face = font_manager.get_font(filename, hinting_factor=1) | ||
| 1029 | + self._face = font_manager.get_font(filename) | ||
| 1030 | 1030 | ||
| 1031 | 1031 | def get_metrics(self, idx): | |
| 1032 | 1032 | # _mul1220 uses a truncating bitshift for compatibility with dvitype. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1731,11 +1731,11 @@ def is_opentype_cff_font(filename): | |||
| 1731 | 1731 | ||
| 1732 | 1732 | ||
| 1733 | 1733 | @lru_cache(64) | |
| 1734 | - def _get_font(font_filepaths, hinting_factor, *, _kerning_factor, thread_id, | ||
| 1734 | + def _get_font(font_filepaths, *, _kerning_factor, thread_id, | ||
| 1735 | 1735 | enable_last_resort): | |
| 1736 | 1736 | (first_fontpath, first_fontindex), *rest = font_filepaths | |
| 1737 | 1737 | fallback_list = [ | |
| 1738 | - ft2font.FT2Font(fpath, hinting_factor, face_index=index, | ||
| 1738 | + ft2font.FT2Font(fpath, face_index=index, | ||
| 1739 | 1739 | _kerning_factor=_kerning_factor) | |
| 1740 | 1740 | for fpath, index in rest | |
| 1741 | 1741 | ] | |
@@ -1749,12 +1749,12 @@ def _get_font(font_filepaths, hinting_factor, *, _kerning_factor, thread_id, | |||
| 1749 | 1749 | # already in the list. | |
| 1750 | 1750 | if enable_last_resort: | |
| 1751 | 1751 | fallback_list.append( | |
| 1752 | - ft2font.FT2Font(last_resort_path, hinting_factor, | ||
| 1752 | + ft2font.FT2Font(last_resort_path, | ||
| 1753 | 1753 | _kerning_factor=_kerning_factor, | |
| 1754 | 1754 | _warn_if_used=True)) | |
| 1755 | 1755 | last_resort_index = len(fallback_list) | |
| 1756 | 1756 | font = ft2font.FT2Font( | |
| 1757 | - first_fontpath, hinting_factor, face_index=first_fontindex, | ||
| 1757 | + first_fontpath, face_index=first_fontindex, | ||
| 1758 | 1758 | _fallback_list=fallback_list, | |
| 1759 | 1759 | _kerning_factor=_kerning_factor | |
| 1760 | 1760 | ) | |
@@ -1783,6 +1783,7 @@ def _cached_realpath(path): | |||
| 1783 | 1783 | return os.path.realpath(path) | |
| 1784 | 1784 | ||
| 1785 | 1785 | ||
| 1786 | + @_api.delete_parameter('3.11', 'hinting_factor') | ||
| 1786 | 1787 | def get_font(font_filepaths, hinting_factor=None): | |
| 1787 | 1788 | """ | |
| 1788 | 1789 | Get an `.ft2font.FT2Font` object given a list of file paths. | |
@@ -1816,20 +1817,16 @@ def get_font(font_filepaths, hinting_factor=None): | |||
| 1816 | 1817 | if isinstance(fname, FontPath) else (_cached_realpath(fname), 0) | |
| 1817 | 1818 | for fname in font_filepaths) | |
| 1818 | 1819 | ||
| 1819 | - hinting_factor = mpl._val_or_rc(hinting_factor, 'text.hinting_factor') | ||
| 1820 | - | ||
| 1821 | 1820 | font = _get_font( | |
| 1822 | 1821 | # must be a tuple to be cached | |
| 1823 | 1822 | paths, | |
| 1824 | - hinting_factor, | ||
| 1825 | 1823 | _kerning_factor=mpl.rcParams['text.kerning_factor'], | |
| 1826 | 1824 | # also key on the thread ID to prevent segfaults with multi-threading | |
| 1827 | 1825 | thread_id=threading.get_ident(), | |
| 1828 | 1826 | enable_last_resort=mpl.rcParams['font.enable_last_resort'], | |
| 1829 | 1827 | ) | |
| 1830 | 1828 | # Ensure the transform is always consistent. | |
| 1831 | - font._set_transform([[round(0x10000 / font._hinting_factor), 0], [0, 0x10000]], | ||
| 1832 | - [0, 0]) | ||
| 1829 | + font._set_transform([[0x10000, 0], [0, 0x10000]], [0, 0]) | ||
| 1833 | 1830 | return font | |
| 1834 | 1831 | ||
| 1835 | 1832 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -142,7 +142,6 @@ class FontManager: | |||
| 142 | 142 | def is_opentype_cff_font(filename: str) -> bool: ... | |
| 143 | 143 | def get_font( | |
| 144 | 144 | font_filepaths: Iterable[str | bytes | os.PathLike | FontPath] | str | bytes | os.PathLike | FontPath, | |
| 145 | - hinting_factor: int | None = ..., | ||
| 146 | 145 | ) -> ft2font.FT2Font: ... | |
| 147 | 146 | ||
| 148 | 147 | fontManager: FontManager | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -236,7 +236,6 @@ class FT2Font(Buffer): | |||
| 236 | 236 | def __init__( | |
| 237 | 237 | self, | |
| 238 | 238 | filename: str | bytes | PathLike | BinaryIO, | |
| 239 | - hinting_factor: int = ..., | ||
| 240 | 239 | *, | |
| 241 | 240 | face_index: int = ..., | |
| 242 | 241 | _fallback_list: list[FT2Font] | None = ..., | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -308,9 +308,7 @@ | |||
| 308 | 308 | ## - no_hinting: Disable hinting. ("none" is a synonym.) | |
| 309 | 309 | #text.hinting: default | |
| 310 | 310 | ||
| 311 | - #text.hinting_factor: 1 # Specifies the amount of softness for hinting in the | ||
| 312 | - # horizontal direction. A value of 1 will hint to full | ||
| 313 | - # pixels. A value of 2 will hint to half pixels etc. | ||
| 311 | + #text.hinting_factor: None # This setting does nothing and is deprecated. | ||
| 314 | 312 | #text.kerning_factor: None # Specifies the scaling factor for kerning values. Values | |
| 315 | 313 | # other than 0, 6, or None have no defined meaning. | |
| 316 | 314 | # This setting is deprecated. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments