Halfist
Halfist

Reputation: 540

Selected text font detection

The problem is next:

  1. I have an empty textarea.
  2. Then I paste some outside text inside it with specific font.
  3. I select (highlight) some part of this text.
  4. I need to detect, what is the font of the selection.

Note, that textarea's text is plain, there is no HTML formatting inside it.

Upvotes: 0

Views: 133

Answers (1)

Tom Gaulton
Tom Gaulton

Reputation: 393

A textarea will only render in the font the page specifies, so you could get the font using jQuery by doing something like:

var font = $("textarea").css("font-family");

However it sounds like you want to know the font that the text was in originally. Unfortunately that isn't possible as the font information is lost when pasting into the browser.

Upvotes: 1

Related Questions