Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7516701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:13:03+00:00 2026-05-30T01:13:03+00:00

I’m doing a test for getting a font in Java, basically getting a larger

  • 0

I’m doing a test for getting a font in Java, basically getting a larger png of the alphabet, then cut it into smaller parts to get each individual letter as a separate subImage. So far I was using BufferedImage and java.awt.Graphics.

However, I’m planning on using LWJGL in the future, and would like to get more familiar with it(for this test I’m even creating the display with LWJGL), and would like to know if there was an equivalent of subImages in LWJGL’s OpenGL. I’d prefer not to get slick.

Here’s the image, just in case it helps:
https://i.stack.imgur.com/nFPQp.png

And here is the code I’m using, it could help.

package typeandscreen;

*imports go here, cut to save space*
public class Font{

    final int width = 78;
    final int height = 12;
    final int rows = 2;
    final int cols = 13;

BufferedImage letters[] = new BufferedImage[rows*cols]; 


void test(){
    try{
        final BufferedImage totalImage = ImageIO.read(new File("ABCabcs.png"));

    for(int i = 0; i < rows; i++){

        for(int j = 0; j < cols; j++){
            letters[(i * cols) + j] = totalImage.getSubimage(
                j * width,
                i * height,
                width,
                height
            );
        }
    }
    } catch(IOException e){
        e.printStackTrace();
    }
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:13:04+00:00Added an answer on May 30, 2026 at 1:13 am

    I’m not sure about a specific method, but here is my method to support Spritesheets…

    First I load the entire image into a single Texture, I then assign a few variables to help determine which part of the Sprite sheet I want to display with the following method:

    public void setSpriteSheetPosition(int columns, int rows, int which_column, int which_row, int wide, int tall)
    {
        this.columns = columns; //Number of columns the sprite sheet has
        this.rows = rows;  //Number of rows the sprite sheet has.
        this.which_column = which_column; //Which column and row I want to display on the Sprite
        this.which_row = which_row;
        this.wide = wide; //How many cells wide I want the sprite to be composed of
        this.tall = tall; //How many cells tall I want the sprite to be composed of
    }
    

    The last two variables allow me to have a spritesheet with variable cell sizes.

    Then my Sprite rendering method looks like the following…

    public void draw()
        {
            glPushMatrix();
            imageData.getTexture().bind();
            int tx = (int)location.x;
            int ty = (int)location.y;
            glTranslatef(tx, ty, location.layer);
    
            float height = imageData.getTexture().getHeight();
            float width = imageData.getTexture().getWidth();
    
            float texture_X = ((float)which_column/(float)columns)*width;
            float texture_Y = ((float)which_row/(float)rows)*height;
            float texture_XplusWidth = ((float)(which_column+wide)/(float)columns)*width;
            float texture_YplusHeight = ((float)(which_row+tall)/(float)rows)*height;
    
            glBegin(GL_QUADS);
            {
                glTexCoord2f(texture_X, texture_Y);
                glVertex2f(0, 0);
    
                glTexCoord2f(texture_X, texture_YplusHeight);
                glVertex2f(0, getHeight());
    
                glTexCoord2f(texture_XplusWidth, texture_YplusHeight);
                glVertex2f(getWidth(), getHeight());
    
                glTexCoord2f(texture_XplusWidth, texture_Y);
                glVertex2f(getWidth(), 0);
            }
            glEnd();
            glPopMatrix();
        }
    

    Which will draw the correct cell (or cells) of the Spritesheet.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am currently running into a problem where an element is coming back from
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have thousands of HTML files to process using Groovy/Java and I need to
I am doing a simple coin flipping experiment for class that involves flipping a
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.