Using Derived fonts in JTextPane

Hi All,
1) Is there any way to insert a char or string in JTextPane, using derived fonts. insertString method takes font information from AttributeSet, where you can specify a font family name only and not the actual FONT type. Suppose I derive a font, and want to use that font for my string, How do I do that.
2) Another queston is that is there any way to insert a blank space of a desired size (in mm, cm or pixel unit) in JTextPane, which uses document as its model ?
Any help would be greatly appreciated.
Thanks

2) Another queston is that is there any way to insert a blank space of a desired size (in mm, cm or pixel unit) in JTextPane, which uses document as its model ? The easiest way is to create image of desired size and insert image in the document using following.
MutableAttributeSet attrs=new SimpleAttributeSet();
StyleConstants.setIcon(attrs,imageIcon);
document.insertString(offset," ",attrs);
another way is to create custom SizeFixedView (with desired size) and replace usual LabelView with it.
best regards
Stas

Similar Messages

  • Urgent :Using a font face name in a JtextPane

    1)How can I use a font face name for setting the font of the text I display in a JTextPane.A call to textPane.setFont() does not work I could find a method StyleConstants.setFontFamily() , but , if I'm not wrong, that would set the font family only and hence the valid arguments to the method would be family names like "Serif", "SansSerif", "Monospaced", "Dialog", and "DialogInput", and not a facename like "Courier".
    2) Also because I cannot use a java.awt.Font object for JTextPane, I cannot use a cache for fonts so that I can share a Font object across multiple JTextPanes. Any ideas?
    Regards
    Nikhil.

    I am not sure how to answer this because you do not
    make it clear why you cannot use a
    java.awt.Font.The reason for this is that if I invoke method setFont (java.awt.Font) on a JTextPane , it has no effect.
    The only way I could find for setting a font in JTextPane is to use StyleConstants.setFontFamily() which
    takes a font family name as a string. As a result , if I have multiple JTextPanes with the same font,
    I'm not sure if internally some sort of caching would be used by the java runtime.
    If only I could use setFont(java.awt.Font) ona JTextPane, I could have cached java.awt.Font objects
    and supplied the same Font object in setFont(java.awt.Font) method of all the JTextPanes that have
    text with identical fonts.
    If you define a
    java.awt.Font in a high-level class, and pass
    it to many JTextPanes it will only be cached once,
    because of oblique passing-by-reference used by the
    JVM.

  • Display Simsun Font in JTextPane, need all characters have same width

    Hi, Gurus
    Need help regarding this issue.
    I am using a JTextPane for display and user input, and I need to use "Simsum" font(customer requirment). And an important requirment is that every character should have the same width, including space. And I find out that when displayed in JTextPane, for English characters and digits, there is no problem, they all have same width, only problem is with space, it is a little bit narrower than other characters. For example, if I type 26 characters "ABCD......XYZ" in the first line, then type 26 spaces in the second line, it is very noticeable that the spaces are narrower.
    At first I thought it is the problen with the font, but then I tried type characters and spaces in Notepad using "Simsun" font and find out that space has the same width with other characters.
    I am thinking probably I need to create my own font based on "Simsun" font, or there is some attributes or styles I need to add when create the styled document for my JTextPane.
    Can anybody give me some help here? Thanks

    Another new dude who is clueless as to the possible effects of cross-posting

  • AI, using derived manifests

    Hello,
    Anyone else had 'issues' with AI providing the disk names using derived manifests in the wrong order for the machine hardware?
    If I use the order that AI gives me the machines will not boot up without manual intervention!
    I'm using Sun Server X3-2L's.
    I have tried MOS but it's like walking in treacle!
    Many Thanks!
    Maria

    2) Another queston is that is there any way to insert a blank space of a desired size (in mm, cm or pixel unit) in JTextPane, which uses document as its model ? The easiest way is to create image of desired size and insert image in the document using following.
    MutableAttributeSet attrs=new SimpleAttributeSet();
    StyleConstants.setIcon(attrs,imageIcon);
    document.insertString(offset," ",attrs);
    another way is to create custom SizeFixedView (with desired size) and replace usual LabelView with it.
    best regards
    Stas

  • The "Roman" font is not being recognized in Firefox 4.0. As such, I cannot read any previously posted topics or post any new topics on websites using this font.

    The "Roman" font is not being recognized in Firefox 4.0. As such, I cannot read any previously posted topics or post any new topics on websites using this font.

    I have had a similar problem with my system. I just recently (within a week of this post) built a brand new desktop. I installed Windows 7 64-bit Home and had a clean install, no problems. Using IE downloaded an anti-virus program, and then, because it was the latest version, downloaded and installed Firefox 4.0. As I began to search the internet for other programs to install after about maybe 10-15 minutes my computer crashes. Blank screen (yet monitor was still receiving a signal from computer) and completely frozen (couldn't even change the caps and num lock on keyboard). I thought I perhaps forgot to reboot after an update so I did a manual reboot and it started up fine.
    When ever I got on the internet (still using firefox) it would crash after anywhere between 5-15 minutes. Since I've had good experience with FF in the past I thought it must be either the drivers or a hardware problem. So in-between crashes I updated all the drivers. Still had the same problem. Took the computer to a friend who knows more about computers than I do, made sure all the drivers were updated, same problem. We thought that it might be a hardware problem (bad video card, chipset, overheating issues, etc.), but after my friend played around with my computer for a day he found that when he didn't start FF at all it worked fine, even after watching a movie, or going through a playlist on Youtube.
    At the time of this posting I'm going to try to uninstall FF 4.0 and download and install FF 3.6.16 which is currently on my laptop and works like a dream. Hopefully that will do the trick, because I love using FF and would hate to have to switch to another browser. Hopefully Mozilla will work out the kinks with FF 4 so I can continue to use it.
    I apologize for the lengthy post. Any feedback would be appreciated, but is not necessary. I will try and post back after I try FF 3.16.6.

  • How do I use a font I downloaded in my Flash game?  I downloaded the font as a TTF file, but can't figure out how to configure it.

    I downloaded the file from 1001freefonts.com
    I've looked at many tutorials about embedding custom fonts - I'm not sure what they are achieving, they never seem to have a step about importing TTF file or anything.
    Thanks!

    close flash pro.
    right click the downloaded font file > click install.
    start flash pro.
    among other ways to use that font, you should be able to find it in the properties panel when you select the text tool.

  • How do I use a font variation in a pages document. I no longer have the "viewer" -glyph option in special characters pane only new mbPro with Lion. I know the variation is available because I can see it in the font book. so now what I just want to be

    How do I use a font variation in a pages document? or other app for that matter? I no longer have the "viewer" - glyph option in the special characters pane (under edit  in toolbar). I know the varaition ia available because I can see it in my font book. I depended on that alot so I need to find a way to still use character and embellishments. I don't want to have to go back to my od computer (from2007) Please Help!

    I really don't understand.
    The menu item is available :
    Maybe, you didn't activate the tool :
    Yvan KOENIG (VALLAURIS, France) mardi 2 août 2011 23:10:17
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.0
    My iDisk is : <http://public.me.com/koenigyvan>
    Please : Search for questions similar to your own before submitting them to the community
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !

  • How do I use a font that a user of my screen saver might not have?

    I am trying to do a little experiment with fonts. I downloaded a font that was not previously installed on my computer, and am trying to make a "Hello, World!" screen saver with that font(which I installed).
    The problem is that I can not even use that font. When I attempt to make a "Hello, World!" screen saver with that font, it uses the default font. Here's the code:
    #import "saverView.h"
    @implementation saverView
    - (id)initWithFrame:(NSRect)frame isPreview:(BOOL)isPreview
    self = [super initWithFrame:frame isPreview:isPreview];
    if (self) {
    [self setAnimationTimeInterval:1/30.0];
    //either my mistake is here:
    hylianFont = [NSFont fontWithName:@"Ancient Hylian - English" size:20];
    attrs = [NSMutableDictionary dictionaryWithCapacity:2];
    //NSForegroundColorAttributeName -- [Color green]
    [attrs setValue:[NSColor greenColor] forKey: NSForegroundColorAttributeName];
    // or it is here:
    [attrs setValue:hylianFont forKey: NSFontAttributeName];
    displayer = [[NSAttributedString alloc] initWithString:@"Hello, World!" attributes:attrs];
    return self;
    //... more stuff I do not use...
    //simply draws "Hello, World!" in green at the top right of the screen.
    //meant to draw it in the different font, but draws it in the standard font.
    - (void)animateOneFrame
    [displayer drawInRect:[self bounds]];
    return;
    @end
    Where did I mistype?

    I think I solved the problem. I just put the font and the screen saver in a pkg file, and make the pkg file install the font. Or I guess I could keep the font in my screen saver and test it that way. Either way, I found the answer.

  • How to use two fonts in one passage?

    I usually use PAGES to write compositions and every time i try to use another font to revise the composition, the font will change back automatically to the font  that I used for writing compositions. It bothered me a lot..... How can i revise the composition with another font without  change back automatically

    Hi.
    You can execute scenario from command line http://docs.oracle.com/cd/E14571_01/integrate.1111/e12643/running_executions.htm#BABJEHIG:
    On UNIX systems:
    ./startscen.sh <scenario_name> <scenario_version> <context_code> [<log_level>] [-AGENT_URL=<remote_agent_url>] [-NAME=<local_agent_name>] [-SESSION_NAME=<session_name>] [-KEYWORDS=<keywords>] [<variable>=<value>]*
    On Windows systems:
    startscen.bat <scenario_name> <scenario_version> <context_code> [<log_level>] [-AGENT_URL=<remote_agent_url>] ["-NAME=<local_agent_name>"] ["-SESSION_NAME=<session_name>"] ["-KEYWORDS=<keywords>"] ["<variable>=<value>"]*

  • PS CS6 has a different set of installed fonts than my old PS CS4.  How do I get my old fonts back?  Don't like most of the CS6 fonts.  Dell Precision, Windows 7.  Does PS use the fonts in the Windows directory or does it use its own?  A lot of my preferre

    PS CS6 has a different set of installed fonts than my old PS CS4.  How do I get my old fonts back?  Don't like most of the newer CS6 fonts.  Dell Precision, Windows 7.  Does PS use the fonts in the Windows directory or does it use its own?  If so, where are they in the directory?  A lot of my preferred fonts show in the Windows directory but not in Photoshop, which does not display them within the program.  Please help.  If I get free fonts (NOT CC fonts) from elsewhere, where do I put them for Photoshop[ CS6 to use them?  Thanks.

    All versions of Photoshop get their fonts from your OS.  Just install any missing font wherever Windows keeps fonts.
    I don't do windows myself.

  • It seems cranky sometimes works, somtimes not.  My other issue - is there a way to create a mail signature using the font I use in Outlook (or can I import that signature)?

    I have a new iPhone 4s - having lots of trouble with Siri.  It seems cranky - sometimes works, somtimes not.  My other issue - is there a way to create a mail signature using the font I use in Outlook (or can I import that signature)?  How can I find fonts availble on my phone?
    Thanks for any help

    Not in Acrobat unless your image is already in the PDF format.
    This is a feature of forms created with LiveCycle Designer.

  • Why is getLineMetrics inaccurate when using device fonts* or immediately after resizing a TextField?

    1.  We need getLineMetrics to return correct values immediately after changing a TextField's width/height or any property that would affect the layout metrics, withouth having to alter other properties like setting the text to itself (p1.text = p1.text).  Currently, if you change the width of a text field to match the stage width for example, getLineMetrics will not return correct values until the next frame.... UNLESS you set the text property.
    2.  We also need some kind of "stage scaled" event in addition to the "stage resize" event (which only fires when stage scale mode is no_scale), because stage scaling affects the rendered size of device fonts so dramatically that we must call getLineMetrics again.  This is not the case for fonts antialiased for readability, since their size is relatively stable with scaling, as demonstrated by drawing a box around the first line once and then scaling the stage.
    So those are the problems.  The asterisk in the title of this post is there because it seem that TextField.getLineMetrics is accurate with device fonts, but I cannot take advantage of that accuracy without a way to detect when the player is scaled.  I can only confirm its accuracy at a 1:1 scale, since there is no way to recalculate the size of the line rectangle once the player is scaled, aside from setting a timer of some sort which is a real hack not to mention horribly inefficient with no way to detect when the stage has actually be scaled.
    I use device fonts because embedded fonts look terrible and blurred compared to device font rendering.  The "use device font" setting matches the appearance of text in web browsers exactly.  The only way to get embedded/advanced antialiased text in flash to approximate that of the device font look is to primarily set gridFitType to PIXEL instead of SUBPIXEL, and secondly set autokerning to true to fix problems caused by the PIXEL grid fit type.  That ensure strokes are fitted solidly to the nearest pixel, however it still lacks the "ClearType" rendering that device fonts use, which has notable color offset to improve appearance on LCD monitors, rather than the purely grayscale text that flash uses in its subpixel rendering.  Frankly, failure to use device fonts because of API issues, is the only reason why Flash sometimes doesn't look as good as HTML text and why people say text in Flash "looks blurry".  I'm tired of hearing it.  If the player simply dispatched an event when scaled and updated the metrics immediately when any property of the text field that would affect the metrics is changed, then we could all happily use device fonts and Flash text would look great.  As is stands, because of the two problems I mentioned in the opening paragraph, we're stuck dealing with these problems.
    If you create two text fields named "p1" and "p2" for paragraph 1 and 2, populate them with an identical line of text and set one to "use device fonts" and the other to "antialias for readability", then use this code to draw boxes around the first line of text in each of them:
    import flash.text.TextField;import flash.text.TextLineMetrics;graphics.clear();drawBoxAroundLine( p1, 0 );drawBoxAroundLine( p2, 0 );function drawBoxAroundLine( tf:TextField, line_index:int ):void{          var gutter:Number = 2;          var tlm:TextLineMetrics = tf.getLineMetrics( line_index );          graphics.lineStyle( 0, 0x0000ff );          graphics.drawRect( tf.x + gutter, tf.y + gutter, tlm.width, tlm.height );}
    The box surrounding the line of text in the "use device fonts" box is way off at first.  Scaling the player demonstrates that the text width of the device font field fluctuates wildly, while the "antialias for readability" field scales with the originally drawn rectangle perfectly.  That much is fine, but again to clarify the problems I mentioned at the top of this post:
    Since the text width fluctuates wildly upon player resize, assuming that getLineMetrics actually works on device fonts (and that's an assumption at this point), you'd have to detect the player resize and redraw the text.  Unfortunately, Flash does not fire the player resize event unless the stage scale mode is set to NO_SCALE.  That's problem #1.  And if that's by design, then they should definitely add a SCALE event, because changes in player scale dramatically affect device font layout, which requires recalculation of text metrics.  It's a real issue for fluid layouts.
    The second problem is that even when handling the resize event, and for example setting the text field width's to match the Stage.stageWidth property, when the text line wraps, it's not updated until the next frame.  In other words, at the exact resize event that causes a word to wrap, calling getLineMetrics in this handler reports the previous line length before the last word on the line wrapped.  So it's delayed a frame.  The only way to get the correct metrics immediately is basically to set the text property to itself like "p1.text = p1.text".  That seems to force an update of the metrics.  Otherwise, it's delayed, and useles.  I wrote about this in an answer over a year ago, showing how sensitive the text field property order is: http://stackoverflow.com/a/9558597/88409

    As I've noted several times, setting the text property to its own current value should not be necessary to update the metrics, and in some subclasses of text field, setting a property to its own value is ignored as the property is not actually changing and processing such a change would cause unnecessary work which could impact application performance.  Metrics should be current upon calling getLineMetrics.  They are not.  That's the problem.
    From a programming perspective, having to set the text property (really "htmlText" to preserve formatting) to itself to update metrics is almost unmanagable, and doesn't even make sense considering "htmlText" is just one of a dozen properties and methods on a TextField that could invalidate the layout metrics (alignment, setTextFormat, width, height, antiAliasMode, type, etc.), and I would have to override every one of those properties so that I could set htmlText = htmlText.  Using such a subclass isn't even possible if I want to use the Flash IDE to add text fields to the stage.  I would have to iterate over the display list and replace all existing fields with my subclass, which also isn't a good workaround because there's no way to update any and all variable references that may have been made to those instances.
    Frome what I've read, the invalide+render event system is unreliable.  My layout framework is similar to that of Windows Forms, and performs layout immediately, with dozens of docking modes and uses suspend and resume layout calls for efficiently resizing multiple child objects in a component.  Certain calculations cannot be aggregated for a render event, because some containers are semi-reflexive, meaning they can expand to fit the child contents while also contraining the child size, depending on whether the contain was resized or the child component was resized, so as a matter of correctness the resizing calcultation must occur immediately when the child resizes, otherwise a top-down pass on the display hierarchy for resizing will not be sufficient.
    As far as waiting until the next frame, no that is not possible, as it will cause one frame to be completely wrong.  If I was dragging the browser window to resize it, it would look terrible as virtually every single frame during the resizing operation would be incorrect.  Also, in the case where a user clicks the maximize or restore button of the web browser, the resizing event will occur exactly once, so if the metrics are not correct when that occurs, there is no recalculation occuring on the next frame, it will just be wrong and sit there looking wrong indefinitely.
    In case it's not obvious by now, this is a web application.  It uses the NO_SCALE stage scaling option, so notification of the event is not actually an issue for me personally.  I was just pointing out that for anyone not using the NO_SCALE option, there is no event in Flash to detect player scale.  What you're suggesting is using a JavaScript event and using the ExternalInterface bridge to send a message, which there is no guarantee whether it will be processed in a timely matter by the player and introduces possible platform inconsistancies, depending on whether the browser has actually resized the Flash interface at that point or what state Flash is in when it tries to recalculate the size of the text.  The browser may send that event to flash before the player is actually resized, so it will be processing incorrect sizes and then resized after the fact.  That's not a good solution.  Flash needs a scale event in addition to a resize event.  I'm really surprised it doesn't have one.  At the very least, the existing resize event should be dispatched reguardless of the stage scale mode, rather than occuring exclusively in the NO_SCALE mode.
    Bottom line is that getLineMetrics needs to return correct values every time it is called, without having to set the "text" property immediately before calling it.  If such a requirement exists, which seems to be the case, then that needs documented in the getLineMetrics method.

  • Can i use a font such as Yuppy, Chalkboard which is basically included in iOS  for commercial purpose?

    hi!
    I make a e-book and it will be published on appstore and android market as application.
    I'm wondering about font.
    Can i use a font such as Yuppy, Chalkboard which is basically included in iOS  for commercial purpose like me?
    I bought a mountain lion on appstore.
    I look forward to hearing from apple whether it is lawful or not.
    Have a blessed day~:)

    Strangely, there isn't and end user license on Apple's site regarding iOS. But here's a look at the font agreement section from OS X Mountain Lion:
    E. Fonts. Subject to the terms and conditions of this License, you may use the fonts included with the Apple Software to display and print content while running the Apple Software; however, you may only embed fonts in content if that is permitted by the embedding restrictions accompanying the font in question. These embedding restrictions can be found in the Font Book/Preview/Show Font Info panel.
    So basically, you need to examine the fonts to see if there are notes on usage restrictions or limitations.

  • Can't find text in distilled file, using some fonts

    The products I have are Mac OS 10.6.8, Acrobat X and 9, and Word 2011 and Apple Pages for Mac; Acrobat 9 and Word 2007 for Windows XP.
    There are numerous ways to create PDFs on both platforms, whether through save as or creating a PostScript file and distilling it. The problem is that with docs I have using Calibri, Cambria, and Candara, if I distill a PostScript file made from Mac Word or Pages, neither Acrobat nor Apple Preview can find text in the resulting PDF, whether the file distilled with Mac or Windows Distiller. (Meaning a "find" for a string comes up as not found.)  All other combinations are okay, even writing a PS file in Windows Word and distilling with Mac Distiller.
    I mention the fonts specifically because most of the time I use OTF faces, which always work. I even tried using the Windows TTF versions in the Mac operating system -- same failure.
    And even if I force these fonts to be embedded in the Distiller job options, still no joy. If I take so much as a comma and set it to an OTF, I can find the comma. Also, Acrobat *can* find Arial text in a Visio flowchart placed in the Word doc. I don't know how the author placed it there, but it's probably copy from Visio, paste into Word.
    The reason why I care about this is because the distilled PFDs are just a tiny bit better looking on the screen than other options, such as "Save as PDF" from the Mac OS Print dialogue. The only other one that looks as good is the Create PDF button in Windows Word, but I would rather not have to use Windows just to get a better-looking PDF.
    So to summarize:
    Mac app > write PS file > Mac Distiller = fail
    Mac app > write PS file > Win Distiller  = fail
    Win app > write PS file > Mac Distiller  = okay
    Win app > write PS file > Win Distiller  = okay
    Mac app > save as PDF directly > okay
    This might not be a problem with Distiller per se; it could be the Mac OS engine that creates the PS files. You see, I had heard that Apple used their own internally developed engine for the options to save PDF files directly, but was using Adobe code when one used the option to write a PostScript file, so that's why I'm so surprised and disappointed it fails.

    tlmurray23 wrote:
    The reason why I care about this is because the distilled PFDs are just a tiny bit better looking on the screen than other options, such as "Save as PDF" from the Mac OS Print dialogue. The only other one that looks as good is the Create PDF button in Windows Word, but I would rather not have to use Windows just to get a better-looking PDF.
    Hmmm. In what way are Distilled PDFs "a tiny bit better looking on screen" than those made by OS X?
    You are viewing both in the same app and platform?
    And you're referring to font display?
    What settings are you using in Distiller which you think might have some bearing on this?
    tlmurray23 wrote:
    This might not be a problem with Distiller per se; it could be the Mac OS engine that creates the PS files. You see, I had heard that Apple used their own internally developed engine for the options to save PDF files directly, but was using Adobe code when one used the option to write a PostScript file, so that's why I'm so surprised and disappointed it fails.
    OS X's native graphics drawing environment, Quartz, is essentially a "Display PDF", so creating a PDF file is a very simple procedure.
    Writing PostScript for printing uses Apple's own cgpdftops CUPS filter. I doubt there is any "Adobe code" as such, and I dispute the implication that "Apple code == bad; Adobe code == good", which you seem to suggest.
    The specifications for PDF and PostScript are clearly documented, and it should be easy for anyone to follow them.
    However, the fact remains that when Apple converts these MS fonts to PS, something goes wrong. It may be a bug in Apple's code; or it may be that Apple it strictly interpreting font data which MS is playing fast and loose with. Windows' own PS export would no doubt be designed to work with the looser implementation in MS's fonts. This is just hypothetical of course, though is in keeping with tradition.
    What you could do is use a decent text editor like TextWrangler (free from BareBones software) to compare the PostScript code from Windows and OS X.
    You could also look a the Properties tab in Acrobat of the PDFs, and compare the font encoding.
    You could also test running out PostScript from any other app on OS X that you have using those fonts.
    However, I think it is unlikely that you will see resolution unless MS releases a new version of their fonts, or some new version of OS X makes an amendment to fix the bug or cater for the MS issue. Perhaps Lion will do this; perhaps it won't.
    Are you using the versions of these fonts that came with Office 2011 for Mac? What happens if you use the Windows versions of the fonts on OS X?

  • How do I use a font I installed?  I installed Belgrad, it's in my font book, but it's not in the menu for pages.

    How do I use a font I installed?  I installed Belgrad, it's in my font book, but it's not in the menu for pages.  I'm using OS X version 10.9.3

    But what version of Pages?
    I located a free TTF version of Belgrad and it installed fine.
    Which one do you have?
    Peter

Maybe you are looking for

  • How can I ask for things to add in the next ios update

    There are a few things I would like on my ipod touch as ios accesories. So how do ask for these things?

  • Lost messages when pulling from MQ via bridge

    Hi all,           I'm using a bridge to pull messages from MQ, sort them, and republish them into one of several outbound topics. I've received word from a consumer application that they aren't seeing all the messages they expect. Sure enough, they'r

  • Setting classpath- jdbc

    hello Im not able to get my JSP working properly i get error as dsn name not found and driver not initialized may be im iWS is not able to fetch the path of jdbc driver how to set the classpath rep soon allam Ewak

  • Why does firefox makes multiple profiles

    My name is Mike from the helpdesk of YER. We have one user with the same problem over and over again. Our employees have a roaming profile with multiple browsers, but he uses Firefox wich is causing a problem. There is a datalimit on our user profile

  • Raid Driver Update..

    MSI released a new Raid Driver for my 990FXA-GD80, the older ver. is from 2009.. if I'm remembering correctly. Can I update the driver version without a restore? Possibly using 'Repair'? Thanks