QJ.NET | Videos | Forums | iPhone | MMORPG | Nintendo DS | Wii | PlayStation 3 | PSP | Xbox 360 | PC | Downloads | Contact Us
Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact

QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides

Go Back   QJ.net Game Discussion - PSP, Xbox, Wii, PS3, PSP Homebrew, and PSP Guides > Developers Corner > PSP Development, Hacks, and Homebrew > PSP Development Forum
The above video goes away if you are a member and logged in, so log in now!

Pre-SmoothType is Open Source & Free

This is a discussion on Pre-SmoothType is Open Source & Free within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Pre-SmoothType Version 1.0.0 The font file data is usualy made up of 94 blocks, allowing only the ASCII code from ...

Reply
 
LinkBack Thread Tools
Old 06-02-2007, 02:35 PM   #1

Developer
 
xart's Avatar
 
Join Date: Dec 2005
Posts: 1,873
Trader Feedback: 0
Default Pre-SmoothType is Open Source & Free

Pre-SmoothType
Version 1.0.0

The font file data is usualy made up of 94 blocks, allowing only the ASCII code from the range of 33 to 126 to be used.

Space has no glyph symbol and so is excluded and ASCII code 127 is never used or is very rarely used and there for is also excluded, this is why the ASCII code range is 33 to 126.

for other languages I will be doing a newer version for OpenCross `08 that is UNICODE

Header

Name Byte Size Description
signiture 4 Signiture for the file, always (NULL)PST
version 3 BCD Format: Major.Minor.Revision
e.g.. 000100h = version 1.0.0
format 1 1 = 1-bit, 8 = 8-bit, 4 = 4-bit, 3 = (Reserved)
0 = x-bit variable format
blocks 1 Number of blocks, normally always 94
first ascii 1 First ASCII code, normally always 33

Glyph Block Structure

Name Byte Size Description
width 1 Width of Glyph
height 1 Height of Glyph
offset 1 Horizontal offset in pixels
baseline 1 Offset in pixels from the baseline
e.g.. " is raised and _ is not raised, so " will have a baseline value and _ will be zero

pixels ... 8-bit / 4-bit grayscale
please note that 1-bit or 4-bit grayscale must be on byte boundary for every raster line.
also in x-bit format the first byte of the pixels data become the format for this block.


Before using the font file a glyph offset address look-up table has to be generated by-using the font file data.

This can be done using this C code
Code:
unsigned char *glyph[256]; // 256 offset table for the glyph table
unsigned char *p=glyphs; // Glyph Data Blocks
int i,j;

for (i=first_ascii,j=0; i<(first_ascii+blocks); i++) {
	glyph[i] = p;
   p += ( (int)(*p) * (int)(*(p+1)) ) + 4;
}

It will come part of OpenCross `07, OpenCross is based on SDL so it can be used on other platforms apart from Macs

i will be extracting the PST stuff from OpenCross `07 for supplying Pre-SmoothType as a seperate download.
__________________
www.xart.co.uk

coreXlib, old school library.

ColorSync Display Profiles for MacBook (LG LCD) & New MacBook (AUO LCD)
Profile for LG LP133WX1
Profile for AUO B133EW01
xart is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-02-2007, 02:59 PM   #2
No longer a community member.
 
Join Date: Oct 2006
Posts: 8
Trader Feedback: 0
Default

lol, this is so above my head it isn't even funny,

by the way xart i visited your website from your sig,

your web design is amazing, im asuming "eye-caching" refers to the fact that it functions by caching everything to memory?
JEMdev is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-02-2007, 03:23 PM   #3

Developer
 
xart's Avatar
 
Join Date: Dec 2005
Posts: 1,873
Trader Feedback: 0
Default

glad you like the site.

Pre-SmoothType download shouln't be long as I am in the middle of doing a seperate class for it to use in OpenCross `07 so as soon as it is done I will be hosting it for downloading with the default OpenCross font file that comes from OpenCross `07

It will be very easy to add to any project, well a little mod for those who don't use OCGraphics, just a put pixel so nothink major
__________________
www.xart.co.uk

coreXlib, old school library.

ColorSync Display Profiles for MacBook (LG LCD) & New MacBook (AUO LCD)
Profile for LG LP133WX1
Profile for AUO B133EW01
xart is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-02-2007, 03:43 PM   #4


Developer
 
Join Date: Jun 2006
Posts: 144
Trader Feedback: 0
Default

nice stuff
__________________
Adrahil - Software architect and specialist in Reverse Engineering.
Spoiler for Guilt of a Dev:
17:17 < InsertWittyName> Can't pin user error on a dev ;)
17:18 < InsertWittyName> Lesson learnt on both sides I would say.
17:18 < InsertWittyName> You learnt to treat the end-user as a retarded fish.
17:18 < InsertWittyName> They learnt to read readme's ;)

Spoiler for me:
Quote:
17:12 <+dot_blank> are you the long haired pimp ;)
adrahil is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 06-02-2007, 04:13 PM   #5

Developer
 
xart's Avatar
 
Join Date: Dec 2005
Posts: 1,873
Trader Feedback: 0
Default

For those who caunt wait here is the method from the OCGraphics class for drawing a Pre-SmoothType Glyph

it also has inline alpha blending, instead of using OCGraphics alphaBlend method
Code:
#define LINE_SIZE         512

u8 glyphCount,depth,asciiStart;
u8 *data;
u8 *glyph[256];

int OCGraphics::drawSmoothGlyph(int x, int y, char ascii)
{
   if(ascii==' ') return 4;
   u8 *p = glyph[(u8)ascii];
   int width = *p++;
   int height = *p++;
   int offset = *p++;
   int baseline = *p++;
   
   u32 *vptr=(u32 *)pixel(x + offset,y - (height + baseline));
   u32 a,rb,g;
   for(int j = 0; j < height; j++) {
      for(int i = 0; i < width; i++) {
         a = *p++;
         rb = (((foreColor & 0x00ff00ff) * a) + ((*vptr & 0x00ff00ff) * (0xff - a))) & 0xff00ff00;
         g  = (((foreColor & 0x0000ff00) * a) + ((*vptr & 0x0000ff00) * (0xff - a))) & 0x00ff0000;
         *vptr++ = ((rb | g) >> 8);
      }
      vptr += LINE_SIZE - width;
   }
   return width + offset;
}

void OCGraphics::loadFont(const char *filename) {
   FILE *fp;
   
   if ( (fp=fopen(filename, "rb")) == NULL ) {
      return;
   }
   
   // Check signiture
   char signiture[4];
   fread(signiture, sizeof(char), 4, fp);
   if (!(
       signiture[0]=='\0' &&
       signiture[1]=='P' &&
       signiture[2]=='S' &&
       signiture[3]=='T'
      )) {
      fclose(fp);
      return;
   }
   
   // Load Pre-Smooth Font Header
   fseek(fp, 3, SEEK_CUR);
   fread(&depth, sizeof(char), 1, fp); // Format/Pixel Depth
   fread(&glyphCount, sizeof(char), 1, fp); // Block/Glyph Count
   fread(&asciiStart, sizeof(char), 1, fp); // First ASCII code, normaly always 33
   
   // Get size of XFont glyph data
   fseek(fp, 0, SEEK_END);
   u16 dataSize;
   dataSize = ftell(fp) - 10;
   
   // Load glyph data
   freeFont(); // make sure no other font is loaded, if so free it first
   data=(u8 *)malloc(sizeof(char)*dataSize);
   if (!data) {
      fclose(fp);
      return;
   } else {
      fseek(fp, 10, SEEK_SET);
      fread(data, sizeof(char), dataSize, fp);
      fclose(fp);
   }
   

   // Build offset glyph data table for glyphs
   int i, j;
   u8 *p = data;
   for (i=asciiStart,j=0; i<(asciiStart+glyphCount); i++) {
      glyph[i] = p;
      p += ( (int)(*p) * (int)(*(p+1)) ) + 4;
   }
}

void OCGraphics::freeFont(void)
{
   if (data!=NULL) {
      free(data);
      data=NULL;
   }
}
the font file can be downloaded from the site
__________________
www.xart.co.uk

coreXlib, old school library.

ColorSync Display Profiles for MacBook (LG LCD) & New MacBook (AUO LCD)
Profile for LG LP133WX1
Profile for AUO B133EW01

Last edited by xart; 06-02-2007 at 04:32 PM..
xart is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
free , open , presmoothtype , source

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -8. The time now is 08:58 AM.



Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © 2009, QJ.NET. All Rights Reserved.
Contact Us