Closed Bug 760048 Opened 12 years ago Closed 11 years ago

API for getting font used by element

Categories

(Core :: Layout: Text and Fonts, defect)

defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: harth, Unassigned)

References

Details

We have DOMUtils.getUsedFontFaces(range) from bug 467669, but what devtools needs for bug 702581 is the single font used by an element (really element+pseudo-element combination).

The difference between this and getUsedFontFaces() can be seen in this example:

```
<div id="description">
  <span id="child">Some Text</span>
</div>

#description {
  font-family: Futura, Helvetica, sans-serif;
}

#child {
  font-family: Georgia, serif;
}
```

getUsedFontFaces(description) would return ["Georgia"]. But what this API should return is "Helvetica".
Don't you mean "Futura"? Or were you assuming it's not present on the system?

With the same styles, what about a case like:
  <div id="description">
    <span id="child">你好</span>
  </div>
Is it helpful to return "Futura" (or "Helvetica") when that's not actually being used for the content (because it doesn't include the necessary characters)?
(In reply to Jonathan Kew (:jfkthame) from comment #1)
> Don't you mean "Futura"? Or were you assuming it's not present on the system?

Sorry, that's assuming Futura isn't present on the system.

> 
> With the same styles, what about a case like:
>   <div id="description">
>     <span id="child">你好</span>
>   </div>
> Is it helpful to return "Futura" (or "Helvetica") when that's not actually
> being used for the content (because it doesn't include the necessary
> characters)?

It would return whatever font would actually be used if there was a text node that was a direct child of that element.

Ideally it would even express which part of the font-family listing was used (e.g. "sans-serif").
> It would return whatever font would actually be used if there was a text node that was a
> direct child of that element.

Which font is used is determined on a per-character basis; see comment 1.  That is, which font is used would depend on the exact contents of the textnode, and might be different for different parts of the textnode...

As far as I can tell, bug 702581 is based on a fundamental misunderstanding of how font fallback works.  :(
Blocks: 702581
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.