![]() |
| Forums | Gaming News | Videos | Downloads | Today's Posts | Mark Forums Read | Chat | FAQ | Members List | Contact |
| ||||||
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 ...
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 |
![]() ![]() Developer
|
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 |
|
|
|
|
|
#2 |
|
No longer a community member.
|
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? |
|
|
|
|
|
#3 |
![]() ![]() Developer
|
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 |
|
|
|
|
|
#5 |
![]() ![]() Developer
|
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;
}
}
__________________
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.. |
|
|
|
![]() |
| Tags |
| free , open , presmoothtype , source |
| Thread Tools | |
|
|