mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 23:09:09 +02:00
+ big endian support for rendering .chr fonts
* explicitly use system unit versions of move and freemem, because fpcmacosall also contains routines with these names (and that unit is used in the upcoming Mac OS X implementation of the graph unit) git-svn-id: trunk@6754 -
This commit is contained in:
parent
2c22173534
commit
3cc1c1bd2e
@ -135,7 +135,7 @@ begin
|
|||||||
while (i < nActive) do begin
|
while (i < nActive) do begin
|
||||||
if (AET^[i]^.yMax = y) then begin
|
if (AET^[i]^.yMax = y) then begin
|
||||||
dec(nActive);
|
dec(nActive);
|
||||||
move(AET^[i+1], AET^[i], (nActive-i)*sizeof(pedge));
|
System.move(AET^[i+1], AET^[i], (nActive-i)*sizeof(pedge));
|
||||||
end else
|
end else
|
||||||
inc(i);
|
inc(i);
|
||||||
end;
|
end;
|
||||||
@ -207,9 +207,9 @@ begin
|
|||||||
inc(y);
|
inc(y);
|
||||||
if (y >= ViewHeight) then break;
|
if (y >= ViewHeight) then break;
|
||||||
end;
|
end;
|
||||||
freemem(et, sizeof(tedge) * numpoints);
|
System.freemem(et, sizeof(tedge) * numpoints);
|
||||||
freemem(get, sizeof(pedge) * numpoints);
|
System.freemem(get, sizeof(pedge) * numpoints);
|
||||||
freemem(aet, sizeof(pedge) * numpoints);
|
System.freemem(aet, sizeof(pedge) * numpoints);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -474,9 +474,9 @@ var
|
|||||||
PatternLine (x1,x2,y);
|
PatternLine (x1,x2,y);
|
||||||
End; { end while }
|
End; { end while }
|
||||||
|
|
||||||
FreeMem (s1,(ViewWidth+1)*2);
|
System.FreeMem (s1,(ViewWidth+1)*2);
|
||||||
FreeMem (s2,(ViewWidth+1)*2);
|
System.FreeMem (s2,(ViewWidth+1)*2);
|
||||||
FreeMem (s3,(ViewWidth+1)*2);
|
System.FreeMem (s3,(ViewWidth+1)*2);
|
||||||
CleanUpDrawnList;
|
CleanUpDrawnList;
|
||||||
CurrentColor := BackUpColor;
|
CurrentColor := BackUpColor;
|
||||||
End;
|
End;
|
||||||
|
@ -1394,7 +1394,7 @@ end;
|
|||||||
{ save state of arc information }
|
{ save state of arc information }
|
||||||
{ because it is not needed for }
|
{ because it is not needed for }
|
||||||
{ a circle call. }
|
{ a circle call. }
|
||||||
move(ArcCall,OriginalArcInfo, sizeof(ArcCall));
|
System.move(ArcCall,OriginalArcInfo, sizeof(ArcCall));
|
||||||
if LineInfo.Thickness = Normwidth then
|
if LineInfo.Thickness = Normwidth then
|
||||||
begin
|
begin
|
||||||
OldWriteMode := CurrentWriteMode;
|
OldWriteMode := CurrentWriteMode;
|
||||||
@ -1404,7 +1404,7 @@ end;
|
|||||||
if LineInfo.Thickness = Normwidth then
|
if LineInfo.Thickness = Normwidth then
|
||||||
CurrentWriteMode := OldWriteMode;
|
CurrentWriteMode := OldWriteMode;
|
||||||
{ restore arc information }
|
{ restore arc information }
|
||||||
move(OriginalArcInfo, ArcCall,sizeof(ArcCall));
|
System.move(OriginalArcInfo, ArcCall,sizeof(ArcCall));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure SectorPL(x1,x2,y: smallint); {$ifndef fpc}far;{$endif fpc}
|
procedure SectorPL(x1,x2,y: smallint); {$ifndef fpc}far;{$endif fpc}
|
||||||
@ -2060,7 +2060,7 @@ end;
|
|||||||
for c := 1 to installedfonts do
|
for c := 1 to installedfonts do
|
||||||
with fonts[c] Do
|
with fonts[c] Do
|
||||||
If assigned(instr) Then
|
If assigned(instr) Then
|
||||||
Freemem(instr,instrlength);
|
System.Freemem(instr,instrlength);
|
||||||
{ release memory allocated for modelist }
|
{ release memory allocated for modelist }
|
||||||
list := ModeList;
|
list := ModeList;
|
||||||
while assigned(list) do
|
while assigned(list) do
|
||||||
|
@ -89,6 +89,64 @@
|
|||||||
{ Internal support routines }
|
{ Internal support routines }
|
||||||
{***************************************************************************}
|
{***************************************************************************}
|
||||||
|
|
||||||
|
{$ifdef FPC_BIG_ENDIAN}
|
||||||
|
procedure swap_fheader(var h: tfheader);
|
||||||
|
(*
|
||||||
|
TFHeader = packed record
|
||||||
|
header_size: word; {* Version 2.0 Header Format *}
|
||||||
|
font_name: array[1..4] of char;
|
||||||
|
font_size: word; {* Size in byte of file *}
|
||||||
|
font_major: byte; {* Driver Version Information *}
|
||||||
|
font_minor: byte;
|
||||||
|
min_major: byte; {* BGI Revision Information *}
|
||||||
|
min_minor: byte;
|
||||||
|
end;
|
||||||
|
*)
|
||||||
|
begin
|
||||||
|
with h do
|
||||||
|
begin
|
||||||
|
header_size := swap(header_size);
|
||||||
|
font_size := swap(font_size);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure swap_header(var h: theader);
|
||||||
|
(*
|
||||||
|
THeader = packed record
|
||||||
|
Signature: char; { signature byte }
|
||||||
|
Nr_chars: smallint; { number of characters in file }
|
||||||
|
Reserved: byte;
|
||||||
|
First_char: byte; { first character in file }
|
||||||
|
cdefs : smallint; { offset to character definitions }
|
||||||
|
scan_flag: byte; { TRUE if char is scanable }
|
||||||
|
org_to_cap: shortint; { Height from origin to top of capitol }
|
||||||
|
org_to_base:shortint; { Height from origin to baseline }
|
||||||
|
org_to_dec: shortint; { Height from origin to bot of decender }
|
||||||
|
_reserved: array[1..4] of char;
|
||||||
|
Unused: byte;
|
||||||
|
end;
|
||||||
|
*)
|
||||||
|
begin
|
||||||
|
with h do
|
||||||
|
begin
|
||||||
|
nr_chars := swap(nr_chars);
|
||||||
|
cdefs := swap(cdefs);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure swap_offsets(var t: toffsettable; start, len: longint);
|
||||||
|
(*
|
||||||
|
TOffsetTable =array[0..MaxChars] of smallint;
|
||||||
|
*)
|
||||||
|
var
|
||||||
|
i: longint;
|
||||||
|
begin
|
||||||
|
for i := start to start+len-1 do
|
||||||
|
t[i]:=Swap(t[i]);
|
||||||
|
end;
|
||||||
|
{$endif FPC_BIG_ENDIAN}
|
||||||
|
|
||||||
|
|
||||||
function ConvertString(const OrigString: String): String;
|
function ConvertString(const OrigString: String): String;
|
||||||
var
|
var
|
||||||
@ -292,30 +350,37 @@ end;
|
|||||||
hp:=pchar(font);
|
hp:=pchar(font);
|
||||||
{ Move to EOF in prefix header }
|
{ Move to EOF in prefix header }
|
||||||
while (hp[i] <> chr($1a)) do Inc(i);
|
while (hp[i] <> chr($1a)) do Inc(i);
|
||||||
move(hp[i+1],FHeader,sizeof(FHeader));
|
System.move(hp[i+1],FHeader,sizeof(FHeader));
|
||||||
move(hp[Prefix_Size],header,sizeof(Header));
|
System.move(hp[Prefix_Size],header,sizeof(Header));
|
||||||
|
{$ifdef FPC_BIG_ENDIAN}
|
||||||
|
swap_fheader(fheader);
|
||||||
|
swap_header(header);
|
||||||
|
{$endif FPC_BIG_ENDIAN}
|
||||||
{ check if the font name is already allocated? }
|
{ check if the font name is already allocated? }
|
||||||
i:=Prefix_Size+sizeof(Header);
|
i:=Prefix_Size+sizeof(Header);
|
||||||
for b:=1 to installedfonts do
|
for b:=1 to installedfonts do
|
||||||
begin
|
begin
|
||||||
if fonts[b].name=FHeader.Font_name then
|
if fonts[b].name=FHeader.Font_name then
|
||||||
begin
|
begin
|
||||||
move(FHeader,fonts[b].PHeader,sizeof(FHeader));
|
System.move(FHeader,fonts[b].PHeader,sizeof(FHeader));
|
||||||
move(Header,fonts[b].Header,sizeof(Header));
|
System.move(Header,fonts[b].Header,sizeof(Header));
|
||||||
move(hp[i],Fonts[b].Offsets[Fonts[b].Header.First_Char],Fonts[b].Header.Nr_chars*sizeof(smallint));
|
System.move(hp[i],Fonts[b].Offsets[Fonts[b].Header.First_Char],Fonts[b].Header.Nr_chars*sizeof(smallint));
|
||||||
|
{$ifdef FPC_BIG_ENDIAN}
|
||||||
|
swap_offsets(Fonts[b].Offsets,Fonts[b].Header.First_Char,Fonts[b].Header.Nr_chars);
|
||||||
|
{$endif FPC_BIG_ENDIAN}
|
||||||
Inc(i,Fonts[b].Header.Nr_chars*sizeof(smallint));
|
Inc(i,Fonts[b].Header.Nr_chars*sizeof(smallint));
|
||||||
move(hp[i],Fonts[b].Widths[Fonts[b].Header.First_Char],Fonts[b].Header.Nr_chars*sizeof(byte));
|
System.move(hp[i],Fonts[b].Widths[Fonts[b].Header.First_Char],Fonts[b].Header.Nr_chars*sizeof(byte));
|
||||||
Inc(i,Fonts[b].Header.Nr_chars*sizeof(byte));
|
Inc(i,Fonts[b].Header.Nr_chars*sizeof(byte));
|
||||||
counter:=Fonts[b].PHeader.font_size+PREFIX_SIZE-i;
|
counter:=Fonts[b].PHeader.font_size+PREFIX_SIZE-i;
|
||||||
{ allocate also space for null }
|
{ allocate also space for null }
|
||||||
GetMem(FontData,Counter+1);
|
GetMem(FontData,Counter+1);
|
||||||
move(hp[i],FontData^,Counter);
|
System.move(hp[i],FontData^,Counter);
|
||||||
{ Null terminate the string }
|
{ Null terminate the string }
|
||||||
FontData[counter+1] := #0;
|
FontData[counter+1] := #0;
|
||||||
if fonts[b].header.Signature<> SIGNATURE then
|
if fonts[b].header.Signature<> SIGNATURE then
|
||||||
begin
|
begin
|
||||||
_graphResult:=grInvalidFont;
|
_graphResult:=grInvalidFont;
|
||||||
Freemem(FontData, Counter+1);
|
System.Freemem(FontData, Counter+1);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
fonts[b].instr:=FontData;
|
fonts[b].instr:=FontData;
|
||||||
@ -743,10 +808,17 @@ end;
|
|||||||
hp:=Prefix;
|
hp:=Prefix;
|
||||||
i:=0;
|
i:=0;
|
||||||
while (hp[i] <> chr($1a)) do Inc(i);
|
while (hp[i] <> chr($1a)) do Inc(i);
|
||||||
move(hp[i+1],fonts[font].PHeader,sizeof(TFHeader));
|
System.move(hp[i+1],fonts[font].PHeader,sizeof(TFHeader));
|
||||||
(* Read in the Header file *)
|
(* Read in the Header file *)
|
||||||
BlockRead(F,fonts[font].Header,Sizeof(THeader));
|
BlockRead(F,fonts[font].Header,Sizeof(THeader));
|
||||||
|
{$ifdef FPC_BIG_ENDIAN}
|
||||||
|
swap_fheader(fonts[font].PHeader);
|
||||||
|
swap_header(fonts[font].Header);
|
||||||
|
{$endif FPC_BIG_ENDIAN}
|
||||||
BlockRead(F,Fonts[font].Offsets[Fonts[font].Header.First_Char],Fonts[font].Header.Nr_chars*sizeof(smallint));
|
BlockRead(F,Fonts[font].Offsets[Fonts[font].Header.First_Char],Fonts[font].Header.Nr_chars*sizeof(smallint));
|
||||||
|
{$ifdef FPC_BIG_ENDIAN}
|
||||||
|
swap_offsets(Fonts[font].Offsets,Fonts[font].Header.First_Char,Fonts[font].Header.Nr_chars);
|
||||||
|
{$endif FPC_BIG_ENDIAN}
|
||||||
{* Load the character width table into memory. *}
|
{* Load the character width table into memory. *}
|
||||||
BlockRead(F,Fonts[font].Widths[Fonts[font].Header.First_Char],Fonts[font].Header.Nr_chars*sizeof(byte));
|
BlockRead(F,Fonts[font].Widths[Fonts[font].Header.First_Char],Fonts[font].Header.Nr_chars*sizeof(byte));
|
||||||
{* Determine the length of the stroke database. *}
|
{* Determine the length of the stroke database. *}
|
||||||
@ -765,7 +837,7 @@ end;
|
|||||||
begin
|
begin
|
||||||
_graphResult:=grInvalidFont;
|
_graphResult:=grInvalidFont;
|
||||||
Currenttextinfo.font:=DefaultFont;
|
Currenttextinfo.font:=DefaultFont;
|
||||||
Freemem(FontData, Length+1);
|
System.Freemem(FontData, Length+1);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
fonts[font].instr:=FontData;
|
fonts[font].instr:=FontData;
|
||||||
@ -776,7 +848,7 @@ end;
|
|||||||
begin
|
begin
|
||||||
_graphresult:=grInvalidFont;
|
_graphresult:=grInvalidFont;
|
||||||
Currenttextinfo.font:=DefaultFont;
|
Currenttextinfo.font:=DefaultFont;
|
||||||
Freemem(FontData, Length+1);
|
System.Freemem(FontData, Length+1);
|
||||||
end;
|
end;
|
||||||
close(f);
|
close(f);
|
||||||
end;
|
end;
|
||||||
|
@ -158,7 +158,7 @@ end;
|
|||||||
if not assigned(ModeList) then
|
if not assigned(ModeList) then
|
||||||
begin
|
begin
|
||||||
new(ModeList);
|
new(ModeList);
|
||||||
move(mode, ModeList^, sizeof(Mode));
|
System.move(mode, ModeList^, sizeof(Mode));
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
@ -168,7 +168,7 @@ end;
|
|||||||
list:=list^.next;
|
list:=list^.next;
|
||||||
new(NewLst);
|
new(NewLst);
|
||||||
list^.next := NewLst;
|
list^.next := NewLst;
|
||||||
move(mode, NewLst^, sizeof(Mode));
|
System.move(mode, NewLst^, sizeof(Mode));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
@ -373,7 +373,7 @@ CONST
|
|||||||
|
|
||||||
procedure GetDefaultPalette(var Palette: PaletteType);
|
procedure GetDefaultPalette(var Palette: PaletteType);
|
||||||
begin
|
begin
|
||||||
move(DefaultColors, Palette.Colors, sizeof(DefaultColors));
|
System.move(DefaultColors, Palette.Colors, sizeof(DefaultColors));
|
||||||
{ The default palette always has 256 entries, but in reality }
|
{ The default palette always has 256 entries, but in reality }
|
||||||
{ it depends on the number of colors possible. }
|
{ it depends on the number of colors possible. }
|
||||||
Palette.Size := PaletteSize;
|
Palette.Size := PaletteSize;
|
||||||
|
Loading…
Reference in New Issue
Block a user