Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

textSplit should not filter out all emoji unicode chars #107

Open
snowyu opened this issue May 10, 2019 · 1 comment
Open

textSplit should not filter out all emoji unicode chars #107

snowyu opened this issue May 10, 2019 · 1 comment

Comments

@snowyu
Copy link

snowyu commented May 10, 2019

Expected Behavior

The default textSplit function should display all emoji unicode characters: "πŸ‰οΈπŸ§šπŸ»β€β™€οΈπŸ§šπŸ»β€β™‚οΈ".
and the Chinsese quotation marks β€œβ€.

Current Behavior

All emoji and Chinese quotation marks unicode chars are filtered out.

Maybe It is related to #94 too.

Please use the Unicode Line Breaking Algorithm

Line breaking, also known as word wrapping, is the process of breaking a section of text into lines such that it will fit in the available width of a page, window or other display area. The Unicode Line Breaking Algorithm performs part of this process. Given an input text, it produces a set of positions called "break opportunities" that are appropriate points to begin a new line. The selection of actual line break positions from the set of break opportunities is not covered by the Unicode Line Breaking Algorithm, but is in the domain of higher level software with knowledge of the available width and the display size of the text.

@snowyu
Copy link
Author

snowyu commented May 10, 2019

Workaround:

import {default as LineBreaker} from "@craigmorton/linebreak";
import { textWrap } from 'd3plus-text';

const wrapper = textWrap
  .split(splitStr)
  .width(...);

function splitStr(sentence) {
  const breaker = new LineBreaker(sentence);
  const result = [];
  let bk;
  let lastPos = 0;
  // eslint-disable-next-line no-cond-assign
  while (bk = breaker.nextBreak()) {
    const word = sentence.slice(lastPos, bk.position);
    lastPos = bk.position;
    result.push(word);
  }
  return result;
}

@davelandry davelandry changed the title [bug] the default textSplit should not filter out all emoji unicode chars. textSplit should not filter out all emoji unicode chars May 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants