First off, please try to avoid cross-posting (if you're not sure where 
to post, just pick one group and go with it.).

srivani wrote:
> document.defaultView.getComputedStyle(node, "").fontFamily
> should work (translated into the language of your choice, of course).
> 
> However I could not find any equivalent API in c++ for getting the
> font-family info out of a text node(or text content node).

Translated into the language of your choice:
nsCOMPtr<nsIDOMDocumentView> docView = do_QueryInterface(document);
nsCOMPtr<nsIDOMAbstractView> defaultView;
docView->GetDefaultView(getter_AddRefs(defaultView));
nsCOMPtr<nsIDOMViewCSS> cssView = do_QueryInterface(defaultView);
nsCOMPtr<nsIDOMCSSStyleDeclaration> cssDecl;
cssView->GetComputedStyle(element, "", getter_AddRefs(cssDecl));
nsString fontFamily;
cssDecl->GetPropertyValue("font-family", fontFamily);
where document is an nsIDOMDocument and element is an nsIDOMElement.

(uncompiled/tested; it's at least close to correct, though.)

Of course, this won't actually tell you what font ends up being used. 
Font selection is buried deep in the graphics code, and isn't exposed 
anywhere.
_______________________________________________
dev-tech-layout mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-layout

Reply via email to