ZhgChgLi / ZMarkupParser

ZMarkupParser is a pure-Swift library that helps you convert HTML strings into NSAttributedString with customized styles and tags.
https://zhgchg.li
MIT License
294 stars 23 forks source link

Fix incorrect font-weight mapping based on Mozilla documentation #35

Closed 5anniversary closed 1 year ago

5anniversary commented 1 year ago

Summary

This PR aims to fix the incorrect mapping of font-weight values in the switch statement. The original implementation had an issue where UIFont.Weight.medium.rawValue would incorrectly map to a bold weight due to the raw value being 0.23000000417232513.

Changes

Why this is important

The issue can cause unexpected behavior in text rendering, especially when comparing UIFont.Weight.medium.rawValue and weight.rawValue.

Test Plan

  1. Validate the new font-weight values against Mozilla's documentation.
  2. Run existing unit tests to ensure no regressions.
  3. Add new unit tests to confirm the correct mapping of font-weight values.

Checklist