- Move each VGA font file to a new "media/vgafonts" directory and convert all PSF fonts to BIN files.

- Add a line to the autogenerated Makefile for Boot-CDs, which creates a "vgafonts.cab" file from the binary fonts at build time.
- Change blue.sys to read the fonts from the "vgafonts.cab" file instead of the "vgafont.bin" (ZIP format) file.
  I dropped support for PSF fonts in blue.sys, because with the vgafontedit app, we can easily convert PSF fonts to BIN fonts now.
  If someone still needs this format in blue.sys, I can reimplement it.

svn path=/trunk/; revision=32145
This commit is contained in:
Colin Finck 2008-02-05 19:31:05 +00:00
parent 54409710c6
commit 8de349c343
13 changed files with 96 additions and 90 deletions

View file

@ -8,8 +8,6 @@
/* DEFINITIONS ***************************************************************/ /* DEFINITIONS ***************************************************************/
#define BUFFER_SIZE 260
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -20,20 +18,34 @@
#define TAG_BLUE TAG('B', 'L', 'U', 'E') #define TAG_BLUE TAG('B', 'L', 'U', 'E')
#include <pshpack1.h> typedef struct _CFHEADER
typedef struct { {
short Version; ULONG Signature; // File signature 'MSCF' (CAB_SIGNATURE)
short GeneralPurposeBitFlag; ULONG Reserved1; // Reserved field
short CompressionMethod; ULONG CabinetSize; // Cabinet file size
short LastModFileTime; ULONG Reserved2; // Reserved field
short LastModFileDate; ULONG FileTableOffset; // Offset of first CFFILE
int CRC32; ULONG Reserved3; // Reserved field
int CompressedSize; USHORT Version; // Cabinet version (CAB_VERSION)
int UncompressedSize; USHORT FolderCount; // Number of folders
short FileNameLength; USHORT FileCount; // Number of files
short ExtraFieldLength; USHORT Flags; // Cabinet flags (CAB_FLAG_*)
} ZIP_LOCAL_HEADER; USHORT SetID; // Cabinet set id
#include <poppack.h> USHORT CabinetNumber; // Zero-based cabinet number
} CFHEADER, *PCFHEADER;
typedef struct _CFFILE
{
ULONG FileSize; // Uncompressed file size in bytes
ULONG FileOffset; // Uncompressed offset of file in the folder
USHORT FileControlID; // File control ID (CAB_FILE_*)
USHORT FileDate; // File date stamp, as used by DOS
USHORT FileTime; // File time stamp, as used by DOS
USHORT Attributes; // File attributes (CAB_ATTRIB_*)
/* After this is the NULL terminated filename */
} CFFILE, *PCFFILE;
#define CAB_SIGNATURE 0x4643534D // "MSCF"
#define VIDMEM_BASE 0xb8000 #define VIDMEM_BASE 0xb8000
#define BITPLANE_BASE 0xa0000 #define BITPLANE_BASE 0xa0000

View file

@ -56,28 +56,23 @@ ScrLoadFontTable(UINT CodePage)
NTSTATUS ExtractFont(UINT CodePage, PUCHAR FontBitField) NTSTATUS ExtractFont(UINT CodePage, PUCHAR FontBitField)
{ {
BOOLEAN bFoundFile = FALSE;
HANDLE Handle; HANDLE Handle;
NTSTATUS Status = STATUS_SUCCESS; NTSTATUS Status;
CHAR FileHeader[5]; CHAR FileName[20];
CHAR Header[5];
CHAR PsfHeader[3];
CHAR FileName[BUFFER_SIZE];
ULONG Length;
IO_STATUS_BLOCK IoStatusBlock; IO_STATUS_BLOCK IoStatusBlock;
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING LinkName; UNICODE_STRING LinkName;
UNICODE_STRING SourceName; UNICODE_STRING SourceName;
ZIP_LOCAL_HEADER LocalHeader; CFHEADER CabFileHeader;
CFFILE CabFile;
ULONG CabFileOffset = 0;
LARGE_INTEGER ByteOffset; LARGE_INTEGER ByteOffset;
WCHAR SourceBuffer[MAX_PATH] = {L'\0'}; WCHAR SourceBuffer[MAX_PATH] = {L'\0'};
if(KeGetCurrentIrql() != PASSIVE_LEVEL) if(KeGetCurrentIrql() != PASSIVE_LEVEL)
return STATUS_INVALID_DEVICE_STATE; return STATUS_INVALID_DEVICE_STATE;
RtlZeroMemory(FileHeader, sizeof(FileHeader));
RtlZeroMemory(Header, sizeof(Header));
RtlZeroMemory(PsfHeader, sizeof(PsfHeader));
RtlInitUnicodeString(&LinkName, RtlInitUnicodeString(&LinkName,
L"\\SystemRoot"); L"\\SystemRoot");
@ -100,10 +95,10 @@ NTSTATUS ExtractFont(UINT CodePage, PUCHAR FontBitField)
Status = ZwQuerySymbolicLinkObject(Handle, Status = ZwQuerySymbolicLinkObject(Handle,
&SourceName, &SourceName,
&Length); NULL);
ZwClose(Handle); ZwClose(Handle);
Status = RtlAppendUnicodeToString(&SourceName, L"\\vgafont.bin"); Status = RtlAppendUnicodeToString(&SourceName, L"\\vgafonts.cab");
InitializeObjectAttributes(&ObjectAttributes, &SourceName, InitializeObjectAttributes(&ObjectAttributes, &SourceName,
OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
NULL, NULL); NULL, NULL);
@ -118,82 +113,78 @@ NTSTATUS ExtractFont(UINT CodePage, PUCHAR FontBitField)
NULL, 0); NULL, 0);
ByteOffset.LowPart = ByteOffset.HighPart = 0; ByteOffset.LowPart = ByteOffset.HighPart = 0;
if(NT_SUCCESS(Status)) if(NT_SUCCESS(Status))
{ {
sprintf(Header, "PK%c%c", 3, 4);
Status = ZwReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock, Status = ZwReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock,
FileHeader, 4, &ByteOffset, NULL); &CabFileHeader, sizeof(CabFileHeader), &ByteOffset, NULL);
ByteOffset.LowPart += 4;
if(NT_SUCCESS(Status)) if(NT_SUCCESS(Status))
{ {
while(strcmp(FileHeader, Header) == 0) if(CabFileHeader.Signature == CAB_SIGNATURE)
{ {
Status = ZwReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock, // We have a valid CAB file!
&LocalHeader, sizeof(ZIP_LOCAL_HEADER), &ByteOffset, NULL); // Read the file table now and decrement the file count on every file. When it's zero, we read the complete table.
ByteOffset.LowPart += sizeof(ZIP_LOCAL_HEADER); ByteOffset.LowPart = CabFileHeader.FileTableOffset;
/* DbgPrint("%ld\n", LocalHeader.FileNameLength); */
if (LocalHeader.FileNameLength < BUFFER_SIZE) while(CabFileHeader.FileCount)
{ {
RtlZeroMemory(FileName, BUFFER_SIZE);
Status = ZwReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock, Status = ZwReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock,
FileName, LocalHeader.FileNameLength, &ByteOffset, NULL); &CabFile, sizeof(CabFile), &ByteOffset, NULL);
}
ByteOffset.LowPart += LocalHeader.FileNameLength; if(NT_SUCCESS(Status))
/* DbgPrint("%s\n", FileName); */
if (LocalHeader.ExtraFieldLength > 0)
ByteOffset.LowPart += LocalHeader.ExtraFieldLength;
if (atoi(FileName) == CodePage)
{
if (LocalHeader.CompressedSize == 2048)
{ {
/* we got it, raw font */ ByteOffset.LowPart += sizeof(CabFile);
// We assume here that the file name is max. 19 characters (+ 1 NULL character) long.
// This should be enough for our purpose.
Status = ZwReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock, Status = ZwReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock,
FontBitField, LocalHeader.CompressedSize, &ByteOffset, NULL); FileName, sizeof(FileName), &ByteOffset, NULL);
ZwClose(Handle);
return STATUS_SUCCESS; if(NT_SUCCESS(Status))
}
else if (LocalHeader.CompressedSize > 2048)
{
sprintf(PsfHeader, "%c%c", 0x36, 0x04);
/* maybe linux psf format */
Status = ZwReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock,
FileHeader, 4, &ByteOffset, NULL);
ByteOffset.LowPart += 4;
if(strncmp(FileHeader, PsfHeader, 2) == 0)
{ {
/* only load fonts with a size of 8 if(!bFoundFile && atoi(FileName) == CodePage)
and filemode 0 (256 characters, no unicode_data)
or filemode 2 (256 characters, unicode_data is skipped) */
if ((FileHeader[3] == 8) && ((FileHeader[4] == 0) || (FileHeader[4] == 2)))
{ {
Status = ZwReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock, // We got the correct file.
FontBitField, 2048, &ByteOffset, NULL); // Save the offset and loop through the rest of the file table to find the position, where the actual data starts.
ZwClose(Handle); CabFileOffset = CabFile.FileOffset;
return STATUS_SUCCESS; bFoundFile = TRUE;
} }
else
DbgPrint("Wrong fontsize or too many characters"); ByteOffset.LowPart += strlen(FileName) + 1;
} }
} }
/* invalid data */
ZwClose(Handle); CabFileHeader.FileCount--;
return STATUS_NO_MATCH;
} }
ByteOffset.LowPart += LocalHeader.CompressedSize;
// 8 = Size of a CFFOLDER structure (see cabman). As we don't need the values of that structure, just increase the offset here.
ByteOffset.LowPart += 8;
ByteOffset.LowPart += CabFileOffset;
// ByteOffset now contains the offset of the actual data, so we can read the RAW font
Status = ZwReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock, Status = ZwReadFile(Handle, NULL, NULL, NULL, &IoStatusBlock,
FileHeader, 4, &ByteOffset, NULL); FontBitField, 2048, &ByteOffset, NULL);
ByteOffset.LowPart += 4; ZwClose(Handle);
/* DbgPrint("%s\n", FileHeader); */ return STATUS_SUCCESS;
}
else
{
DPRINT1("Error: CAB signature is missing!\n");
Status = STATUS_UNSUCCESSFUL;
} }
} }
else
DPRINT1("Error: Cannot read from file\n");
ZwClose(Handle); ZwClose(Handle);
return Status;
} }
else else
{ {
DbgPrint("Error: Can not open vgafont.bin\n"); DPRINT1("Error: Cannot open vgafonts.cab\n");
return Status; return Status;
} }
return STATUS_NO_MATCH;
} }
/* Font-load specific funcs */ /* Font-load specific funcs */

View file

@ -13,7 +13,4 @@
<directory name="nls"> <directory name="nls">
<xi:include href="nls/nls.rbuild" /> <xi:include href="nls/nls.rbuild" />
</directory> </directory>
<directory name="vgafont">
<xi:include href="vgafont/vgafont.rbuild" />
</directory>
</group> </group>

Binary file not shown.

View file

@ -1,5 +0,0 @@
<?xml version="1.0"?>
<!DOCTYPE group SYSTEM "../../tools/rbuild/project.dtd">
<group>
<cdfile installbase="$(CDOUTPUT)">vgafont.bin</cdfile>
</group>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -3851,6 +3851,13 @@ MingwIsoModuleHandler::GenerateIsoModuleTarget ()
FileLocation reactosInf ( bootcdReactos.directory, FileLocation reactosInf ( bootcdReactos.directory,
bootcdReactos.relative_path, bootcdReactos.relative_path,
"reactos.inf" ); "reactos.inf" );
FileLocation vgafontsCab( bootcdReactos.directory,
bootcdReactos.relative_path,
"vgafonts.cab");
FileLocation vgafontsDir( SourceDirectory,
"media" + sSep + "vgafonts",
"" );
vSourceFiles.push_back ( reactosDff ); vSourceFiles.push_back ( reactosDff );
string IsoName; string IsoName;
@ -3879,6 +3886,10 @@ MingwIsoModuleHandler::GenerateIsoModuleTarget ()
cdFiles.c_str (), cdFiles.c_str (),
cdDirectories.c_str () ); cdDirectories.c_str () );
fprintf ( fMakefile, "\t$(ECHO_CABMAN)\n" ); fprintf ( fMakefile, "\t$(ECHO_CABMAN)\n" );
fprintf ( fMakefile,
"\t$(Q)$(CABMAN_TARGET) -M raw -S %s %s\\*.bin\n", // Escape the asterisk for Make
backend->GetFullName ( vgafontsCab ).c_str (),
backend->GetFullName ( vgafontsDir ).c_str ());
fprintf ( fMakefile, fprintf ( fMakefile,
"\t$(Q)$(CABMAN_TARGET) -C %s -L %s -I -P $(OUTPUT)\n", "\t$(Q)$(CABMAN_TARGET) -C %s -L %s -I -P $(OUTPUT)\n",
backend->GetFullName ( reactosDff ).c_str (), backend->GetFullName ( reactosDff ).c_str (),