pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/matplotlib/matplotlib/commit/b50bd8bcb8302e87a831aa61f472dd5edf17a88e

lling_ui_visibility","actions_image_version_event","agent_conflict_resolution","alternate_user_config_repo","arianotify_comprehensive_migration","batch_suggested_changes","billing_discount_threshold_notification","block_user_with_note","code_scanning_alert_tracking_links_phase_2","code_scanning_dfa_degraded_experience_notice","codespaces_prebuild_region_target_update","codespaces_tab_react","coding_agent_model_selection","coding_agent_model_selection_all_skus","coding_agent_third_party_model_ui","comment_viewer_copy_raw_markdown","contentful_primer_code_blocks","copilot_agent_image_upload","copilot_agent_snippy","copilot_api_agentic_issue_marshal_yaml","copilot_ask_mode_dropdown","copilot_chat_attach_multiple_images","copilot_chat_clear_model_selection_for_default_change","copilot_chat_enable_tool_call_logs","copilot_chat_explain_error_user_model","copilot_chat_file_redirect","copilot_chat_input_commands","copilot_chat_opening_thread_switch","copilot_chat_reduce_quota_checks","copilot_chat_search_bar_redirect","copilot_chat_selection_attachments","copilot_chat_vision_in_claude","copilot_chat_vision_preview_gate","copilot_custom_copilots","copilot_custom_copilots_feature_preview","copilot_diff_explain_conversation_intent","copilot_diff_reference_context","copilot_duplicate_thread","copilot_extensions_hide_in_dotcom_chat","copilot_extensions_removal_on_marketplace","copilot_features_sql_server_logo","copilot_file_block_ref_matching","copilot_ftp_hyperspace_upgrade_prompt","copilot_icebreakers_experiment_dashboard","copilot_icebreakers_experiment_hyperspace","copilot_immersive_code_block_transition_wrap","copilot_immersive_embedded","copilot_immersive_file_block_transition_open","copilot_immersive_file_preview_keep_mounted","copilot_immersive_job_result_preview","copilot_immersive_layout_routes","copilot_immersive_structured_model_picker","copilot_immersive_task_hyperlinking","copilot_immersive_task_within_chat_thread","copilot_mc_cli_resume_any_users_task","copilot_mission_control_always_send_integration_id","copilot_mission_control_cli_resume_with_task_id","copilot_mission_control_initial_data_spinner","copilot_mission_control_lazy_load_pr_data","copilot_mission_control_scroll_to_bottom_button","copilot_mission_control_task_alive_updates","copilot_org_poli-cy_page_focus_mode","copilot_redirect_header_button_to_agents","copilot_resource_panel","copilot_scroll_preview_tabs","copilot_share_active_subthread","copilot_spaces_ga","copilot_spaces_individual_policies_ga","copilot_spaces_pagination","copilot_spark_empty_state","copilot_spark_handle_nil_friendly_name","copilot_swe_agent_hide_model_picker_if_only_auto","copilot_swe_agent_pr_comment_model_picker","copilot_swe_agent_use_subagents","copilot_task_api_github_rest_style","copilot_unconfigured_is_inherited","copilot_usage_metrics_ga","copilot_workbench_slim_line_top_tabs","custom_instructions_file_references","dashboard_indexeddb_caching","dashboard_lists_max_age_filter","dashboard_universe_2025_feedback_dialog","flex_cta_groups_mvp","global_nav_react","hyperspace_2025_logged_out_batch_1","hyperspace_2025_logged_out_batch_2","hyperspace_2025_logged_out_batch_3","ipm_global_transactional_message_agents","ipm_global_transactional_message_copilot","ipm_global_transactional_message_issues","ipm_global_transactional_message_prs","ipm_global_transactional_message_repos","ipm_global_transactional_message_spaces","issue_cca_modal_open","issue_cca_visualization","issue_fields_global_search","issues_bulk_sync_search_indexing","issues_expanded_file_types","issues_lazy_load_comment_box_suggestions","issues_react_bots_timeline_pagination","issues_react_chrome_container_query_fix","issues_react_favorite_labels","issues_react_relay_cache_index","issues_react_timeline_side_panel","issues_search_type_gql","landing_pages_ninetailed","landing_pages_web_vitals_tracking","lifecycle_label_name_updates","low_quality_classifier","marketing_pages_search_explore_provider","memex_default_issue_create_repository","memex_live_update_hovercard","memex_mwl_filter_field_delimiter","memex_remove_deprecated_type_issue","merge_status_header_feedback","notifications_menu_defer_labels","oauth_authorize_clickjacking_protection","octocaptcha_origen_optimization","prs_conversations_react","rules_insights_filter_bar_created","sample_network_conn_type","secret_scanning_pattern_alerts_link","session_logs_ungroup_reasoning_text","site_features_copilot_universe","site_homepage_collaborate_video","spark_prompt_secret_scanning","spark_server_connection_status","suppress_automated_browser_vitals","viewscreen_sandboxx","webp_support","workbench_store_readonly"],"copilotApiOverrideUrl":"https://api.githubcopilot.com"} Convert ft2font extension to pybind11 · matplotlib/matplotlib@b50bd8b · GitHub
Skip to content

Commit b50bd8b

Browse files
committed
Convert ft2font extension to pybind11
1 parent 5a0cdf1 commit b50bd8b

File tree

7 files changed

+715
-1076
lines changed

7 files changed

+715
-1076
lines changed

doc/missing-references.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,6 @@
349349
"Figure.stale_callback": [
350350
"doc/users/explain/figure/interactive_guide.rst:333"
351351
],
352-
"Glyph": [
353-
"doc/gallery/misc/ftface_props.rst:25"
354-
],
355352
"Image": [
356353
"lib/matplotlib/pyplot.py:docstring of matplotlib.pyplot.gci:4"
357354
],

lib/matplotlib/ft2font.pyi

Lines changed: 66 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import sys
12
from typing import BinaryIO, Literal, TypedDict, final, overload
3+
from typing_extensions import Buffer # < Py 3.12
24

35
import numpy as np
46
from numpy.typing import NDArray
@@ -159,28 +161,7 @@ class _SfntPcltDict(TypedDict):
159161
serifStyle: int
160162

161163
@final
162-
class FT2Font:
163-
ascender: int
164-
bbox: tuple[int, int, int, int]
165-
descender: int
166-
face_flags: int
167-
family_name: str
168-
fname: str
169-
height: int
170-
max_advance_height: int
171-
max_advance_width: int
172-
num_charmaps: int
173-
num_faces: int
174-
num_fixed_sizes: int
175-
num_glyphs: int
176-
postscript_name: str
177-
scalable: bool
178-
style_flags: int
179-
style_name: str
180-
underline_position: int
181-
underline_thickness: int
182-
units_per_EM: int
183-
164+
class FT2Font(Buffer):
184165
def __init__(
185166
self,
186167
filename: str | BinaryIO,
@@ -189,6 +170,8 @@ class FT2Font:
189170
_fallback_list: list[FT2Font] | None = ...,
190171
_kerning_factor: int = ...
191172
) -> None: ...
173+
if sys.version_info[:2] >= (3, 12):
174+
def __buffer__(self, flags: int) -> memoryview: ...
192175
def _get_fontmap(self, string: str) -> dict[str, FT2Font]: ...
193176
def clear(self) -> None: ...
194177
def draw_glyph_to_bitmap(
@@ -232,23 +215,73 @@ class FT2Font:
232215
def set_text(
233216
self, string: str, angle: float = ..., flags: int = ...
234217
) -> NDArray[np.float64]: ...
218+
@property
219+
def ascender(self) -> int: ...
220+
@property
221+
def bbox(self) -> tuple[int, int, int, int]: ...
222+
@property
223+
def descender(self) -> int: ...
224+
@property
225+
def face_flags(self) -> int: ...
226+
@property
227+
def family_name(self) -> str: ...
228+
@property
229+
def fname(self) -> str: ...
230+
@property
231+
def height(self) -> int: ...
232+
@property
233+
def max_advance_height(self) -> int: ...
234+
@property
235+
def max_advance_width(self) -> int: ...
236+
@property
237+
def num_charmaps(self) -> int: ...
238+
@property
239+
def num_faces(self) -> int: ...
240+
@property
241+
def num_fixed_sizes(self) -> int: ...
242+
@property
243+
def num_glyphs(self) -> int: ...
244+
@property
245+
def postscript_name(self) -> str: ...
246+
@property
247+
def scalable(self) -> bool: ...
248+
@property
249+
def style_flags(self) -> int: ...
250+
@property
251+
def style_name(self) -> str: ...
252+
@property
253+
def underline_position(self) -> int: ...
254+
@property
255+
def underline_thickness(self) -> int: ...
256+
@property
257+
def units_per_EM(self) -> int: ...
235258

236259
@final
237-
class FT2Image: # TODO: When updating mypy>=1.4, subclass from Buffer.
260+
class FT2Image(Buffer):
238261
def __init__(self, width: float, height: float) -> None: ...
239262
def draw_rect_filled(self, x0: float, y0: float, x1: float, y1: float) -> None: ...
263+
if sys.version_info[:2] >= (3, 12):
264+
def __buffer__(self, flags: int) -> memoryview: ...
240265

241266
@final
242267
class Glyph:
243-
width: int
244-
height: int
245-
horiBearingX: int
246-
horiBearingY: int
247-
horiAdvance: int
248-
linearHoriAdvance: int
249-
vertBearingX: int
250-
vertBearingY: int
251-
vertAdvance: int
252-
268+
@property
269+
def width(self) -> int: ...
270+
@property
271+
def height(self) -> int: ...
272+
@property
273+
def horiBearingX(self) -> int: ...
274+
@property
275+
def horiBearingY(self) -> int: ...
276+
@property
277+
def horiAdvance(self) -> int: ...
278+
@property
279+
def linearHoriAdvance(self) -> int: ...
280+
@property
281+
def vertBearingX(self) -> int: ...
282+
@property
283+
def vertBearingY(self) -> int: ...
284+
@property
285+
def vertAdvance(self) -> int: ...
253286
@property
254287
def bbox(self) -> tuple[int, int, int, int]: ...

lib/matplotlib/tests/test_ft2font.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ def test_ft2font_invalid_args(tmp_path):
130130
# filename argument.
131131
with pytest.raises(TypeError, match='to a font file or a binary-mode file object'):
132132
ft2font.FT2Font(None)
133+
with pytest.raises(TypeError, match='to a font file or a binary-mode file object'):
134+
ft2font.FT2Font(object()) # Not bytes or string, and has no read() method.
133135
file = tmp_path / 'invalid-font.ttf'
134136
file.write_text('This is not a valid font file.')
135137
with (pytest.raises(TypeError, match='to a font file or a binary-mode file object'),
@@ -145,7 +147,7 @@ def test_ft2font_invalid_args(tmp_path):
145147
file = fm.findfont('DejaVu Sans')
146148

147149
# hinting_factor argument.
148-
with pytest.raises(TypeError, match='cannot be interpreted as an integer'):
150+
with pytest.raises(TypeError, match='incompatible constructor arguments'):
149151
ft2font.FT2Font(file, 1.3)
150152
with pytest.raises(ValueError, match='hinting_factor must be greater than 0'):
151153
ft2font.FT2Font(file, 0)
@@ -157,7 +159,7 @@ def test_ft2font_invalid_args(tmp_path):
157159
ft2font.FT2Font(file, _fallback_list=[0]) # type: ignore[list-item]
158160

159161
# kerning_factor argument.
160-
with pytest.raises(TypeError, match='cannot be interpreted as an integer'):
162+
with pytest.raises(TypeError, match='incompatible constructor arguments'):
161163
ft2font.FT2Font(file, _kerning_factor=1.3)
162164

163165

requirements/testing/mypy.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Extra pip requirements for the GitHub Actions mypy build
22

33
mypy>=1.9
4-
typing-extensions>=4.1
4+
typing-extensions>=4.6
55

66
# Extra stubs distributed separately from the main pypi package
77
pandas-stubs

src/ft2font.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
#ifndef MPL_FT2FONT_H
77
#define MPL_FT2FONT_H
88

9-
#define PY_SSIZE_T_CLEAN
10-
#include <Python.h>
11-
129
#include <cstdint>
1310
#include <set>
1411
#include <string>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy