Skip to content

Potentially inaccurate surrogate pair detection #59513

Closed

Description

@justinmc

@HansMuller brought up that our _isUtf16Surrogate method in text_painter.dart is potentially inaccurate. See the Wikipedia definition of surrogate pair.

bool _isUtf16Surrogate(int value) {

Activity

  1. self-assigned this
    on Jun 15, 2020
  2. lrhn commented on Jun 17, 2020

    @lrhn
    Contributor

    The code is correct for what its name says it does: Surrogate detection. If the input is a UTF-16 code unit. The & 0xF800 maps every integer in the range 0xD800 through 0xDFFF to 0xD800.

    The only issue would be if the value was not in the range 0..0xFFFF, which means that ti's not a UTF-16 code unit. In that case you can use & ~0x7FF instead. It's probably just as efficient.

    The documentation seems to suggest that it can detect multi-codeunit glyphs. That is not correct, "e\u0301" or "\r\n" are multi-character glyphs that do not use surrogates.

  3. justinmc commented on Jun 18, 2020

    @justinmc
    ContributorAuthor

    Note to self: see also #53381 (comment).

  4. github-actions commented on Aug 19, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  5. locked as resolved and limited conversation to collaborators on Aug 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

a: typographyText rendering, possibly libtxtframeworkflutter/packages/flutter repository. See also f: labels.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions