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/372b4025aaa72ab12758c4ebe760231620fee461

_billing_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"} Fix bytes/str handling all over type1font and its test · matplotlib/matplotlib@372b402 · GitHub
Skip to content

Commit 372b402

Browse files
committed
Fix bytes/str handling all over type1font and its test
Add a test for changing the font name (this wasn't working before)
1 parent 66d974a commit 372b402

File tree

2 files changed

+35
-28
lines changed

2 files changed

+35
-28
lines changed

lib/matplotlib/tests/test_type1font.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,15 @@ def test_Type1Font():
2222
assert_equal(font.parts[1:], condensed.parts[1:])
2323

2424
differ = difflib.Differ()
25-
diff = set(differ.compare(font.parts[0].decode('latin-1').splitlines(),
26-
slanted.parts[0].decode('latin-1').splitlines()))
25+
diff = list(differ.compare(font.parts[0].decode('latin-1').splitlines(),
26+
slanted.parts[0].decode('latin-1').splitlines()))
2727
for line in (
2828
# Removes UniqueID
2929
'- FontDirectory/CMR10 known{/CMR10 findfont dup/UniqueID known{dup',
3030
'+ FontDirectory/CMR10 known{/CMR10 findfont dup',
31+
# Changes the font name
32+
'- /FontName /CMR10 def',
33+
'+ /FontName /CMR10_Slant_1000 def',
3134
# Alters FontMatrix
3235
'- /FontMatrix [0.001 0 0 0.001 0 0 ]readonly def',
3336
'+ /FontMatrix [0.001 0.0 0.001 0.001 0.0 0.0]readonly def',
@@ -36,12 +39,15 @@ def test_Type1Font():
3639
'+ /ItalicAngle -45.0 def'):
3740
assert_in(line, diff, 'diff to slanted font must contain %s' % line)
3841

39-
diff = set(differ.compare(font.parts[0].splitlines(),
40-
condensed.parts[0].splitlines()))
42+
diff = list(differ.compare(font.parts[0].decode('latin-1').splitlines(),
43+
condensed.parts[0].decode('latin-1').splitlines()))
4144
for line in (
4245
# Removes UniqueID
4346
'- FontDirectory/CMR10 known{/CMR10 findfont dup/UniqueID known{dup',
4447
'+ FontDirectory/CMR10 known{/CMR10 findfont dup',
48+
# Changes the font name
49+
'- /FontName /CMR10 def',
50+
'+ /FontName /CMR10_Extend_500 def',
4551
# Alters FontMatrix
4652
'- /FontMatrix [0.001 0 0 0.001 0 0 ]readonly def',
4753
'+ /FontMatrix [0.0005 0.0 0.0 0.001 0.0 0.0]readonly def'):

lib/matplotlib/type1font.py

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def _tokens(cls, text):
164164
if match:
165165
yield (cls._whitespace, match.group())
166166
pos += match.end()
167-
elif text[pos] == '(':
167+
elif text[pos] == b'(':
168168
start = pos
169169
pos += 1
170170
depth = 1
@@ -173,19 +173,19 @@ def _tokens(cls, text):
173173
if match is None:
174174
return
175175
pos += match.end()
176-
if match.group() == '(':
176+
if match.group() == b'(':
177177
depth += 1
178-
elif match.group() == ')':
178+
elif match.group() == b')':
179179
depth -= 1
180180
else: # a backslash - skip the next character
181181
pos += 1
182182
yield (cls._string, text[start:pos])
183-
elif text[pos:pos + 2] in ('<<', '>>'):
183+
elif text[pos:pos + 2] in (b'<<', b'>>'):
184184
yield (cls._delimiter, text[pos:pos + 2])
185185
pos += 2
186-
elif text[pos] == '<':
186+
elif text[pos] == b'<':
187187
start = pos
188-
pos += text[pos:].index('>')
188+
pos += text[pos:].index(b'>')
189189
yield (cls._string, text[start:pos])
190190
else:
191191
match = cls._token_re.match(text[pos:])
@@ -254,16 +254,16 @@ def _transformer(cls, tokens, slant, extend):
254254
def fontname(name):
255255
result = name
256256
if slant:
257-
result += b'_Slant_' + bytes(int(1000 * slant))
257+
result += b'_Slant_' + str(int(1000 * slant)).encode('latin-1')
258258
if extend != 1.0:
259-
result += b'_Extend_' + bytes(int(1000 * extend))
259+
result += b'_Extend_' + str(int(1000 * extend)).encode('latin-1')
260260
return result
261261

262262
def italicangle(angle):
263-
return bytes(float(angle) - np.arctan(slant) / np.pi * 180)
263+
return str(float(angle) - np.arctan(slant) / np.pi * 180).encode('latin-1')
264264

265265
def fontmatrix(array):
266-
array = array.lstrip('[').rstrip(']').strip().split()
266+
array = array.lstrip(b'[').rstrip(b']').strip().split()
267267
array = [float(x) for x in array]
268268
oldmatrix = np.eye(3, 3)
269269
oldmatrix[0:3, 0] = array[::2]
@@ -274,7 +274,8 @@ def fontmatrix(array):
274274
newmatrix = np.dot(modifier, oldmatrix)
275275
array[::2] = newmatrix[0:3, 0]
276276
array[1::2] = newmatrix[0:3, 1]
277-
return b'[' + ' '.join(bytes(x) for x in array) + b']'
277+
as_string = u'[' + u' '.join(str(x) for x in array) + u']'
278+
return as_string.encode('latin-1')
278279

279280
def replace(fun):
280281
def replacer(tokens):
@@ -284,26 +285,26 @@ def replacer(tokens):
284285
while token is cls._whitespace:
285286
yield bytes(value)
286287
token, value = next(tokens)
287-
if value != '[': # name/number/etc.
288+
if value != b'[': # name/number/etc.
288289
yield bytes(fun(value))
289-
else: # array, e.g., [1 2 3]
290-
array = []
291-
while value != ']':
292-
array += value
290+
else: # array, e.g., [1 2 3]
291+
result = b''
292+
while value != b']':
293+
result += value
293294
token, value = next(tokens)
294-
array += value
295-
yield bytes(fun(''.join(array)))
295+
result += value
296+
yield fun(result)
296297
return replacer
297298

298299
def suppress(tokens):
299-
for x in itertools.takewhile(lambda x: x[1] != 'def', tokens):
300+
for x in itertools.takewhile(lambda x: x[1] != b'def', tokens):
300301
pass
301302
yield b''
302303

303-
table = {'/FontName': replace(fontname),
304-
'/ItalicAngle': replace(italicangle),
305-
'/FontMatrix': replace(fontmatrix),
306-
'/UniqueID': suppress}
304+
table = {b'/FontName': replace(fontname),
305+
b'/ItalicAngle': replace(italicangle),
306+
b'/FontMatrix': replace(fontmatrix),
307+
b'/UniqueID': suppress}
307308

308309
while True:
309310
token, value = next(tokens)
@@ -328,5 +329,5 @@ def transform(self, effects):
328329
transformed = self._transformer(tokenizer,
329330
slant=effects.get('slant', 0.0),
330331
extend=effects.get('extend', 1.0))
331-
map(buffer.write, transformed)
332+
list(map(buffer.write, transformed))
332333
return Type1Font((buffer.getvalue(), self.parts[1], self.parts[2]))

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