Font sizing issues with JTextPane

Hello all,
I have a question which I hope won't be too difficult. Here is some background. I have created both a swing application that is a text editor. The user can cut, copy, and paste text. The user can also change the "font style" and "font size" through a series of combo boxes. When the application is launched there are 2 user inputs which indicate the size of the JTextPane area. For example, the user would type in: >java texteditor 2.5 3.0
and the editor launches with a JTEXTPANE width of 2.5 inches and height of 3.0 inches. This is to be a WYSIWYG type editor which will eventually print what is contained in the JTextPane.
Finally my question. When the user decides to change the font size, I have noticed that the font size does not appear to be the correct size as compared to a MS Word Font Size. For example, I type a phrase in MS Word and set the font size to be 12, and I type the same phrase in my JTextPane to be 12, the text in the JTextPane is much smaller. I actually have to set the font size to be 16 in the JTextPane to match the MS Word Font size. I have used many differnt fonts and in every single case the in JTextPane I have to add 4 to the font size to make it match the font size of the same phrase in MS Word. Does anyone have any idea what is going on here? Does Java (I am using JDK118, it's REQUIRED on my part and swing 111) have it's own font rendering engine that is different than what I see in MS Word? Why would 2 fonts, 1 in MS Word and another in a JTextPane, appear differently? The JTextPane is always 4 too small. I can compenstate for this by adding 4 but that does not tell me why it is happening.
joberoni

Thanks for your response Eric. I have made sure that the view I am looking at in Java is in fact 100%. I realize what represents, for example, 3 inches in ms word according to thier "rulers" does not actually represent 3 inches. That actually depends on the screen resolution and pisels per inch. And while I realize that the font I see on the screen is not the same font that is printed, I still expect to see in Java and in ms word, 2 fonts b appear to be the same size if both are being rendered at 100%. I even did the same experiment in Notepad which and a paint program and I get the same result. I can't help but think if I define a 3 inch area in any program, be it any word processor or graphics program, that the font sizes for a given font should appear the same size. And while the printed font is something completly different, I still still don't understand why the screen fonts appear in a smaller size in a Java JtextPane and probably other controls as well. I just don't get it.
joberoni

Similar Messages

  • Font smoothing issues with Samsun 23 inch LCD

    I am having a font smoothing issue with my MacBook and my Samsung LN-S2352W 23 inch LCD (http://www.samsung.com/Products/TV/LCDTV/LNS2352WXXAA.asp). I am using the mini-DVI to VGA adapter and the plugging that into the VGA port of my LCD. It doesn't matter which app I run, but as long as it has fonts, they come out blurry, hazy, colors bleed, etc.
    I have played with the font smoothing settings and that has not helped at all. I have heard of TinkerTool and will try it to see if it makes any difference, but am not expecting much.
    I also have a PC running Windows Vista and I connected it to the VGA port of my LCD. Wow...the difference in picture quality was astounding. I'm ******. I want my MacBook to look that sweet on my LCD.
    Anyone have any thoughts? Can this be fixed?

    TinkerTool didn't make any difference for me. I played around with it and found that there was no improvements using it or disabling font smoothing.
    I have watched DVD's on this LCD being played with my MacBook. I have seen 2MB+ full screen digital pictures. Both the DVD and digital pics look absolutely amazing on it.
    It's only the fonts that appear blurry or in some areas they appear to have a shadown to the right. This happens with any text that appears in every app.
    Keep in mind too, Windows Vista looks perfect on this display, but my prized MacBook looks really sub-par.
    I'm not quite following you on changing the display preferences to change to pixel size to that of the MacBook...

  • Font color issue with inserted HTML content in JTextPane (HTMLEditor)

    Hi everyone,
    I have a very serious issue with the HTMLEditor I'm developping. This editor is a little bit special since it is intended to edit blocks of HTML content that are loaded when the editor is initialized.
    You can in fact decide to keep this loaded HTML content or start a new HTML document from scratch. Alright, now my issue is the following :
    When text is loaded, it's properly rendered. I have a functionality which let's you see the HTML code from the HTML document used in the editor, so I can check and see if code is correct, and yes, it's correct.
    The problem is that when I try to change the color attribute of some text on my loaded content, nothing happens ! I don't know what's the matter with this bug, I only have it with the color attribute, with every other attribute everything's fine (font, size, etc.)
    The funny thing is that, after I change another attribute for loaded content, like font family, then changing color attribute funcionnality starts to work again !
    I've also noticed that I don't have any of these problems when I start my HTMLDocument from scratch (when I create a new HTML document and start typing text).
    Another weird thing, is that I have a feed-back feature in my editor which reflects attributes for text over which the caret is positionned. For example, if you put caret over red text, the color combo box displays a red value, you know, just like in MS Word. Well, with my loaded content if I have a red text color and I decide to put it in green, the color combo box displays the green value when I click over text for which I have changed color, but in my JTextPane it's still red !! And when I try to see the HTML code generated nothing has changed, everything is still red !
    There is something really strange here, this means that when I get the attributes of the loaded text from the HTMLDocument, color appears to be green, but when it gets rendered in the JTextPane it's still red and when it gets anlyzed to produce the corresponding HTML code, these changed attributes are not taken into account.
    But the most weird thing above all, is that I don't have this bug everytime, sometimes I start my HTML editor applet and it works fine, and some other times this color issue is bakc there. Is this a known bug for Swing API or not ?
    =============
    This is more or less my technique :
    //I declare a global reference to my HTMLDocument
    HTMLDocument _docHTMLDoc;
    //Create a JTextPane
    JTextPane _tpaEditor = new JTextPane( );
    //Set type content to automatically select HTMLEditorKit
    _tpaEditor.setContentType("text/html");
    //Get a referene to its HTMLEditorKit
    HTMLEditorKit _kitHTMLEditor = (HTMLEditorKit) _tpaEditor.getEditorKit( );
    //I then have a function to create new documents
    void newDocument(){
      _docHTMLDoc = (HTMLDocument) _kitHTMLEditor.createDefaultDocument();
      _tpaEditor.setDocument(_docHTMLDoc);
       //I do other stuff wich are not important to be shown here
    //I then have another function to load content
    void loadContent(){
       //I get content from a HashMap I initialized when I started my applet
       String strContent = (String)_mapInitParameters.get("html_content");
       //I set content for my editor
       _tpaEditor.setText(strContent);
    //Notice.. I have tried many other ways to load this text : via HTMLEditorKit and its insertHTML method, I
    //have also tried to store this content in some reader and make HTMLEditorKit read it... and nothing,
    // I always get the bug
    //To change color it goes like this :
    JComboBox _cboColor = new JComboBox();
    //I correctly initialize this combo with colors
    //then I do something like this
    ActionListener _lst = new ActionListener(){
       public void actionPeformed(ActionEvent e){
          Color colSel = (Color) _cboColor.getSelectedItem();
          MutableAttributeSet mas = new SimpleAttributeSet();
          StyleConstants.setForeground(mas,colSel);
          setAttributeSet(mas);
    _cboColor.addActionListener(_lst);
    //Set Attributes goes something like this
    private void setAttributeSet(javax.swing.text.AttributeSet atrAttributeSet) {       
            //Get current 'End' and 'Start' positions
            int intCurrPosStart = _tpaEditor.getSelectionStart();
            int intCurrPosEnd = _tpaEditor.getSelectionEnd();
            if(intCurrPosStart != intCurrPosEnd){
                //Apply attributes to selection
                _docHTMLDoc.setCharacterAttributes(intCurrPosStart,intCurrPosEnd - intCurrPosStart,atrAttributeSet,false);
            else{
                //No selection : apply attributes to further typed text
                MutableAttributeSet atrInputAttributes = _kitHTMLEditor.getInputAttributes();
                atrInputAttributes.addAttributes(atrAttributeSet);

    hi, friend!
    try this:
    void setAttributeToText(JTextPane pane, int start, int end, Color color) {
    MutableAttributeSet new_att = new SimpleAttributeSet();
    StyleConstants.setForeground(new_att,color);
    HTMLDocument doc=(HTMLDocument)pane.getDocument();
    doc.setCharacterAttributes(start,end,new_att,false);
    It works fine in my Application, hope will work in yours, too.
    good luck.

  • How do I avoid sizing issues with a Bevel?

    I am designing a logo for a startup business, and a beveled filter really looks nice for this particular company. The client really likes what I came up with. The problem is the filter seems to cause sizing issues. Enlarging it is creating ugly pixelation. Is there a method for avoiding this, or can I simply not use a bevel?
    Thanks.

    In the preferences check scale strokes and effects

  • Font/Type Issue with Slideshow & Transitions

    DVDSP 4.1.0. I've created a slideshow in DVDSP. I created all the photos in Photoshop.Each has a small caption at the bottom created as part of the actual photo. When I create a slideshow in DVDSP everything looks great. However, if I had a transition to the slides (say a fade through color for 1 second) the type on the caption looks crazy bad on SOME DVD players. Looks fine on my computer and two of my DVD players, but on one other one (and unfortunately my clients) DVD player the type looks very bad when the transitions have been added to the slideshow. The photo still looks great, but the type at the bottom looks horrible. Clearly it's an issue with some DVD players and some don't seem show the problem. Just wondered if anyone had any insight into this problem. Thanks.

    hi, friend!
    try this:
    void setAttributeToText(JTextPane pane, int start, int end, Color color) {
    MutableAttributeSet new_att = new SimpleAttributeSet();
    StyleConstants.setForeground(new_att,color);
    HTMLDocument doc=(HTMLDocument)pane.getDocument();
    doc.setCharacterAttributes(start,end,new_att,false);
    It works fine in my Application, hope will work in yours, too.
    good luck.

  • Font size issue with the email functionality of infopath form

    Hi,
    We have a SharePoint list created and customised the form to send the form via email using email functionality in infopath form.
    We have made the font size of the form fields( rich text box) to 11. But it is showing as 10 in email. Also for a text box we set the font size to 14. But it is 13.5 in the email.
    Could anyone please let me know how to fix this issue?

    http://social.technet.microsoft.com/Forums/sharepoint/en-US/afbd9fc3-b8d3-4ef9-a8bf-9cb136d12039/formatting-problem-with-email-from-an-browser-enabled-infopath-2010-form-in-sharepoint-2010?forum=sharepointcustomizationprevious
    Yes, this is normal. Forms Services has to convert the form to an aspx page, and things get lost in translation when this gets submitted via email.  My workaround has always been to set static widths to columns/controls, but you said that didn't work
    for you?  It's always worked for me.
    https://go4answers.webhost4life.com/Example/infopath-send-form-email-162481.aspx
    http://www.formotus.com/15413/blog-infopath/making-the-most-of-email-submit-with-infopath-and-formotus-forms

  • How do I solve my FONT conflict issue with the system Helvetica Neue

    Everytime I start up in Leopard I get the error message "There is a conflict with the "HelveticaNeue" font file". How do I resolve this issue? I require the Postscript versions of Helvetica Neue for my design programs. I use Linotype FontExplorer to manage the fonts. Is there a way to rename these postscript versions so they don't conflict?

    Currently, the only way is to remove Apple's supplied versions of Helvetica. They have exactly the same internal names as the PostScript versions. Follow the instructions in section 4 of my article, Font Management in OS X, to see how to do that.
    The link, or one of the links above directs you to my personal web site. While the information is free, it does ask for a contribution. As such, I am required by Apple's rules for these discussions to include the following disclaimer.
    I may receive some form of compensation, financial or otherwise, from my recommendation or link.

  • Font color issue with animated text in Captivate 5

    When I prepare a new animated text and open the property and then click the square to choose a color , I only get a  little part of the color panel (when I click the color box) and I have  no possibilities to enter the color code either:
    I'm working with a Windows XP, 64 bits desktop and I have Captivate 5 version 5.0.1.624.
    Any ideas to solve this issue would be appreciated as it is becoming urgent for me.

    @Lieve: You're on the French version of Captivate 5 aren't you?
    Can you provide a screenshot of what the Animated Text font colour dialog looks like on your PC and upload it here?
    This is what that box looks like for me:
    It seems that on this user's PC the colour picker isn't able to float on top of the dialog as it should.
    I encouraged Valerie to post her issue on this forum in the hope that one of the Captivate developer technicians would chime in with a possible solution.  I think this one has got to be some kind of bug due to a language version of Cp.

  • Font style issue with exporting report in Crystal Reports 2008

    Hi,
    I got stuck on the below issue for a while. Please can anyone help on this?
    When I designed and executed a report in Crystal Reports 2008 on my local PC, the font style and size used in charts were exactly what I was expecting.
    However, after I exported the report to our BusinessObjects CMC and displayed it in InfoView, the font style and size in charts looked quite different from what they were in CrystalReports.
    Any ideas of how to fix this issue?
    Thanks!
    BAI

    Hi Nanda Kishore,
    This is because you do not have proper rights on Business View Manager.  Whenever you create a dynamic parameter in crystal and try to save the report on BO, it creates a Business view automatically.  Now in your case, it is unable to create a business view due to insufficient rights.
    Go in Business View Manager u2013 Repository exploreru2014You will find Dynamic Cascading Prompts folderu2014Right click on that and go in rights and add your user information and give full rights.
    Also make sure that your BO and CR designer on same version and patch level.
    Thanks,
    Sastry

  • Font Mapping issue with Arial Unicode MS font

    Hi All,
    I was able to do font mapping for Arial Unicode MS font (.ttf) in BIP version 10.1.3.4.
    But after applying the patch 10256764 I am not able to see the Arial Unicode MS font in the Font Selection drop down box in BIP .
    I have copied some other .ttf fonts to the .\ jre\lib\fonts folder and they are appearing in the BIP
    Does BIP patch 10256764 not support Arial Unicode MS font ?
    Please help me...
    its resolved .Font name extention should be in lower case (.ttf)
    Edited by: deepz on May 5, 2011 10:15 PM

    There is no BOLD font TTF files for Arial Unicode MS.  No resolution at this point of time. Closing the issue.
    Edited by: vamsee m on Apr 27, 2011 9:29 AM
    Closing this issue

  • Sizing issues with macbook

    Hi,
    I've got a Macbook with os 10.4.11 and two problems re: sizing.
    1st-I can't get it to print the full size on my canon mp830 printer. It reduces to about a third of the size and moves to the top left corner. I've tried everything I can think of to no avail. My wife has the exact same computer and hers works fine.
    2nd-I can't reduce the size of photo's from iphoto and move them to my hotmail account. They are huge. Again, I've tried everything I can think of and it doesn't work.
    I've posted these Q's before and tried what was suggested, but they didn't work.
    Any other ideas would be greatly appreciated.
    Thank you

    1) Go here: Macintosh HD > Users > YOURUSERNAME > Library > Preferences and delete the following files:
    com.apple.print.add.plist
    com.apple.custompresets.plist
    com.apple.print.printerproxy.plist
    com.apple.print.printingprefs.plist
    Don't worry if all 4 files aren't there, just delete the ones that are.
    2) Go to System Preferences > Printers and remove your Cannon printer completely. Delete the whole thing. Then, restart your computer and re-add the printer by returning to System Preferences > printers.
    3) As for iPhoto, when you want to email a photo, choose "Email" from the bottom of iPhoto. A box pops up that asks you what size you want to send the photo as. Choose from small, medium, or large.

  • Font printing issue with InDesign CS4

    Hello all,
    I am at my wits end with a small but particular problem. I have an InDesign publication that is using a "Hands" font. For some reason, InDesign will not print a particular text box with just one "hand" character. However, it will print the same hand character in another text box. He're the other weird part. When I export the document to a PDF, the missing hand prints just fine! InDesign just doesn't want to print this particular box and font. Has anybody ran into this problem before?
    Thanks a bunch!

    Alec is right the easies way to handle this is to create Outlines which effectively converts the type to a vector shape.
    To be on the safe side I always drag a duplicate of my type outside the print area directly to the left using alt + shift key, that way i still have live type that I can edit if I have to go back. It also keeps the font embeded in the document when I package it so it can be identified by the pritner if needed for some reason.Then I export the PDF and run a Acrobat PRO preflight just to be safe and correct anything in the profile.

  • With Flash Catalyst - sizing issue with artboard

    i have created an artboard along with all my images etc. 900 x 300 all my images sit outside these boarders, when i check to see how my project is working part of the images to the right of the artboard come up in plain view.  I have checked my artboard size and moved my images further to the right and they keep coming up. 
    Can anyone help me.
    Confused.

    Hi Bear,
    Thanks for the email i have tried to do the whole clipping thing i can see how it would work in certain scenarios but when i did it, it took away all my interactions etc.
    I did the toggle thing which did work for the images but not the writing. 
    My artboard is 900 wide so i moved my wrting all the way over to 1200 on the right to get it off the screen.  my main problem is now when i put into dreamweaver html and play looks fine, but when i upload to internet i have all that extra room on the right and a little on the bottom.
    One thing that confuses me is that i have images on the left and they dont show up at all the artboard only extends to the right and a little on the bottom out of the artboard specified size.
    help kathy

  • Sizing issue with self webcamsubscriber

    i'm stumped, this could be simply a flex container behavior that i'm not understanding, but i can't see why this is happening.  i have a WebcamSubscriber displaying my own webcam.  it's "selfWebcamSubscriber" as seen below. when i log into LCCS directly, the WebcamSubscriber properly stretches to fill the entire width and height of its container.
    however, when i log in using external authentication first, the WebcamSubscriber seems to have an aspect ratio forced on it, looks like a 2/3rds ratio.  it does not stretch to fit the width and height of the container.  for example, if the width/height of the container of WebcamSubscriber is 200px/200px, the height of WebcamSubscriber gets forced to 120px.  
    i'm very confused as to why this is happening only when i do external auth.  is there a maintainAspectRatio flag somewhere? or am i using containers improperly?  an obscure question i know, but i'm totally stumped on this one. 
    <rtc:ConnectSessionContainer id="connectSessionContainer" autoLogin="false" width="100%" height="100%">
    <s:VGroup width="100%" height="100%">
    <s:HGroup id="webcamsHGroup" width="100%" height="70%">
    <view:WebcamsView id="webcamsView" width="50%" height="100%"/>
    </s:HGroup>
    <view:TimerView id="timerView" height="20" visible="false"/>
    <s:Label id="appURLLabel" width="100%" height="16" />
    <s:HGroup width="100%" height="200">
    <rtc:WebcamSubscriber id="selfWebcamSubscriber" width="20%" height="100%"/>
    <s:HGroup width="100%" height="100%">
          <rtc:SimpleChat height="100%" width="100%" sessionDependent="true" />
         <rtc:Roster id="userRoster" width="200" height="100%" />
    </s:HGroup>
    </s:HGroup>
    </s:VGroup>
    </rtc:ConnectSessionContainer>

    I remember using it with Chrome and it worked but there was some goofyness with the interface.  I think after each module I needed to exit, go back to the main menu for module selection and refresh, then pick the next one.  I couldn't just go to the next module.  But it definitely saved progress.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

  • Font subsetting issue with srw.run_report

    I have PDF subsetting as
    "Courier" = "MSGOTHIC.TTC"
    I have a report emp.rdf. This emp report just displays the data from emp table.
    I have a report dept.rdf. This dept report just displays the data from dept table.
    In the after report trigger of the dept, I added
    srw.run_report(report=emp destype=file desname=emp.pdf desformat=pdf);
    I am running the dept report from command line as
    rwclient server=<servername> userid=<user/pwd@db> report=dept destype=file desname=dept.pdf desformat=pdf
    The report hangs. I tried moving the after report trigger to before report trigger and it fails too.
    Any ideas?

    Hi,
    Can you try running this report from the Reports Builder, ie, use File > Generate to file > pdf, and see if both the master and child files are generated.
    If yes, can you post both server and engine trace file contents (last few lines) of the instance when you run it from the server, and not from Builder.
    Navneet.

Maybe you are looking for

  • How can I install Adobe inDesign without optical drive?

    I have Word and a few other programs that are on CD's how can I put them on my MacBook Pro w/ retina display? Do I have to go to the apple store? Or buy that external DVD/CD Drive?

  • Acrobat sdk 9 wizard problem!

    Developing acrobat plug_in with the acrobat wizard ,slecting using mfc,. I creat a dialog in resource  ,when I call the domodal function ,the program crash,why? the program select using mfc in shalled dll,so I use the AFX_MANAGE_STATE marco ,but caus

  • Hyperlinks issues on iweb

    I have created a hyperlink and have altered the colour to make it stand out on the web, however, whenever i ckeck the website the hyperlinks are still in the default colours. why are the adjusted colours that i have used not showing up?

  • LaCie external HDD no longer recognised.

    I have a LaCie 500Gb d2 external HDD connected to my intel iMac via firewire 400. This has been working well until now. The HDD icon has disappeared off my desktop and while disk utility shows the disc present, it won't allow any communication with i

  • Unable to install Symantec Antivirus on Windows XP Partition.

    My son just bought a macbook for college. I installed XP through Boot Camp. He gets a free Norton Antivirus download from school. When I downloaded it and attempted to install it through Windows, I got a message that it could not be installed on the