Using fonts and CSS

I know a font that it is not installed in the system can be used the following way
BufferedInputStream bis = null;
try {
    bis = new java.io.BufferedInputStream(new java.io.FileInputStream("C:\\ProggyTiny.ttf"));
    final Font font = Font.createFont(Font.TRUETYPE_FONT, bis);
    font.deriveFont(Font.PLAIN, 12);
    // Now you can do jLabel.setFont(font); or something like this
} catch (Exception e) {
    e.printStackTrace();
} finally {
    try {if (bis!=null) bis.close(); } catch (Exception e) {}
}But I'm using a JTextPane in order to show some HTML content. The html code is styled using CSS. How can I use a current font in a CSS rule?

OK,
I have given up messing with stylesheets, trying display:
block, inline, different ways of formatting the XML, messing with
XML.ignoreWhiteSpace, and XML.prettyPrinting etc.
I went down the route of encodeURI, using a RegExp to strip
out all tabs, linefeeds and carriage returns. This now gives
consistent results for all situations, even embedded and none
embedded fonts.
e.g.
_text:String = TEXT FROM XML, HTML TEXT etc
var st:String = encodeURI(_text);
var pattern:RegExp = /(%09)+|(%0A)+|(%0D)+/g;
st = st.replace(pattern, "");
st = decodeURI(st);
YOUTEXTFIELD.htmlText = st;
The <p> tags still behave as a <br/> tag, but you
can add an extra <br/> to simulate a paragraph.
Here is the example again with the updates,
Hope this helps someone

Similar Messages

  • Developer-Online: Create a Digg login style using jQuery and CSS

    Create a Digg login style using jQuery and CSS
    Hello Friend, today We'll see how to create a Digg Login panel using only CSS3 and a bit of jQuery script. You'll see how is simple present a login feature using a modal window creates by js. You'll find the .ZIP tutorial visiting: http://www.beatfly.com/download.php
    Tags:    tips & tricks | JS
    Author: patrizio Quatrini
    Posted: 2010-02-04 10:57:48
    Brought to you by: Developer-Online

    Thanks Leonard
    On the surface that looks a mighty powerful product that probably goes far beyond what we require. Looking at the system requirements, it seems that some specific Application Servers are needed (is this correct?), which we won't have. Am I correct in thinking this is a modular based product, in that I buy a base product (being LiveCycle ES ... not sure what this product does on it's own) and then add a module such as PDF Generator to it?
    It's difficult to glean from the product web site exactly what this product is all about but my gut feel is it'll be a few steps beyond what we need to achieve. I might be wrong, so feel free to pull me up there but it seems this is along the lines of a total back-end Adobe solution.
    If you have any other suggestions I'd be grateful, otherwise I may need to continue down the "clunky yet serviceable" HTML to PDF route
    Adrian 

  • [J2ME MIDP 2.0] Alert, how to use fonts and colors?

    good morning,
    does anyone know in which way I can use colors in an alert pop-up?
    I've done my on using the code below. I would like to have text and images centered in the screen display and I would also like to use the colors I'm using in the application I'm writing.
    thx in advice,
    Omar
    private void alertDisplay(String s){   
        Alert a = new Alert("Location set to " + s.toUpperCase());   
        if(s.startsWith("H"))
          a.setImage(hOn);
        else
          a.setImage(oOn); 
        a.setString("Actual Location: " + s.toUpperCase());
        a.setTimeout(2000);
        a.setType(AlertType.INFO);
        Display.getDisplay(this).setCurrent(a);
        Display.getDisplay(this).vibrate(1000);
        Display.getDisplay(this).flashBacklight(1000);
      }

    Hi,
    The way how an Alert looks like cannot be influenced. When setting an image, you cannot indicate where that image should be placed. When setting a certain message text, you cannot influence its colour, its font and its allignment...
    The colour and font properties are theme / skin dependent on your mobile. When switching your mobile to another theme, then you will notice that your Alerts (and Forms and Lists, etc etc...) are coloured (titlebar, command softkeys, textfields) according to that theme.
    Cheers,
    Jasper

  • Custom Scrollbars in Firefox using HTML and CSS

    With the updated Firefox I can no longer use my custom css scrollbars. Are the completely gone or is there a new way to build them?
    ::-webkit-scrollbar {
    width: 5px;
    /* Track */
    ::-webkit-scrollbar-track {
    /*-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.8);*/
    -webkit-border-radius: 0px;
    background-color:#fff;
    border-radius: 0px;
    /* Handle */
    ::-webkit-scrollbar-thumb {
    -webkit-border-radius: 0px;
    border-radius: 0px;
    background:#fc8a3a;
    }

    See if this works;
    '''[https://addons.mozilla.org/en-US/firefox/addon/noiascrollbars/ NewScrollbars (aka NoiaScrollbars)]''' {web link}
    The "NewScrollbars"-extension replaces the default
    scrollbars of Firefox and Thunderbird with
    colorized ones (partly) known from "Noia themes".

  • Vertical menu using javascript and css

    Hi all,
    I have to build a vertical top-level menu for a customer. for a few days I surfing the internet to find a good sample. The only sample I found is http://javascript.internet.com/navigation/expanding-menu.html. this is what the customer wants. But this sample has just one level of subitems. I need a sample or source with dynamical levels of subitems. I'am not so formiliar with javascript and css to build it by my own very quickly.
    Has someone a sample for me or can someone change the sample so that I can use it in my toplevel menu.
    Richard

    Richard,
           Are you trying to implement this vertical menu at Portal's Top Level Navigation? If so, please be aware that these menu's might run into issues which SAP will not support.
            Also, there might be issues with upgrades on your portal. We have encountered the same for your client implementation and had to finally decided against the idea until SAP released their own version.
           Hope this helps.
    Regards,
    Winston
    PS: reward points if you find this useful

  • Design Region using HTML and CSS

    Hi,
    I need to design a region with HTML and CSS tags. Is there any tools available so that auto generated code gets that can be used inside the region. Please suggest.
    Thanks
    Sudhir

    See if this works;
    '''[https://addons.mozilla.org/en-US/firefox/addon/noiascrollbars/ NewScrollbars (aka NoiaScrollbars)]''' {web link}
    The "NewScrollbars"-extension replaces the default
    scrollbars of Firefox and Thunderbird with
    colorized ones (partly) known from "Noia themes".

  • How Do You Render a Component using styleClass and CSS?

    To create a special rendering for a component like a RadioButton how do you build and apply a CSS style to it? I tried using "styleClass" for a component and inserting a CSS command like "P.two{font-size:small}" but nothing happened. There were no warnings or errors in the "source view". Do I have to write a java bean with methods that have the CSS commands in them and somehow reference them from the XML "styleClass" attribute? If so does anyone have an example or can you point me to one?
    Any help appreciated!
    Thanks,
    newsjsc

    usually you put that in an external stylesheet (*.css) and import it at the top of the page...
    <html><head>
    <link rel="stylesheet" href="css/default_developer.css" />
    </head><body></body></html>
    that's the one for this page...
    or you can put the style tags right within the <head> tags
    <html><head>
    <style type="text/css">
    <!--
    .two {
    font-size: 23px;
    -->
    </style>
    </head><body></body></html>
    The better practice is to put stylesheets in an external file and include that one file across multiple pages or for your whole application. For some real cool CSS stuff, check out www.cssvault.com or css zen garden.

  • Font and CSS in HTMLDocument

    I try to read an HTMLEditorKit. But when there is a font tag in my HTML I have an exception :
    Exception in thread "main" java.lang.NoClassDefFoundError
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:120)
    at java.awt.Toolkit$2.run(Toolkit.java:500)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.awt.Toolkit.getDefaultToolkit(Toolkit.java:491)
    at javax.swing.text.html.CSS.getValidFontNameMapping(CSS.java:932)
    at javax.swing.text.html.CSS$FontFamily.parseCssValue(CSS.java:1789)
    at javax.swing.text.html.CSS.getInternalCSSValue(CSS.java:531)
    at javax.swing.text.html.CSS.addInternalCSSValue(CSS.java:516)
    at javax.swing.text.html.StyleSheet.addCSSAttribute(StyleSheet.java:436)
    at javax.swing.text.html.HTMLDocument$HTMLReader$ConvertAction.start(HTMLDocument.java:2536)
    at javax.swing.text.html.HTMLDocument$HTMLReader.handleStartTag(HTMLDocument.java:1992)
    at javax.swing.text.html.parser.DocumentParser.handleStartTag(DocumentParser.java:145)
    at javax.swing.text.html.parser.Parser.startTag(Parser.java:333)
    at javax.swing.text.html.parser.Parser.parseTag(Parser.java:1786)
    at javax.swing.text.html.parser.Parser.parseContent(Parser.java:1821)
    at javax.swing.text.html.parser.Parser.parse(Parser.java:1980)
    at javax.swing.text.html.parser.DocumentParser.parse(DocumentParser.java:109)
    at javax.swing.text.html.parser.ParserDelegator.parse(ParserDelegator.java:74)
    at javax.swing.text.html.HTMLEditorKit.read(HTMLEditorKit.java:242)
    at HtmlMail.main(HtmlMail.java:35)
    Do you know the way to avoid this error ?

    I have this problem with Solaris and not with windows

  • CC Desktop; using Fonts and Storage

    When I login to CC Desktop I am told that CC Storage and Fonts are not yet available. Is this true?

    nciscyber - obviously you understand this stuff which is wonderful.  Can you please give me the novice explanation of what you just posted?   I have the same issues / screenshots as posted above. 
    SInce I have PS CC shouldn't I be able to save / open files from the CC from inside PS?  I expected to see a "save" option (in addition to my hard drive folders) for my Creative Cloud.  My misunderstanding?   Is this "coming soon"?  Thanks so much.   

  • Documentation for FXML and CSS

    Where can I find documentation that lists all the different things you can do using FXML and CSS for JavaFX?
    For example, how am I supposed to know that I can do "-fx-font-size: 12px" for font size in CSS or "Font name='System' size='12.0' />" for FXML?

    CSS Styling
    Here is the css reference guide, which is an excellent start.
    Complement it by thoroughly studying caspian.css (the JavaFX 2.2. stylesheet) and modena.css (the JavaFX 8 stylesheet).
    There is also css styling info scattered throughout the Oracle JavaFX tutorials.
    Try using the material from the css reference guide to style some of the simple default controls, like buttons etc.
    Once you have the hang of that, move on to more complex things like graphs and tables.
    Don't forget tricks like overriding some of the default paint constants as it makes styling much easier if all you need is a color change, for example try the following stylesheet:
    .root { -fx-base: antiquewhite; }
    FXML Reference
    There is (and never will be) any such thing (as least not a complete one).
    FXML works by reflecting on classes.
    As you can add more classes to your classpath or modify existing classes, you can add more elements and attributes to fxml.
    Best current documentation of fxml is the Introduction to FXML as well as the FXML tutorials from Oracle.
    In terms of learning some of the more common elements and attributes for FXML for standard JavaFX controls, try loading up SceneBuilder and examining the FXML it generates.
    Also, as FXML is a reflection of the JavaFX Java API, you can get to know what attributes and elements it can use by looking at the standard JavaFX javadoc.
    All that said, I think the FXML documentation could be improved, so if, after you go through in detail studying the available information I provided in this post, you have concrete ideas for improvement of the documentation, feel free to file specific detailed requests in the JavaFX issue tracker, or send feedback to the JavaFX documentation team's email address: [email protected]

  • PL/SQL Server Pages (PSPs) and CSS

    Hi,
    I am used to creating standards compliant websites using XHTML and CSS and some other application language for dynamic content. I have recently started working with PL/SQL and want to create an application using PSPs. I was wondering the best way to go about including CSS in an application, because it doesn't make sense to duplication the CSS on each page, but since the PSP is converted to a procedure this seesm to be the only way to include CSS?
    Any ideas on best practice for using CSS with PSPs?

    I think you should be able to put all your CSS into a single file, or only a few files, like in a normal web project and that you can include this file using the regular HTML tag.
    You store your CSS file(s) in a folder that is accessible by your website. Normally this is achieved by adding an Alias in the Apache webserver that is embedded in the Oracle database.
    If I remember it correctly (it has been a while since I saw the embedded webserver) your request for your PSP goes to an url like http://your.server.com/pls/your_page. Everything of the url that comes after /pls/ is handled by the mod_plsql Apache module that is repsonsible for sending the request to the database and returning the result to the screen.
    If you can define an alias like 'css' (without the quotes), which makes the url something like http://your.server.com/css/, then you can try to include your CSS file(s) referring to /css/file.css. Once you get this working, you can do the same for images.
    This is a generic approach that can get you started hopefully.
    Good luck.
    I hope this can get you started. Information on the alias can be found

  • Java Swing/AWT and FX is so old school! Give me HTML and CSS for GUI!

    Dear Java,
    I am a seasoned programmer and I feel it's time JAVA implements a GUI system where it uses HTML and CSS for the GUI. For the love of god just look at the interfaces you can make using HTML and CSS alone. I am a big fan of Java Swing and the recent GUI designer for FX is quite cool. But they are just not as simple as HTML and CSS. And JavaFX has some interesting requirements for the graphics.
    I know it is possible to use JavaFX and implement the WebView/WebDriver and make it load a HTML page, etc... but why go through all the trouble?
    Just imagine... if you make Java where it has powerful back-end to do what it does best and the HTML/CSS powered GUI on the front-end. It will make the lives of many developers much much easier.
    I am not sure whether a Swing designed GUI will be faster than a HTML designed GUI... but if you look at a traditional browser and how fast it renders HTML/CSS, I am sure if Java had a native Form where it uses HTML and CSS to render the GUI, Java will make the dreams of many programmers a reality.
    Make it happen!!!!

    Check this i solve problem just now using this
    https://wiki.archlinux.org/index.php/Ja … ow_Manager

  • Using MySql and PHP with Dreamweaver on a Mac

    Hello all,
    As always if the answers to these questions are obscenely
    obvious please humour me.
    I use XHTML and CSS in my websites and realise that it is
    time that I dabbled with SSI. So I've started using PHP.
    However, I have been following the installation directions of
    MySql and am running into problems. I am installing the relavent
    software and am then unable to find it on my Mac, the startup files
    are there but the actual MySql data appears to not be installed
    despite my computer telling me it is...... I am using a G3 running
    OSX 10.4 is this good enough? I noticed talk of needing a PowerPC
    or Intel mac. Is this the case?
    Also, would I need MySql installed on my actual computer if
    the my servers have it already? And does Dreamweaver 8 have both of
    these programs installed as standard?
    If you could help out I would be very appreciative as I would
    like to learn this stuff and I appear to be struggling at the
    outset....
    Cheers
    M.A

    M.A.Wilson wrote:
    > However, I have been following the installation
    directions of MySql and am
    > running into problems. I am installing the relavent
    software and am then unable
    > to find it on my Mac, the startup files are there but
    the actual MySql data
    > appears to not be installed despite my computer telling
    me it is...... I am
    > using a G3 running OSX 10.4 is this good enough? I
    noticed talk of needing a
    > PowerPC or Intel mac. Is this the case?
    MySQL is a relational database management system that
    comprises a
    database server and several utility programs. Although you
    install it
    like any other program on a Mac, the similarity stops there.
    First, the point about PowerPC and Intel Macs is that there
    are
    different versions of the MySQL installer for each type of
    processor.
    I'm pretty sure that a G3 is OK, but you must choose the
    PowerPC version
    of MySQL, not the 64-bit or x86 (Intel Mac) version.
    Once you have installed MySQL, you need to drag the
    MySQL.PrefPane icon
    from the disk image onto your System Preferences. This
    installs a
    Preference Pane that enables you to start and stop MySQL. The
    Preference
    Pane has an option to start up MySQL automatically, but in my
    experience, it doesn't work on Tiger. You need to open the
    Preference
    Pane, and click Start MySQL Server each time you start your
    computer.
    The best way to work with MySQL is to use a graphical
    interface, such as
    phpMyAdmin. As Osgood has mentioned, I have written a book
    about PHP and
    Dreamweaver, which goes into all the necessary details. It's
    also very
    Mac-friendly with separate instructions where necessary for
    PC and Mac.
    More details here:
    http://foundationphp.com/dreamweaver8/
    David Powers
    Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
    Author, "Foundation PHP 5 for Flash" (friends of ED)
    http://foundationphp.com/

  • I just updated my Firefox browser to Firefox 8. I am a college student and practice with HTML and CSS for class assignments. The fonts in all my html documents are being overwritten online by your script typeface. How do I resolve this issue?

    I just updated my Firefox browser to Firefox 8. I am a college student and practice with HTML and CSS for class assignments. The fonts in all my html documents are being overwritten online by your script typeface. I did not have this issue in the older version. I use an iMAC running OS10.6.8. How do I resolve this issue?

    Starting with this, you have errors in your CSS code.
    body {
      margin-top: 0px;
      margin-right: 0px;
      margin-bottom: 0px;
      margin-left: 0px;
      color: 151515;
      font-family: "Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu Sans Condensed", Helvetica, Arial, sans-serif;
      background-color: EFF5F8;
    body {
      margin:0;
      color: #151515;
      font-family: "Gill Sans", "Gill Sans MT", "Myriad Pro", "DejaVu Sans Condensed", Helvetica, Arial, sans-serif;
      background-color: #EFF5F8;
      font-size: 100%;
    Related links:
    Windows Chrome, why do my fonts look so bad? - Lee Green
    css3 - Bad font rendering Chrome - Stack Overflow
    Nancy O.

  • I am using Illustrator CS5. I am using a certain font and when I make a selection to use one of the letter options or a glyph, it does not take my selection; in other words, nothing changes.

    I am using Illustrator CS5. I am using a certain font and when I make a selection to use one of the letter options or a glyph, it does not take my selection; in other words, nothing changes.

    What font? What system? What Glyph? What language settings? Could be anything. Either way, ask in the AI forum. You'll get quicker answers there - if you provide all the required info.
    Mylenium

Maybe you are looking for

  • Error with JAVA_HOME enviro variable

    I'm running win2k Pro. I installed first j2sdk1.4.1 and then tomcat 4.1.12 on my e:\. When I click START TOMCAT i recieve the error in a dialog box: Cannot find the file '-Djava.endorsed.dirs='(or one of its components). Make sure the path and filena

  • EJB environment question (static helper classes)

    We're using JBoss as AS containing several stateless session beans. Now, we have certain helper classes that are abstract and contain static methods. Is this a problem for the EJBs? All of them use these helper classes all over their methods. Are the

  • Real Quick Commissions Reviews Released by Jeff Carter

    Real Quick Commissions Review are entrance in all the measure instantly. A portion of colonize suffer taken Jeff transporter up on his novel invention Real Quick Commissions transporter and colonize are already getting results and bearing in mind an

  • E-mailed attached images from I-photo are always highly compressed

    When I attach an image (e.g. 2.5mb) to an e-mail then send it, the recipient finds it has been reduced to approx 50kb and is pixellated. How can I avoid this happening.

  • Watermark is being reduced to nothing in Aperture

    Hi, I created a watermark in Photoshop and I loaded it in a preset. The Photoshop image size is 640x480 pixels and the preset in Aperture is for Original Size, 72 DPI. The watermark in Photoshop is quite large, but when I export a photo with the wate