Creating fonts based on pixels size

Hi i'am still a java beginner and i am switching from .NET so anyone can help on how can I create a font based on Pixels size rather than Point Size

You can translate between points size and pixels size using the DPI:
http://java.sun.com/products/java-media/2D/reference/faqs/index.html#Q_Why_does_eg_a_10_pt_font_in_Ja
Dmitri

Similar Messages

  • Check the pixel size on runtime

    Hi all
    can any one tell me is there is any trigger which check the pixel size of user screen???i am using oracle 9iIDS and run on LAN....the problem is that i have create the form on pixel size 1024x768....now some user on LAN has pixel size 800x600...so the problem is that the forms doesn't look better on that pixel....i want that when form run it check the pixel size....if it is 1024x768 then ok if it is 800x600 then it prompt a message that u change ur pixel size to 1024x768.....
    Is it possible to do????
    plz reply
    thanks in advance
    shayan
    [email protected]

    now i am using this code
    declare
    al_button alert := find_alert('pixel');
    al_id number(5);
    width number(5) := get_application_property(display_width);
    height number(5) := get_application_property(display_height);
    LC$Scoord VARCHAR2(100) := Get_Form_Property( Name_in('system.current_form'), COORDINATE_SYSTEM ) ;
    begin
    -- Conversion of offset in pixel --
    If LC$Scoord = 'INCHES' Then
    width := width * 0.0104 ;
    height := height * 0.0104 ;
    ElsIf LC$Scoord = 'POINTS' Then
    width := width * 1.333 ;
    height := height * 1.333 ;
    ElsIf LC$Scoord = 'CENTIMETERS' Then
    width := width * 0.0263 ;
    height := height * 0.0263 ;
    End if ;
    if width = 600 or height = 800 then al_id := show_alert(al_button);
    end if;
    end;
    that code compile successfully but not give the alert if pixel is 800x600

  • Set font size based on component size

    Hi everybody,
    This is kind of a duplicate, kind of new, because my original post is buried and I figured out a more helpful and general way to ask this question. Does anyone know if there is a way to set the size of a string as large as possible on a component, but still be able to have the whole string visible, if you're using a font other than default?
    For example:
    public static void main( String args[] ){
    try {
              JFrame frame = new JFrame( "Title" );
              frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
              int guiWidth = width / 2;
              int guiHeight = height / 2;
              frame.setSize( guiWidth, guiHeight );
              Container pane = frame.getContentPane();
              // Create main label
              String labelString = "Test";
              JLabel label = new JLabel( labelString );
              label.setBackground( new Color( 179, 0, 0 ) );
              label.setForeground( new Color( 235, 191, 16 ) );
              label.setHorizontalAlignment( CENTER );
              label.setOpaque( true );
              label.setFont( new Font( �Old English Text MT�, 0, 48 ) );
              pane.add( label, BorderLayout.NORTH );
              frame.setLocationRelativeTo( null );
              frame.setVisible( true );
    } catch( Exception e) {
    e.printStackTrace();
         }As you can see, right now the font needs to be hard coded. I'd like it to be dynamic, based on the size of the screen the user has.
    Sorry if the partial double post annoys anybody; I figured it would be less annoying than resurrecting my old post.
    Any help on this would be great, and thank you!
    Jezzica85
    Message was edited by:
    jezzica85
    Message was edited by:
    jezzica85

    import java.awt.*;
    import java.awt.event.*;
    import java.awt.font.*;
    import java.awt.geom.AffineTransform;
    import javax.swing.*;
    public class DynamicFont {
        private JLabel getNorth() {
            // Create main label
            String labelString = "Test";
            final JLabel label = new JLabel( labelString ) {
                public void paint(Graphics g) {
                    ((Graphics2D)g).setRenderingHint(
                            RenderingHints.KEY_TEXT_ANTIALIASING,
                            RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
                    super.paint(g);
            label.setBackground( new Color( 179, 0, 0 ) );
            label.setForeground( new Color( 235, 191, 16 ) );
            label.setHorizontalAlignment( JLabel.CENTER );
            label.setOpaque( true );
            label.setFont( new Font( "Old English Text MT", 0, 48 ) );
            label.addComponentListener(new ComponentAdapter() {
                Font font = label.getFont();
                public void componentResized(ComponentEvent e) {
                    int w = label.getWidth();
                    int sw = label.getFontMetrics(font).stringWidth(label.getText());
                    double scale = (double)w/sw;
                    AffineTransform at = AffineTransform.getScaleInstance(scale, 1.0);
                    label.setFont(font.deriveFont(at));
                    label.repaint();
            return label;
        public static void main( String[] args ) {
            JFrame frame = new JFrame( "Title" );
            frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
            Container pane = frame.getContentPane();
            pane.add( new DynamicFont().getNorth(), BorderLayout.NORTH );
            frame.setSize( 400, 100);
            frame.setLocationRelativeTo( null );
            frame.setVisible( true );
    }

  • How come a font set at a certain pixel size is not actually that size when you measure it's height? For example, a font set at size 24 pixels is actually only 16 pixels tall (cap height).

    How come a font set at a certain pixel size is not actually that size when you measure it's height? For example, a font set at size 24 pixels is actually only 16 pixels tall (cap height).

    Hello, indeed, as Semaphoric stated, the Em box is not the same as the Cap heigh...
    It is described in length in this blog post by Thomas Phinney http://www.thomasphinney.com/2011/03/point-size/
    THis article has good images also that illustrate the em square: Font Bureau Blog | The Em

  • Resize intensity image based on pixel dimensions

    Hi,
    I want to resize an intensity graph to an exact pixel-by-pixel size, but I do not see this option anywhere.  Right now I need to create a 257x256 intensity graph on the front panel, but I have no idea how to do this.  Does the graph automatically reshape the viewable area based on the dimensions of the 2d array that I provide it?
    Thanks,
    Anthony

    Hello,
    There is an intensity graph property available called Plot Area: Size which will set the plot area (width and height) in pixels - I think this is exactly what you are looking for.  Attached is an example of this in version 7.1, otherwise you can just right click the intensity graph on your block diagram and Create -> Property Node, and then use the operating tool on the property node to select the noted property.
    Best Regards,
    JLS
    Best,
    JLS
    Sixclear
    Attachments:
    Programmatically Set Intensity Graph Plot Area in Pixels.vi ‏24 KB

  • Improving Precision when scaling to exact pixel size

    Hi All,
    I'm very new to javascript and illustrator scripting, so I'm pretty sure my problem might be easily fixed
    I'm trying to write a script for creating PNGs with a specified pixel size.  I have created the following functions, which first works out the scaling % to use based on the artboard size (borrowed the idea from this post -thanks MuppetMark), and then export the image to PNG.
    It works, but, I am finding that when scaling to larger sizes, the resultant output is often a few pixels different from the value I have specified.  I'm sure this is due to precision/rounding issues in javascript, but have no idea how to fix.
    I'd be really grateful of any suggestions
    Many thanks
    Tim
    function getScaleFactor(artboard, width, height)
    var scaleFactor;
    if (width > 0)
            var scaleFactor = ( width / ( artboard.artboardRect[2] - artboard.artboardRect[0] ) ) * 100;
    else if (height > 0)
            scaleFactor = ( height / ( artboard.artboardRect[1] - artboard.artboardRect[3] ) ) * 100;
    else
        scaleFactor = 100.0;
    return scaleFactor;
    function exportFileToPNG24 (dest, scaleFactor) {
        if ( app.documents.length > 0 ) {
            var exportOptions = new ExportOptionsPNG24();
            var type = ExportType.PNG24;
            var fileSpec = new File(dest);
            exportOptions.antiAliasing = true;
            exportOptions.transparency = true;
            exportOptions.saveAsHTML = false;
            exportOptions.artBoardClipping = true;
            exportOptions.horizontalScale = scaleFactor;
            exportOptions.verticalScale = scaleFactor;
            app.activeDocument.exportFile( fileSpec, type, exportOptions );

    What you type in that box is just the ratio not the actual pixel number. And the box does not like to many digits in there. A ratio of 4 x 5 would work perfectly fine in your case, but more complicated ratios like 21 x 50 don't work.
    To get 500 x 400 px you must then export your image with settings that restrict your image, eg, to fit into a 500 x 500 px box.
    The idea behind this two-step approach is that you might think of 500 x 400 px output right now, but by doing the actual pixel generation at a later point, you can always easily export later at 1000 x 800 px if you need a higher resolution version with the same aspect ratio.

  • I am pulling my hair out! I am using adobe indesign and just want to make a text box 'autofit text' as I change fonts a lot and want the font to automatically re-size as I change it. help help help please - I have latest version of indesign - thanks

    I am pulling my hair out! I am using adobe indesign and just want to make a text box 'autofit text' as I change fonts a lot and want the font to automatically re-size as I change it.
    Is it not possible to create a text box, fill it with dynamic (data driven) text, but make the font size either scale up or down automatically, so that the entire text box is filled? This is a feature in PrintShop Mail Pro called COPY FIT. but no such feature in Indesign??
    help help help please - I have latest version of indesign - thanks, DJ

    lol... it seems to work, but I have another huge problem!
    Apparently .CSV files cannot contain page breaks in the data! The data I am trying to merge is a 'letter', with paragraphs, line breaks, etc.,
    But, after data merging, it ignores page breaks and only merges the first paragraph of each letter. (sigh)
    Solution? Hopefully, an EASY solution. lol as we have thousands of records.
    Is there a third party indesign plugin that will allow .xml, or .xls data merge import??
    Thx,
    DJ

  • Is there a way to determine pixel size of type displayed in browser?

    I'm still wrestling with getting type to line-break as I see it in Dreamweaver.
    At 'Actual Size' in Safari, the type is bigger than I see it in Dreamweaver. I have determined that 12px is the appropriate size while working in Dreamweaver but when I view the text online it is much bigger and the line-breaks do not fall where the writer wants them to.
    Here is the page in question:
    http://www.kgngroup.net/logos_and_packaging.html
    I guess I was wondering first, if there is a 'sizeometer' that can identify the actual pixels size of type as it is displayed, so I can tell how much bigger it actually is than what I am trying to build.
    TIA,
    Ken

    pziecina wrote:
    Hi
    The size of your text is set to 100% in your body elements css, this means that for Safari you will get a default font size of 16px, (providing you have not changed the browsers default settings).
    Change the body element font-size to 12px in the css and see what happens.
    PZ
    www.pziecina.com
    I've run out of helpful stars to hand out to all of you nice people. Thank you so much, and as the post quoted here also demonstrates, there are 'overrides' in CSS. It struck me this morning as I have been thinking about this, the very first thing to introduction to CSS is that the meaning of Cascading Style Sheets is that there is an order of priority in command, and the troops closest to the front lines get the final say. I would think that the statement in the document would be the final word, but apparently it's the CSS sheet that takes priority in this case.
    I think my thinking has been in reverse on this rule, not unusual for me, but now I need to re-educate myself thanks to this problem.
    Ken

  • Photo Gallery w/ Images adjusting size based on Browser size.

    I'm new to web design but I'm trying to create a photo gallery with images that dynamically size based on the size of the browser window. Similar to this http://pageduke.com/#/Residential/Colonial%20Revival-Nashville1/1. I know th is a flsh site, but is there a way yo do it in HTML in Dreamweaver, maybe using Spry. I don't know Jquery, but is it possible that way.
    Thanks

    Nancy,
    Woo is not a gallery. It's just a slider - a panel widget, which should
    be adaptive/responsive by default. The problem is that for years, the
    typical jQuery plugin writer simply copies stuff done by others so
    someone finally realized you don't have to fix a width and a height if
    you know how to write a stub script
    Galleries are totally different. To do a responsive gallery is not so
    easy and the only ones that come remotely close - using open source
    scripts - do require an initial width. They will not scale both up and down.
    I gusess it depends on what the original poster wants and/or cares about
    in terms of efficiencies and functionality.
    [External commercial link removed]
    Message was edited by: Sudarshan Thiagarajan. Please refrain from posting external links advertising/ promoting products & services.

  • Exporting Versions to a specific pixel size

    I want to export files for a slideshow that requires a pixel size of 1900 x 1200 , can it be done in Aperture ? , I have tried modifying the export preset , it does not work with (Fit Within ) is there another way ?
    Thanks
    Ray

    Trythis,
    What exactly is failing?
    Your 1900x1200 size is a very strange size. That's not the 3:2 aspect ratio of an SLR or the 4:3 aspect ratio of point-and-shoot cameras. Also, Aperture will not enlarge pictures by choosing "fit within", since a smaller picture already "fits within". I.e., if you have a 640x480 picture, that already "fits within" 1900 pixels so Aperture will not make it bigger.
    Also, Aperture will not crop your pictures on export. You may have to crop each picture first so that it has a 19:12 aspect ratio, and then "fit within" 1900 pixels. If the aspect ratio of a picture is 19:12 and the picture is larger than 1900 pixels, Aperture should properly reduce the size to 1900x1200, based on the aspect ratio.
    nathan

  • Is there a way to adjust the pixel size/resolution of a picture in iPhoto?

    Hi there!
    Long story long, I have downloaded a photo from a friend's not-so-great camera in order to make it into a blanket that is 50x60 in size.  When I try to upload the picture, the website that I'mbuying it through says that in order for it to look good it should be 9300x7800 pixels.
    I think one is 2265x2168 if I'm looking at the right place in iPhoto, on the photo information.  Is it possible and if so, how can I beter the resolution in order to create this gift for someone?
    Thanks for any and all help...hope I supplied enough information to even warrant an answer.  I'm new the Mac computers & still learning what I can/can't do!

    Answer is simple - that is not possible
    You can use programs like PhotoShop Elements to makeup new pixels and put them between the existing pixels- but the quality of the resulting image will be lower than the original even though it has more pixels
    And you might ask the print firm for suggestions since no comsumer camera has images that come close to 9300 x 7800 - You would be hard pressed to get an image that size without a $25,000 or more pro camera - for example a $15,000 Canon EOS 1Dc is only 4096x2160 pixels - http://snapsort.com/learn/sensor/pixel-size
    LN

  • Changing font based on resolution of client machine

    I have a Flex app in deployment now which resizes depending
    on the size of the clients screen. One screen it runs on is a huge
    48" flat screen, and it also needs to run on various small laptops
    etc.
    The resizing works great, but I would like to also change the
    fonts based on the resolution of the client machine. I have two
    questions:
    1) Is there a way to detect that in Flex,
    2) How do you dynamically set the font on barcharts and
    datagrids, can you just refer to a function instead of a variable,
    or do you need to use some kind of special method like
    "fontFormula" or something?
    M.

    I don't know if this is the type of thing you're looking for
    but give it a try:
    <?xml version="1.0" encoding="UTF-8"?>
    <mx:Application xmlns:mx="
    http://www.adobe.com/2006/mxml"
    xmlns:comp="*">
    <mx:Script>
    <![CDATA[
    import flash.system.Capabilities;
    import mx.controls.Alert;
    private function showSize():void{
    Alert.show(Capabilities.screenResolutionX + " by " +
    Capabilities.screenResolutionY)
    ]]>
    </mx:Script>
    <mx:Button label="Button" click="showSize();"/>
    </mx:Application>

  • Fonts displaying at same size when they should be different sizes

    I recently reinstalled Firefox after finding that Chrome was slowing down too much. I was interested mostly in having access to the LJlogin addon again, as I spend a lot of time on LJ with several different accounts. When I'd last had Firefox on my computer, I had it set to display all fonts as Times New Roman, but on reinstall I decided to let things go back to defaults on various sites (I believe LJ uses Verdana). But now, with the box checked for "allow pages to choose their own fonts", it's showing all the entry/comment text on LJ as the same size. Things that I know to be enclosed in a smallfont tag are the same size as unaltered text. It makes things rather confusing, so I'd appreciate any help with it.

    Thank you so much for responding to me. Having checked 6 at random it seems that they are all roughly the same ie around 227 x 160-189 pixels, all 72dpi and all 8cms x6cm (give or take a mm here and there) yet some print 2/3rds the size of A4 and others approx 6cms long. There was one that 295 x 400 at 150dpi 5cm x 7cm and that printed only a quater of the image because it was so huge.
    If it is that the pixel size or dpi overides the physical (cm ) size of the image how on earth can one determine what size they print off in real life. Also I see that if you simply chnage the dpi vale the image becomes distorted. Please excuse my ignorance but I just don't understand how the sizing works.

  • How to register created fonts in Java 5?

    Java 6 provides the registerFont(Font) method in GraphicsEnvironment to register fonts created using Font's createFont(int, InputStream) method. However, I need my application to work using Java 5.
    I looked in the Java 6 source code hoping to find the solution. In Java 6, GraphicsEnvironment's registerFont(Font) method calls a static method also entitled registerFont(Font) on the platform class sun.font.FontManager. Based on the code in sun.font.FontManager, I created a class for use in my application which only contains the variables and methods necessary for the registerFont(Font) method.
    There is only one problem: the registerFont(Font) method in sun.font.FontManager relies on the use of a native+ method to derive a Font2D object from the created font. The method is: public static native Font2D getFont2D(Font). Although my program compiles, I get the following error message at runtime:
    Exception in thread "Thread-3" java.lang.UnsatisfiedLinkError: getFont2D
         at MyFontManager.getFont2D(Native Method)
         at MyFontManager.registerFont(MyFontManager.java:105)
         at java.lang.Thread.run(Unknown Source)
    How do I derive a Font2D object from a Font object?
    OR
    Using Java 5, how do I register a created font such that I can reference that font via its family name, as in the following lines of code (the Java 6 solution is crossed out)?
    this.simpleAttributeSet = new SimpleAttributeSet();
    try {
    InputStream inputStream = getClass().getResource("fonts/FONT.TTF").openStream();
    Font font = Font.createFont(Font.TRUETYPE_FONT, inputStream).deriveFont(Font.PLAIN, 25);
    inputStream.close();
    GraphicsEnvironment.getLocalGraphicsEnvironment().registerFont(font);
    MyFontManager.registerFont(font);
    StyleConstants.setFontFamily(this.simpleAttributeSet, font.getFamily());
    } catch (Exception exception) {
    System.err.println(exception);
    }

    Sure.
    My strategy was to create a class for use in my application which would only contain all the variables and methods necessary to execute the registerFont(Font) method in the Java 6 version of sun.font.FontManager. The registerFont(Font) method calls two static, native methods: isCreatedFont and getFont2D. Originally, I made the mistake of including these methods in the class I created. The solution: call these methods on sun.font.FontManager.
    The Java 5 version of sun.font.FontManager fortunately supports getFont2D, but does not support isCreatedFont. However, it is not necessary for my program to determine whether or not the font is a created font. Therefore, I replaced all instances of calls to isCreatedFont with the value true.
    NOTE: The solution works, but my font ended up looking worse than it did using Java 6 and I'm interested in learning why.

  • Pixel size for epub books?

    Should the pixel size when creating a book for iTunes with an epub format be different or the same as with ibooks author? 

    Xorlac wrote:
    I assume that I use iTunes Producer when I am ready to publish to iBooks with an ePub file?
    Yes

Maybe you are looking for

  • How do I add photos to my contacts on galaxy s5

    You have two ways of adding pictures. From the camera/gallery or from your contacts. From contacts, find the one you want, open, tap the pen to edit. Tap the + sign and the pop up will ask where you want to add the photo from. From the gallery, selec

  • Regarding excise

    HI Guru's I have a problem regarding gr cancellation.User had made wrong excise entries and with out knowing they have transfered the stock to production.So i have taken necessary action to bring the stock back to raw material store.So when i was can

  • Is Showtime's Homeland being removed from On Demand?

    All episodes of Homeland On Demand are now listed as available unitl 7/2/2014.  Is Homeland being removed from On Demand?  If so, why?  It's a current running series with a new season to start in the Fall.

  • Mac Pro 1.1 processor upgrade

    I have a Mac Pro 1.1 and would request that this be put into i7 processor? The machine has 2 x 3GHz dual core processor. If it can be replaced on what should be done?

  • Lifespan of AirPort Extreme and Time Capsule

    In April 2009, I bought a 1 TB Time Capsule.  It developed the power supply problem (covered in other discussions) and died.  In September 2011, I bought a replacement 2 TB Time Capsule. A few weeks ago, while running a Time Machine backup from my Ma