SetFormatOfRange applies wrong font

Hi all,
I am having an issue changing the font for text in a RichEditableText to an embedded font. I am using Flex 4.1, and my code looks more or less like this (simplified):
<fx:Style>
     @namespace s "library://ns.adobe.com/flex/spark";
     @namespace mx "library://ns.adobe.com/flex/mx";
     @font-face {
          src: url("assets/txt/BlackCasper.ttf");
          fontFamily: BlackCasper;
          embedAsCFF: true;
</fx:Style>
<fx:Script>
     <![CDATA[
     import mx.events.FlexEvent;
        public function setFont() : void {
          var newTlf : TextLayoutFormat = new TextLayoutFormat;
          newTlf.fontFamily = "BlackCasper";
          text.setFormatOfRange(newTlf);
     ]]>
</fx:Script>
<s:RichEditableText id="text"
          top="5" bottom="5" left="5" right="5"
          selectionHighlighting="{TextSelectionHighlighting.ALWAYS}"
          fontSize="70" editable="false" selectable="false"
          />
Polling Font.enumerateFonts in setFont lists "BlackCasper" correctly, so the font seems properly embedded. Also, if I set text.setStyle("fontFamily","BlackCasper"), the font is set correctly for the entire RichEditableText. However, if I call my function setFont, the selected text changes to a standard system font, instead of changing to the embedded font. I tried using a string that was not listed by Font.enumerateFonts(true) as fontFamily, and the selection changes to the same system font that it changes to if I use "BlackCasper". Finally, if I use a system font as fontFamily, then the selection changes (correctly) to the specified system font. From these observations, it would appear to me that a font family for an embedded font is not recognized by setFormatOfRange, which instead uses a default. Does anyone has any suggestions on how to fix this?
Thanks in advance!

That's exactly what I was trying to do:
var newTlf : TextLayoutFormat = new TextLayoutFormat;
newTlf.fontFamily = "BlackCasper";
text.setFormatOfRange(newTlf);
However, for some reason, the selection is not rendered to the embedded font "BlackCasper" as it should. Instead, the text is rendered in some random system font that is not "BlackCasper". For all widgets that accept CSS styling, I can use "BlackCasper" perfectly with setStyle. I really don't get what I am doing wrong with the way I use TextLayoutFormat

Similar Messages

  • Apply different font styles in single text frame

    hi all
    how can i apply different font styles in a single text frame using indesign script ?
    for example :
    "dasdnasndasndlasndnasdlasdasdas"
    may i know is it possible to do that and how to do that ?
    thanks

    You can set (as well as read) every single property of any text range with scripts. This is javascript; it assumes you text cursor is inside a frame with some text.
    * Setting some specific characters to a color:
    app.selection[0].parentStory.characters.itemByRange(5,10).fillColor = "Red";
    * Change the font of words:
    app.selection[0].parentStory.words[3].appliedFont = "Arial\tBold";
    * .. or just the style:
    app.selection[0].parentStory.lines[2].fontStyle = "Italic";
    * .. or any other attribute (this one requires you to have at least 5 characters selected):
    app.selection[0].characters[5].underline = true;
    Of course these operations are not limited to something you select; they work the same with any text frames you can refer to.
    app.activeDocument.textFrames[1].paragraphs[2].appliedCharacterStyle = "charstyle";

  • Open pdf and the text is in written in wrong font

    hi
    i have a problem with my illustrator.
    i created a pdf file a long time ago. the text is written in times new roman regular.
    now when i open the pdf in illustrator it shows a wrong font. i think the wrong font could be new times romance or something)
    but if mark the text and change the font from regular in bold, it shows the right font (times new roman bold).
    how can i change back the text in times new roman regular?
    im using cs4 on win7. already checked the fonts in systemfolder
    thanks a lot
    thanks

    i deleted and nothing happened.
    edit: i checked the the font with an fontanalyzer. it seems that the font was not new times romance. i deleted the analyzed font and now illustrator showe me the right font.
    thanks

  • Can we apply embedded font in extension to a text layer of Photoshop ?

    Hi All,
    I have embedded some fonts into my Flex extension panel of Photoshop.
    Can I apply these fonts to any text layer?
    Kindly help URGENTLY!
    Thanks,
    D.A

    Here are 3 options for future reference:
    1. With the setup you've described, apply a Match Move behavior to  the text and make the rectangle the source. Change the Transform parameter to Mimic source.  This way you can still adjust the text postion as needed, but the rectangle will drive the animation.
    2. Use a group to do the animation.  Put both your rectangle and text in the same group and animate the group's postion.
    3. Use the Link behavior.
    Each of these has it's advantages depending on what you need.

  • Html to image but wrong font

    I found some code to convert an html to an image.
    Using the codeexample, i get a nice png-image but it has a wrong font.
    I tried changing it in the html-source but it doesn't help.
    any idea?
    import javax.imageio.ImageIO;
    import javax.swing.*;*
    *import java.awt.*;
    import java.awt.image.BufferedImage;
    import java.beans.PropertyChangeEvent;
    import java.beans.PropertyChangeListener;
    import java.io.File;
    import java.io.IOException;
    import java.net.URL;
    public class Test {
    private static volatile boolean loaded;
    public static void main(String[] args) throws IOException {
    loaded = false;
    File mySignature = new File("d:/mypage.htm");
    URL url = mySignature.toURI().toURL();
    JEditorPane editorPane = new JEditorPane();
    editorPane.addPropertyChangeListener(new PropertyChangeListener() {
    public void propertyChange(PropertyChangeEvent evt) {
    if (evt.getPropertyName().equals("page")) {
    loaded = true;
    editorPane.setPage(url);
    while (!loaded) {
    Thread.yield();
    File file = new File("d:/ex_mypage.png");
    componentToImage(editorPane, file);
    public static void componentToImage(Component comp, File file) throws IOException {
    Dimension prefSize = comp.getPreferredSize();
    BufferedImage img = new BufferedImage(prefSize.width, comp.getPreferredSize().height,
    BufferedImage.TYPE_INT_ARGB);
    Graphics graphics = img.getGraphics();
    comp.setSize(prefSize);
    comp.paint(graphics);
    ImageIO.write(img, "png", file);
    }Here is the html code
    <html>
    <head>
    <title>Test</title>
    <style type="text/css">
    body {
    font-family: Verdana, serif;}
    </style>
    </head>
    <body>
    <table border="0" width="700" cellspacing="0" cellpadding="0">
    <tr>
    <td colspan="2" bgcolor="#1D4667" align="center">
    <font size="-1" color="#FFFFFF">Title</font></td>
    </tr>
    <tr>
    <td><font size="-1">Normal Text</font></td>
    <td><b><font size="-1">Bold Text</font></b></td>
    </tr>
    </table>
    </body>
    </html>

    I ran your code and the output text looked like it was plain. However, all the Verdana fonts on my system look
    pretty close to plain text, so I didn't know wether it was working or not.
    So I ran your code but replaced the font with a more stylish one on my system (called "Chiller") in the html file. I got the correct results.
    The posiblity then exists that "Verdana, serif" in your html file is not the proper way to reference
    the font you're looking for. And if the JEditorPane can't find the font name on your system it defaults to plain text. "Chiller"
    seemed to work fine for me.

  • Prints with wrong font and drops letters. Preview shows font correctly.

    I'm having problems printing some pdfs in Leopard. The preview shows correctly but the resulting printout is in the wrong font and has missing letters. Specifically every time there are two 'f' in sequence they get left out.
    Printing the same files on Tiger or even (Sigh) Windows yield the correct result. I've tested this with 3 printers (OKI C5800, Canon iR5000 and Canon iR C2620N). All with the same result.
    The pdf in question were created with LaTeX.
    Has anybody experienced something similar? What could be wrong?
    I can provide the sample .pdf file if necessary.

    After upgrading to Leopard, I was having trouble with my Samsung printer (ML-2150). Samsung hasn't upgraded the driver since OS 10.3, and it doesn't seem likely that they will ever do it. I found that the Linux-Foundation has an open source driver, which is compatible with a lot of printers. I downloaded the three components, and my Samsung is working perfectly now.
    I would suggest that you give it a try, here is the link:
    http://www.linux-foundation.org/en/OpenPrinting/MacOSX/hpijs

  • Unable to undo applied embedded fonts

    Hello All,
    I have application with text box created with  container controller and textflow.
    Also I have applied embedded fonts dynamicaly using
    styleManager.loadStyleDeclarations2(url,false);
    but after this when I try to undo, previous font is not get applied.
    When I debug the application, i fonund that generation is number is mismatch.
    please anybady know why it is? When I apply different font size or any other property link color, Undo works properly.
    Thanks,
    Vikram

    Undo can only undo those changes that are inside operations. If there are direct model changes (changes resulting from an API call that is NOT in an operation), this will cause a generation number mismatch. Undo will be blocked because the model has changed. I would suggest finding out what it is you are calling that is incrementing the generation number, but is not inside an operation.
    - robin

  • Wrong font in PDF opened in Preview

    I have a Mac G5-Intel running 10.5.4. The problem is as follows:
    I make a figure (a plot) with Igor, save the plot as EPS. I use Preview or "epstopdf" command to get the PDF.
    For figures I processed before this problem showed up, the Preview displays the wrong font, but Acrobat displays the correct font (this is the font I selected in Igor when I first made the plot).
    For figures processed after the problem showed up, both Preview and Acrobat display the same wrong font.
    If I open the EPS version using some other application such as Canvas (a drafting software), the font displays correctly.
    If I try to alter the font in the PDF file using Acrobat (full version), the font cannot always be changed because "The compatible system font and the document font may differ and some characters may look different. If the font is not on your system, there will be no way to re-embed it. Do you want to proceed?" message appears. I click "yes" and the font changes to Arial (I had requested Helvetica).
    If I then want to change the font again to the previous condition, Acrobat refuses because "The change to a different font was not done because the chosen font and the font encodings in the document differ and could not be resolved."
    The problem never occurred in my older Mac Power PC running 10.4. In my new Intel Mac, there was a trouble-free couple of weeks after I got the machine.
    The problem doesn't happen when I take my pdf figures to a colleague's identical machine or to my Intel MacBook Pro laptop running 10.5.2.
    Any ideas?
    Thanks

    The problem also affects the same plots when they are part of a Latex output PDF made with TexShop. I thought this is normal, since Texshop uses Mac's PDF Preview machinery to process.

  • Unable to apply embedded font swf to text in text layout framework

    Hello,
    We have created a swf for a given font (for e.g., Calibri.swf) which contains all the styles (Regular, Italic, Bold, BoldItalic).
    We have created a xml which lists the name of the font and the corresponding swf file path. The names from the xml are loaded into a combo box in the application.
    When we try to apply the selected font to a text in the text layout framework, it does not apply the same. It sets the font to default "Times" font.
    Following is a snippet of code to apply the font to the text:
    private function selectFont(fontXML:XML):void {               
                    var path:String = fontXML.@source;
                    var myEvent:IEventDispatcher = styleManager.loadStyleDeclarations(FlexGlobals.topLevelApplication.url.substring(0,FlexGl obals.topLevelApplication.url.lastIndexOf("/"))+"/"+path);
                    myEvent.addEventListener(StyleEvent.COMPLETE, function(event:StyleEvent):void{
                        var editManager:EditManager = textFlow.interactionManager as EditManager;
                        var itextLayout:TextLayoutFormat = new TextLayoutFormat();
                        itextLayout.fontSize = 20;
                        var fontName:String = fontXML.@name;
                        Alert.show(fontName);
                        itextLayout.fontFamily = fontName;   
                        Alert.show( "itext = " + itextLayout.fontFamily);
                        editManager.applyFormat(itextLayout,itextLayout,itextLayout);
                        var flowLeafElement:FlowElement = textFlow.findLeaf(editManager.anchorPosition) as FlowElement;
                        editManager.changeStyleName(fontName,flowLeafElement);
    Can anyone please let us know what is missing in the implementation?
    Thanks in advance.
    Vikram

    My recommendation: unless you really care about ISWFContext implementations and the application domain issues, ignore Alex's post about embedded fonts.
    It is a nice discussion about the inner workings of the domain and security of how this works but it is imho broken and is an insane concept to require an ISWFContext to just use an embedded font. It also breaks runtime CSS loading that has fonts embedded in it because the Flex compiler (last I checked) was also busted – it doesn't include the function necessary to create within context the font embed so that it may be applied. You can't create an ISWFContext with a compiled CSS file.
    These issues were introduced in the last Flex SDK beta before FB4 was released in final form. There are multiple bugs logged against the issue of applying loaded font files to TLF text (in short, SWFContext is broken and you have to override GlobalSettings.resolveFontLookupFunction to return embedded or null, all the time).
    Here's some more details to get you started - with links to at least one of the SDK bugs that were filed:
    http://forums.adobe.com/message/2656152
    For example:
    import flashx.textLayout.elements.GlobalSettings;
    import flash.text.engine.FontLookup;
    GlobalSettings.resolveFontLookupFunction = function makeValid():String { return FontLookup.EMBEDDED_CFF };
    And you may need to do this after your font is loaded:
    yourTextBlock.textFlow.invalidateAllFormats();
    Disclaimer: I haven't seen the latest Flex SDK release to see if this was fixed. I have an AIR application with native process that builds embedded font SWF files for use and stub code for FB4 usage but haven't updated to the latest SDK yet to see if it's working properly.
    Anyhow, your best bet is to look at the Flash Builder forums. I think this is/was a Flex team issue, not TLF.

  • Problems with Saved Watermarks - Wrong Font Size

    Hi,
    I am having problems with "Saved" Watermarks, as when I selected them they have the wrong font size.
    I created a Watermark (Draft) to be placed on the lower right
    corner of a PDF, using font Arial-10. This watermark has been save using the "Save Settings..." in Watermarks.
    When I add this this "saved" watermark to a new PDF, the font size is wrong
    (much much bigger), even though the Add Watermark windows reports Arial-10. Only by a selecting a different font size and changing it back to the saved font size (10) I get the correct Font Size in the PDF.
    I had a similar problem with the placement, but managed to solve that by setting the Preference>User&Guide to the used Unit (Page&Ruler = centimeters). But for the font size I can't find anything in the preference.
    Any Help or Suggestions ?

    Hi,
    Sorry forgot to add, I am using
    Acrobat Professional 8.1.2 on Windows XP Prof.
    Cheers
    Johannes

  • Applying wrong imaging driver updates ....

    ZENworks 11.3.2 Windows 2008 R2 SP1
    Last night we upgraded from ZENworks 11 SP3 to 11.3.2
    Applying Imaging Driver Update Feburary 2015 zenworks11.3.2_FRU1_Feb15.zip results in error message 'Applying wrong imaging driver update'
    ZUpdate.sig on primary server where running the update says ZEN_CLIENT_VERSION 112403 - timestamps on certain folders in the tftp directory and in the share\preboot\update folder though indicate that updates did take place at the time of the upgrade.
    Also a seconday server shows ZEN_CLIENT_VERSION 113200.
    'Assuming' that only the ZUpdate.sig file didn't update on the primary server - would it be safe to manually update the ZEN_CLIENT_VERSION and then run the imaging update?
    Thanks.

    Sector osh wrote:
    >
    > ZENworks 11.3.2 Windows 2008 R2 SP1
    >
    > Last night we upgraded from ZENworks 11 SP3 to 11.3.2
    >
    > Applying Imaging Driver Update Feburary 2015
    > zenworks11.3.2_FRU1_Feb15.zip results in error message 'Applying wrong
    > imaging driver update'
    >
    > ZUpdate.sig on primary server where running the update says
    > ZEN_CLIENT_VERSION 112403 - timestamps on certain folders in the tftp
    > directory and in the share\preboot\update folder though indicate that
    > updates did take place at the time of the upgrade.
    >
    > Also a seconday server shows ZEN_CLIENT_VERSION 113200.
    >
    > 'Assuming' that only the ZUpdate.sig file didn't update on the primary
    > server - would it be safe to manually update the ZEN_CLIENT_VERSION
    > and then run the imaging update?
    >
    > Thanks.
    Before doing so... I would run a ZDC, just to check - could me more
    than just this one file...
    Niels
    I have always liked... Cowabunga!
    If you find this post helpful, please show your appreciation by clicking
    on the star below.
    A member must be logged in before s/he can assign reputation points.

  • Can't apply -fx-font-weight: bold;

    Hi. I'm trying to apply this style to Labels :
    .label {
    -fx-text-fill: gray;
    -fx-font-weight: bold;
    The gray fill is ok , but bold weight doesn't work.
    I'm using MacOS JavaFX 2.1 b17.
    Am i doing something wrong ?
    thanks
    Edited by: mschoenfelder on 2012-03-22 11:27

    I can't reproduce this, the -fx-font-weight:bold style works fine for me when set either in code via setStyle or in the exact same external stylesheet you supplied (WinXPsp3, JavaFX 2.1b17, JDK7u4ea).
    My guess is either:
    1. It is a Mac specific bug.
    2. The default font used by JavaFX on the Mac does not support bold (seems really unlikely).
    3. You are not copying the correct version of your stylesheet to the binary output directory you are running the application from (most likely).
    4. You are not correctly loading the required stylesheet.
    5. You are otherwise overwriting the style somewhere else.

  • Bridge CS5 applies wrong white balance during thumbnail extraction (raw files only)

    Hello to all Adobe Wizards,
    Hobbiest photographer here. I use a Canon T2i and I have been shooting raw with auto white balance.
    After I upload the CR2 files to Bridge, Bridge begins thumbnail extraction. This is when the problem begins: I watch Bridge extracting thumbnail photo after photo, turning them into wrong white balance one by one. After Bridge is done, I open one of these photos in Camera Raw, it shows the photo in "custom white balance". I was able to change it back to "As Shot". But every photo in Bridge now has custom white balance and is difficult to view in Bridge. This screenshot shows what my Bridge looks like after thumbnail extraction....
    Yesterday, just out of curiosity, I took some photos with different white balance settings on the camera. I uploaded them to Bridge and Bridge over-wrote all the white balance settings. I then imported the same photos (from the same files) to iPhoto, they show up with correct write balance. Please see the second screenshot.
    The third screenshot shows a unedited photo I opened from Bridge to Camera Raw, and the same photo as it appears in iPhoto, both unedited.
    Again, this only happens to CR2 files. All tif, jpeg files are fine.
    Any ideas?
    Thanks!
    -Wolfie

    Any ideas?
    First of all, shooting Raw has the benefit of changing the color temperature (Whit Balance) to what ever you like from whatever you shot in camera.
    To me it seems you once have saved a custom white balance as default setting and this is been applied to every new file because you told Bridge to do so. The easiest way to get out of this is open a raw file in ACR and in the basic tab at the right side you see a small icon for sub menu (next to the word basic). Click on it and from the row choose 'Reset Camera Raw defaults' at the bottom.
    Also decide whether you want to stay in 16 bit mode (as you are now as shown in the blue line under the preview). If you want to chance it back to 8 bit just click on that blue line and choose your options from that menu. You only have to do this once for the files from that same camera, ACR remembers the settings for you.
    Using 16 bit mode has advantages when using critical color corrections (but then you also should change the color mode to ProPhoto in my opinion). The disadvantage is that 16 bit doubles the file size compared to 8 bit
    Having set the ACR defaults should effect your thumbs immediately by building new thumbs and previews but if not you must choose purge cache for folder from the menu tools / cache/ purge cache for folder. Now the new settings will be applied.
    It may take some time so let Bridge do its work properly before starting other jobs in Bridge (see the activity bar bottom left to check if Bridge is still caching).

  • How to Apply A Font Style in Mail?

    This seems like a simple question, but I can't seem to find an answer by searning this forum.
    I'm new to Mail (recently converted over from Entourage). Quite often, the e-mails I compose are a hodge podge of cut and pastes from other messages and documents. The result is a mix of fonts and font formats.
    I would like a simple way to highlight all of the text in a document and apply a single style. Essentially, I want a way to apply a single style to all of the text in a mail message.
    I can't seem to find this in Mail. I've tried to "apply" the default style using the Format --> Style ... menu, but that doesn't work as expected (I don't think it changes anything). Looking up "Style" in the Help menu brings up nothing of help.
    Any suggestions?

    you could also select Verdana 12pt as your Fixed-width font and your Message font in preferences under fonts/colors, then check the box that says "use fixed-width font for plain text messages"
    then you could select your text command-A, then Shift-Command-A (to convert to plain text) which would convert everthing to verdana 12pt, then if you wanted rich text message again, just press Shift-Command-A again and it will stay with Verdana 12pt but be a rich text message.
    This would only be 2 and at the most 3 key combos with no mouse clicks to achieve what you mentioned in your previous post.

  • Acrobat X displaying the wrong font

    I've been using Acrobat X for a few weeks. The other day it installed an update. Since then my documents aren't displaying the font used by the orginal Office 2010 documents.
    If I create the PDF from Office 2010 by selecting "save as Adobe PDF" from Word or Excel file menu then Acrobat X renders it using Adobe Serif MM instead of Times New Roman. It seems like a close enough match.
    If I create the PDF in Office using "save as" and choose the PDF file type then Acrobat X will substite Adobe Sans MM for Times New Roman,
    If I send this to a person who is using Acrobat 9 it is being displayed as Times New Roman.
    Does anyone know how I can make this work? We have a lot of pdf documents that were created using Office 2007 & 2010.

    Hi Louis,
    If I understand you correctly, you are saying that problem started with updating Acrobat 10.0.1 to 10.0.2 and it is there in both Save as "PDF" and  Save as "Adobe PDF"
    With Save as Adobe PDF, you see Adobe Serif MM font and
    With Save as PDF, you see Adobe Sans MM font.
    where the actual font is TimeNewRoman.
    Am I correct?
    Also when you say that "If I send this to a person who is using Acrobat 9" do you mean that you are sending above Acrobat 10.0.2 created PDF to a person who will view this in Acrobat 9? And there this PDF shows correct font. Please correct me if I am wrong.
    I tried this for a sample file with Acrobat 10.0.2+Office 2010 Pro Plus+Win7 SP1 but couldn't able to reproduce. So based on above queries we will investigate it more. If possible please share your source file also (you can upload it on acrobat.com)
    Thanks,
    Vishal Gupta

Maybe you are looking for

  • CAN'T TRANSFER CDS TO IPOD

    When I put a cd in, it comes up in itunes, I imported it and little green checks come up next to each song. Seems successful.. but when I try to drag it onto my ipod (which works fine for Mp3s I already have on my computer) I get an error message say

  • On startup, FF loads 2 tabs - one is my default, the other a FF info window.

    I turn on my desktop and click my Firefox (FF) icon. When FF loads to the screen, two tabs appear. - one with some FF page that includes a FF video it says something like "Hurray: your browser is up to date." - the other is my default page The result

  • Inspection at vendor site while loading the material?

    Hi All, How we can enable the inspection while loading the material i.e at vendor's site, how we can enable the inspection while unloading the material at customer site. That is I exactly require an inspection set up to record the values after PO & b

  • JOptionPane and UninitializedValue. Help

    I am trying to create a personalized dialog that has 2 buttons (OK and Cancel) and three RadioButton where the first two radio buttons disable input and when user presses OK it returns a fixed string and if the user chooses the third button input is

  • Anyone have this same problem with Zen 20G tou

    Everything was working great until...... I started to get the screen that said, Firmware problem. I figured out how to reset it and get into recovery mode by holding down the power and then the reset button. I deleted the firmware in there and up loa