Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upUppercase strings rather than chars for small-caps #5938
Labels
Comments
Merged
bors-servo
added a commit
that referenced
this issue
Jan 4, 2018
Uppercase strings rather than chars for small-caps <!-- Please describe your changes on the following line: --> use `str::to_uppercase` earlier in the code, rather than doing individual chars. --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #5938(github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19678) <!-- Reviewable:end -->
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently,
font-variant: small-capsis implemented with synthesized small caps: transform the text to upper case and use a smaller font size.gfx::font::glyph_indexcontains code likecodepoint.to_uppercase().next().unwrap()to find the upper case of a single code point..next().unwrap()takes the firstcharin the iterator returned bychar::to_uppercaseand drops the rest.This is OK at the moment since the iterator always of length 1. But in the future, it will do complex case mapping and may yield more than one char, and the rest should not be dropped. See rust-lang/rust#23126
The small-caps implementation should probably use
str::to_uppercaseearlier in the code, before considering individualchars.However it may not be as easy as upper-casing entire text nodes, we only want to reduce the font size of things that were previously lower-case.