Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Support 'px' format in lineHeight option#5363

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
Copilot wants to merge3 commits intomaster
base:master
Choose a base branch
Loading
fromcopilot/fix-2612-2

Conversation

Copy link
Contributor

CopilotAI commentedJun 21, 2025
edited
Loading

This PR adds support for specifyinglineHeight using pixel values with the 'px' suffix, while maintaining full backward compatibility with existing numeric multiplier format.

Problem

Previously, users could only specifylineHeight as a numeric multiplier (e.g.,1.2). When using DOM rendering, users wanted to set exact pixel values but had to manually calculate the multiplier:

// Before: Want 23px line height with 16px character height// Had to calculate: 23 ÷ 16 = 1.4375constterm=newTerminal({lineHeight:1.4375});

This was unintuitive and error-prone, especially when the character height changed.

Solution

NowlineHeight accepts both formats:

// Existing numeric format (unchanged)constterm1=newTerminal({lineHeight:1.2});// New px formatconstterm2=newTerminal({lineHeight:'24px'});

Implementation

  • Type System: Updated public and headless APIs to acceptlineHeight?: number | string
  • Validation: EnhancedOptionsService to validate both formats with proper error handling
  • Renderers: Added sharedcalculateLineHeightInPixels() utility function for both DOM and WebGL renderers
  • Safety: Enforces minimum values (≥1 for numeric, ≥1px for string, but also ≥ character height)
  • WebGL Compatibility: Maintains char atlas compatibility by converting px values to multipliers when needed

Testing

  • All existing tests pass (2242 passing)
  • Added comprehensive test coverage for new functionality
  • Validates both valid and invalid inputs
  • Tests calculation logic for edge cases

Examples

// Numeric multipliers (existing behavior)newTerminal({lineHeight:1.0});// 16px char → 16px line heightnewTerminal({lineHeight:1.2});// 16px char → 19px line heightnewTerminal({lineHeight:1.5});// 16px char → 24px line height// Pixel values (new feature)newTerminal({lineHeight:'20px'});// Always 20px line heightnewTerminal({lineHeight:'23px'});// Always 23px line heightnewTerminal({lineHeight:'25px'});// Always 25px line height// Minimum enforcementnewTerminal({lineHeight:'10px'});// 16px char → 16px line height (minimum)

Fixes#2612.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Clickhere to start the survey.

CopilotAIand others added2 commitsJune 21, 2025 18:19
Co-authored-by: Tyriar <2193314+Tyriar@users.noreply.github.com>
Co-authored-by: Tyriar <2193314+Tyriar@users.noreply.github.com>
CopilotAI changed the title[WIP] Support 'px' format in lineHeight optionSupport 'px' format in lineHeight optionJun 21, 2025
CopilotAI requested a review fromTyriarJune 21, 2025 18:24
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@TyriarTyriarAwaiting requested review from Tyriar

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Support 'px' format in lineHeight option

2 participants

@Tyriar

[8]ページ先頭

©2009-2025 Movatter.jp