PowerToys icon indicating copy to clipboard operation
PowerToys copied to clipboard

Add 'Points' as a unit of measure in Screen Ruler

Open ThanhNguyxn opened this issue 3 weeks ago • 1 comments

Summary of the Pull Request

This PR adds "Points" (pt) as a new measurement unit option in Screen Ruler, addressing the feature request in #39464.

Points are a standard unit in typography and design, where 1 point = 1/72 inch. This is particularly useful for developers working with WPF/XAML measurements, font sizes, and design specifications.

PR Checklist

  • [x] Closes: #39464
  • [x] Communication: I've discussed this with core contributors already. If work hasn't been agreed, this may be closed
  • [x] Tests: Added/Passed
  • [x] Accessibility: Ensured accessibility standards are met
  • [x] Documentation: Added documentation if needed
  • [x] Localization: Localized resource strings added

Detailed Description of the Pull Request / Additional comments

Changes Made:

  1. Measurement.h

    • Added Point = 16 to the Measurement::Unit enum
    • Increased abbreviations array size from 4 to 5
  2. Measurement.cpp

    • Added Point conversion logic:
      • With physical DPI: pixels * px2mmRatio / 10.0f / 2.54f * 72.0f
      • Without physical DPI: pixels / 96.0f * 72.0f (assumes 96 DPI)
    • Added Point case to GetUnitFromIndex() (index 4)
    • Added Point abbreviation loading in InitResources()
    • Added Point case to GetUnitAbbreviation()
    • Added Point to allUnits array for Print function
  3. MeasureToolUI Resources.resw

    • Added MeasurementUnitAbbrPoint with value "pt"
  4. MeasureToolPage.xaml

    • Added new ComboBoxItem for Points option
  5. Settings.UI Resources.resw

    • Added MeasureTool_UnitsOfMeasure_Points.Content with value "Points"

Validation:

The implementation follows the existing patterns for other measurement units (Pixels, Inches, Centimeters, Millimeters) and maintains consistency with the codebase.

ThanhNguyxn avatar Dec 03 '25 08:12 ThanhNguyxn

@microsoft-github-policy-service agree

ThanhNguyxn avatar Dec 03 '25 08:12 ThanhNguyxn