[JS][CS4]List fonts used in the Document

Hi to all scripting gurus,
I have this following script that returns a list of fonts used in the document:
function fontused(){               var fontscoll = document.fonts;               for(var i = 0; i < fontscoll.length; i++){                       var font = fontscoll[i];                       alert(font.name);                } }
The above is working OK my problem is that it also list the fonts used in the placed illustrator files (.eps). Is there some kind of parameter or something that i can use so that it only list the fonts used in the text?
-CharlesD

Charles
Doesn't time fly?
This will give you the idea, if when you find more exceptions add them in a likewise manner.
The "if" statements check that tables, headers, etc. exists otherwise an error will be throw.
Enjoy
Trevor
P.s. I had planned on updating the script after David highlighted the problem, just didn't get round to it.
// Script to find fonts in documents which are not just in content pasted from illustrator file
// By Trevor http://forums.adobe.com/message/4807396#4807396
var   myFonts="",
        uniqueFonts = {}, n;
if (app.documents[0].stories.everyItem().textStyleRanges.length > 0) fontsIn (app.documents[0].stories.everyItem().textStyleRanges.everyItem().appliedFont)       
if (app.documents[0].stories.everyItem().tables.length > 0) fontsIn (app.documents[0].stories.everyItem().tables.everyItem().cells.everyItem().textStyleRanges.everyItem().appliedFont)
if (app.documents[0].stories.everyItem().footnotes.length > 0) fontsIn (app.documents[0].stories.everyItem().footnotes.everyItem().textStyleRanges.everyItem().appliedFont)
for (n in uniqueFonts) myFonts+=(uniqueFonts[n])+"\r";
alert(myFonts)
function fontsIn (item)
        var l = item.length;
        while (l--) uniqueFonts[item[l].name] = item[l].name;

Similar Messages

  • List fonts used in a document, search by font.

    Help! I cannot find a way to list, by name, of the fonts used (past tense) in a document. Like in the document properties: where the word and character count is.
    Example: The author used Arial, Arial Condensed and OCR A in her document. I would like to see a list of three font names. If I have (or don't have) those fonts is outside the scope of this request.
    Simply smashing the styles of a document and then restylng by hand is not working so well for me. Most of the documents used manual formatting instead of styles too!
    Second: I can search and replace text if it had a font applied to it, but I cannot specify the font to search on. ANY font will be match and changed to the 'replace' style. Any solution?
    Thanks!
    John Fields

    Interesting request and a bit of a programing challenge but here is what I have come up with. Try it on some of the documents that you need to deal with and let me know how it does.
    Sub FontsUsed 'Version 1 John Vigor 4/25/06
    'List fonts used in Writer document. Appears to work in normal text,
    'Sections, normal Tables, and Frames. Will currently crash on a Table
    'within a Table.
    oDoc = ThisComponent
    Dim fonts as Integer: Dim aFonts(1)
    oTC = oDoc.Text.createTextCursor
    oTC.goRight(1,true) : CurrentFont = oTC.charFontName
    fonts = fonts + 1 : aFonts(fonts) = CurrentFont
    REM Do "normal" text.
    partEnum = oDoc.Text.createEnumeration
    PartEnumerator(partEnum,CurrentFont,fonts,aFonts())
    REM Do Frames.
    oFrames = oDoc.getTextFrames
    If oFrames.Count > 0 then
    fonts = fonts + 1 : ReDim Preserve aFonts(fonts)
    aFonts(fonts) = "NEW FONTS, IF ANY, FOUND IN FRAMES:"
    For I = 0 to oFrames.Count - 1
      thisFrame = oFrames.getByIndex(I)
      partEnum = thisFrame.createEnumeration
      PartEnumerator(partEnum,CurrentFont,fonts,aFonts())
    Next
    EndIf
    REM Prepare list.
    For I = 1 to fonts
    s = s & aFonts(I) & Chr(10)
    Next
    iAns = MsgBox(s,4,"FONTS FOUND. Create font list document?")
    If iAns = 7 then
      End
    Else
      NewDoc = StarDesktop.loadComponentFromURL("private:factory/swriter"," blank",O,Array())
      oVC = NewDoc.CurrentController.getViewCursor
      oVC.String = s : oVC.collapseToEnd
    EndIf  
    End Sub
    Sub PartEnumerator(partEnum,CurrentFont,fonts,aFonts())
    While partEnum.hasMoreElements
    thisElement = partEnum.nextElement
    If thisElement.supportsService("com.sun.star.text.Paragraph") then
       portionEnum = thisElement.createEnumeration
       PortionEnumerator(portionEnum,CurrentFont,fonts,aFonts())
      ElseIf thisElement. supportsService ("com.sun.star.text.TextTab le") then
       Cols = thisElement.getColumns.Count - 1
       Rows = thisElement.getRows.Count - 1
       For C = 0 to Cols
        For R = 0 to Rows
         thisCell = thisElement.getCellByPosition(C,R)
         cellEnum = thisCell.createEnumeration
         While cellEnum.hasMoreElements
          thisPara = cellEnum.nextElement
          portionEnum = thisPara.createEnumeration
          PortionEnumerator(portionEnum,CurrentFont,fonts,aFonts())
         Wend
        Next
       Next
    EndIf
    Wend
    End Sub
    Sub PortionEnumerator(portionEnum,CurrentFont,fonts,aFonts())
    Dim found as Boolean
    While portionEnum.hasMoreElements
    thisPortion = portionEnum.nextElement
    thisFont = thisPortion.charFontName
    If thisFont <> CurrentFont then
      For I = 1 to fonts
       If aFonts(I) = thisFont then found = true: Exit For
      Next
      If found then
       CurrentFont = thisFont : found = false Else
       fonts = fonts + 1 : ReDim Preserve aFonts(fonts)
       aFonts(fonts) = thisFont : CurrentFont = thisFont
      EndIF
    EndIf
    Wend
    End Sub

  • CS2- How to get the fonts used in a document ?

    Hi,
    Can anyone tell how to find the the fonts used in the document directly without iterating through the text art used in the document.BCOZ if i iterate through each text frame or character my plugin works very slowly.I want to speed up the process of finding & replacing the fonts like wat we do manually in the "Type-> Find Font" menu thru my code.
    Please post ur comments on this .If there is no direct option to find &replace the fonts used in the document ,pls let me know the simplest logic of finding & replacing all occurances of a font in a doc so that my process of doing this should be faster.
    Thanks in advance.
    myRiaz

    As far as I know, there's no way to get a list of fonts in use in a document without iterating over the document and compiling a list by asking every piece of art.
    If you want to trigger 'Type > Find Font' there might be a way to invoke that using Actions (AIActionManager.h). I'm not sure if that would help or not though.
    This probably isn't very helpful depending on what you're doing, but I think this is meant to be handled by using character styles. That way you can change a style and update any related text instantly. Not much help though if you're just trying to write a S&R font plugin.

  • Listing all fonts used in a document?

       As I understand it, TextFonts is a collection of all fonts available to Illustraot.  Is there a collection of all fonts used in the open document?  Or would I have to step through every textFrame an create that list myself?

    I don't know why and how you write error log, so I only add a single alert after all. "xmpString" and "XMP library" are two different methods, you only need one of then.
    #target illustrator
    var inputFolder = Folder.selectDialog("Select a folder contains '*.eps' files ");
    if (inputFolder) {
        var fileList = inputFolder.getFiles('*.eps'),
            fontsInfo = [];
        loadXMPLibrary();
        for (var i = 0; i < fileList.length; i++) {
            if (fileList[i] instanceof File && fileList[i].hidden == false) {
                fontsInfo.push(getFontsInfo(fileList[i]));
        unloadXMPLibrary();
    var Loginfo = new File(inputFolder + '/Font.info.txt');
    Loginfo.open('w', 'TEXT', '????');
    var info = fontsInfo.join('\n\n');
    Loginfo.write(info);
    Loginfo.close();
    if (/(Open Type|TrueType)/.test(info)) {
        alert('Open Type / TrueType font found, see log file for details!')
    function getFontsInfo(file) {
        var arr = ['File: ' + decodeURI (file.name)],
            xmpFile, oXmp, fontNumber, i, path, fontname, fonttype, ns = 'http://ns.adobe.com/xap/1.0/t/pg/';
        xmpFile = new XMPFile(file.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_READ);
        oXmp = xmpFile.getXMP(); //Returns an XMPMeta object
        fontNumber = oXmp.countArrayItems(ns, 'xmpTPg:Fonts');
        xmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
        if (fontNumber) { // if there's at least 1 font, proceed
            for (i = 1; i <= fontNumber; i++) {
                path = XMPUtils.composeArrayItemPath(ns, 'xmpTPg:Fonts', i);
                fontname = oXmp.getStructField(ns, path, XMPConst.TYPE_FONT, 'fontName');
                fonttype = oXmp.getStructField(ns, path, XMPConst.TYPE_FONT, 'fontType');
                arr.push([i, '. ', fontname, '-', fonttype].join(''));
        return arr.join('\n');
    function loadXMPLibrary() {
        if (!ExternalObject.AdobeXMPScript) {
            try {
                ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
            } catch (e) {
                alert('Unable to load the AdobeXMPScript library!');
                return false;
        return true;
    function unloadXMPLibrary() {
        if (ExternalObject.AdobeXMPScript) {
            try {
                ExternalObject.AdobeXMPScript.unload();
                ExternalObject.AdobeXMPScript = undefined;
            } catch (e) {
                alert('Unable to unload the AdobeXMPScript library!');

  • I have a MacBook Pro , Model Identifier MacBook Pro8,2 , MAC OX S 10.7.4 I noticed that if I open Final Cut Projects created on other/older models MacBook Pro Laptops or MacPro Desktops, the fonts used in the previously created FCP projects, change their

    I have a MacBook Pro , Model Identifier MacBook Pro8,2 , MAC OX S 10.7.4
    I noticed that if I open Final Cut Projects created on other/older models MacBook Pro Laptops or MacPro Desktops, the fonts used in the previously created FCP projects, change their font spacing! which distorts the look of the Text that was written, by oevrlapping on other things that were put & present on the screen.. Another similar probelm is that the Vector shaped used for example to highlight certain words or shapes, also change their position on the screen so that they no longer highlight exact things that we once used these vectors to highlight or outline... Anyone knows how to solve this problem please?? I made sure that the same fonts are available in the Library in both old and newer computers...
    thanks in advance..

    You might want to take your question to the FCP forum - if you copied all fonts to your Library>Fonts folder and restarted they should be recognized by all applications. I know that this works for Adobe products, anyway.
    Clinton

  • When opening a word document, I get this:The table of contents is empty because none of the paragraph styles selected in the Document Inspector are used in the document. Is there a way to solve this?

    The table of contents is empty because none of the paragraph styles selected in the Document Inspector are used in the document.
    The above is what I get when I open a word document. Is there a way to solve this?

    Hmmm. Apply the styles?
    Peter

  • What is the font used in the buttons in Titanium skin?

    Hello,
    I need to know what the font used for the buttons (Contents,
    Index, etc) in the WebHelp Titanium (RoboHelp 6) skin. I need to
    know because I want to use this skin, and also include a Print
    button.
    Thanks!
    Jennifer Bennett

    Hi Jennifer. If you download the skin and open it in the skin
    editor you'll see the font used next to the "Font" button near the
    bottom r/h/ corner. You can also use the button to change the font
    if you wish.

  • What is the font used at the end of the movie trailer, Blockbuster

    Can anyone tell me the name of the FONT used in the I Movie Trailer called Block Buster?
    I think the opening font says ROADTRIP
    Thanks so much!
    A

    Can you attach a screenshot?
    *http://en.wikipedia.org/wiki/Screenshot
    *https://support.mozilla.org/kb/how-do-i-create-screenshot-my-problem
    Use a compressed image type like PNG or JPG to save the screenshot.
    Is this a toolbar?
    *Firefox menu button > Options
    *View > Toolbars (press F10 to display the hidden Menu bar)
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do NOT click the Reset button on the Safe Mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • List all fonts used in the illustrator document

    Hi All,
    Having searched google I can't seem to find what I am after but am hoping someone here might be able to help me.
    Due to a recent issue with a designer using a font that wasn't part of the brand guidelines for a particular company we would now like to list all fonts that are used in the illustrator file in a media panel on the document when it is sent for both internal and external approval.
    I know that I can go to find font, save the list, open the document and then copy and paste that list in to a text box in Illustrator, however this is quite time consuming and a bit of a faff.
    What I would like to know is:
    1. Does such a plug in exist that will create a text box in illustrator and just list all the fonts automatically, ideally updating whenever fonts are changed?
    2. If not does anyone have a script that I can run that will do the same thing and just drop a list of all fonts currently live in the document in to a text box?
    I will have the same issue when working with Indesign documents to so if anyone one know the answers to the above but all related to indesign that would also be great!
    Thanks everyone!

    I thought about AdjustObjectAIColors, and its a good way to get a bunch of them but I'm not 100% sure if it covers all colours or just those found in paths. If not, this would exclude colours on effects & overlays for symbols, found in kPluginArt (though there is a similar function for plugin art specifically) and I imagine text. Probably a few other types if we look hard enough. Granted, paths are probably 90% of colours :-) I also wondered (sinc I haven't tried it before) how comprehensive that method is -- does it hit all the colours in various effects & styles layered on path? Or does it just hit the standard stroke & fill? I assume not, but I don't know.

  • How to set price list to use in a Document

    Hi all,
    I have a simple question. I'm trying to insert a draft document into SAP B1 via DI API. I can't seem to find the correct property to set in order to change the price list to use for that draft.
    Example: The price list in the Supplier BP is 'Price List 01' and I want to change it only for the current document to 'Price List 02'.
    Can you guys help me?
    Thanks.
    Edited by: Pedro Magueija on Aug 28, 2009 6:11 PM
    Edited by: Pedro Magueija on Aug 28, 2009 6:41 PM

    That's too bad, since it is possible to do it in SAP B1.
    OK, but since I can only change the price for the item, line by line is it possible to force a .UnitPrice = 0 and .PriceAfterVAT = 100.00?
    The reason I ask is, the document I'm trying to insert get's it's prices from a source where only VAT included prices are present. So instead of the unit price, I want to set the price after VAT and have SAP B1 calculate the unit price.
    I set the BP default price list to a list where no prices are defined, and it works. But has you can imagine, when doing a document in SAP B1 this will cause it to set the prices to 0 on the lines, and the users might get angry at it.
    So if you guys have any ideas on how to go around this some other way, please do tell.
    Thanks in advance.

  • Tools to list classes used in the project/

    Hi
    is there any tool that would list all the classes and packages used in my project. the tools must be something like getting input as a main class and list all the other classes used in the project. ?
    -- MJ

    Hi,
    This forum is exclusively for discussions related to Sun Java Studio Creator. Please post your question at :
    http://forum.java.sun.com/forum.jspa?forumID=54
    Thanks,
    RK.

  • [AS] List of used colors in document

    AppleScript question
    Is there a way to get a list of colors used in a document?

    This oughtta do it...
    tell application "Adobe InDesign CS3"
    tell document 1
    get every color
    get name of every color
    get color value of every color
    get space of every color
    end tell
    end tell

  • Changing the fonts used by the look and feel?

    I want to be able to change the font settings for the program I'm writing. Is there any way to do this without writing my own theme and/or LookAndFeel? For example, is there a way to just use the Nimbus Look & Feel, but override the fonts it uses somehow? I've been browsing around and it seems like most solutions are to write your own theme from scratch, which I'd like to avoid if possible (I don't want to change anything else, just the fonts!).
    Any help or guidance is very much appreciated. Please let me know if I was unclear.

    Thank you both for the links. I realize I didn't ask this initially, and you both answered the question I asked, but I'm actually curious if there's a way to do this consistently across different looks and feels. Just some sort of blanket command that, regardless of what the Look and Feel is, overrides font selections. Perhaps I'm looking for a way to override the mappings of logical fonts? I'm not exactly sure how one would accomplish it.
    I don't do this because I want to force the user into using a specific font, but actually I'm trying to add a feature that allows the user to override the Look & Feel's font choices with their own if they so choose.
    But I can't control what Look and Feel they're using (well, I can, but I have chosen not to).
    Does any of that make sense?
    Edited by: Caryy on Sep 21, 2010 11:22 AM

  • How can i change font used by the java plugin?

    im running j2se 1.4.0 on win2k, and the java plugin is using a font that is not readable because sized way too small (also, the font is not a 'standard' font).
    the font is also applied do class loading or exception messages in java applets (in IE5.5, but i don't think that this is browser-related).
    is there a possibility to change to font (or the font size)?

    thanks for the tip, but this problem seems not to be tightened to the font.properties file:
    the wrong font is only used with the j2sdk1.4.0 plugin, not with that from j2re1.4.0 (actually, i had installed jre first, and afterwards j2sdk without removing j2re before). changing the plugin used back to j2re made the java console display the correct font (though the font.properties files were identically in both cases).

  • Prepping large lists for use with the IN Operator

    We frequently have to run a query on a specific listing of comptuer names, typically using the IN Operator and ('Name1', 'Name2', etc.).
    Am looking for a way both to speed up the placing of the names into the required formatting, and to also remove the CRLF between them (they come mostly from Excel lists, so one per row) to make the code at least look neater (and spend less time typing),
    i.e.,:
    Name1
    Name2 
    Etc.      to:  ('Name1', 'Name2', 'etc.')
    Any way to automate?
    Thanks.

    We may all be going overboard suggesting better ways to do things, but to loop back around to answer your question, if you just wanted a simpler way to paste a shortish list of values into SSMS for convenient running through an IN clause...
    SSMS the front end application you use to query SQL Server supports Regular Expressions, even though (sadly) SQL Server itself doesnt.  Here's a Search and Replace that would mostly do what you want.. (This works almost perfectly, except there is one
    extra comma at the end you have to backspace to fix.  I could spend way more time figuring out how to handle the extra comma at the end, but then again, I could also NOT spend that time too.. :-)
    Start with just your pasted list, or highlight just the list itself, leave the rest unhighlighted.
    Find and Replace (or control-H)
    Find what:  Type in exactly as shown, just the highlighted part below
    {^}{.*}{\n*}
    Replace with: Type in exactly as shown, just the highlighted part on the line below
    '\2',
    Make sure "look in" is set to the appropriate thing ("selection" if you took the select text approach)
    Choose Regular Expressions via the USE checkbox at the bottom
    Click Replace All
    There's also a cache of "Most recently used find and replace strings", so the down arrow will remember the regex expression for a little while at least.
    Sadly, SSMS doesn't have savable macros, you'd have to type that in each time.  However, the investment to mess with and learn regular expressions will last a lifetime
    Other approaches I also use:
    Notepad++ and some stored macros (so paste from your source to notepad++, run the macro, then copy and paste from there to SSMS.  Notepad++ has quite a nice way to just record what you're doing, without having to worry about
    learning how their macros work.
    An embarrasingly complex spreadsheet for quick and dirty conversions to SQL formatting that I use in certain very unique situations for my own personal queries, nothing else.  Again, requires an interim step of pasting to the spreadsheet, then to SQL.
    And the disclaimer: As people here are suggesting better and more robust ways (load a table, etc.), this approach that I mentioned here here (Regular expressions via SSMS) is a "for programmer use only while using SSMS" approach, not really suitable
    for a large scale solution.  (But then again, if you're a programmer using SSMS, maybe it's just fine!)

Maybe you are looking for

  • Error message when trying to import a CD into iTunes

    I get an error message when I try to import a CD into iTunes that says the disk cannot be found. I recently requested to uninstall Tune-up because I kept receiving annoying messages to purchase the software. It looks like Tune-up is deactivated, but

  • How to get rid of modal ads

    More and more often I get this blac opac modal screen when visiting newssites etc. Like this: http://www.youtube.com/watch?v=rAo-xsfJ4u8&feature=youtu.be What causes this and how do I get rid of it?

  • Application preferences system - best practice

    Hi, I'm migrating a forms application from 6i to 11g The application source forms are the same for all the possible deployments , which are set in different databases (let's say one database for each client). But as you may expect, each client wants

  • Set primary database to maximize availability; ORA-02231

    Hi Folks, Today while trying to change Protection Mode for one of my Primary Database i started recieving below provided error codes: SQL> alter database set primary database to maximize availability; alter database set primary database to maximize a

  • My Reply emails don't send

    This is a strange problem I've been having with my iPhone (original). I can receive and send emails mostly fine. However, if I send an email, someone replies, and I reply back to them, my reply never goes through. The "sending" bar fills up, and my p