mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-21 11:09:27 +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
|
||||
if (AET^[i]^.yMax = y) then begin
|
||||
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
|
||||
inc(i);
|
||||
end;
|
||||
@ -207,9 +207,9 @@ begin
|
||||
inc(y);
|
||||
if (y >= ViewHeight) then break;
|
||||
end;
|
||||
freemem(et, sizeof(tedge) * numpoints);
|
||||
freemem(get, sizeof(pedge) * numpoints);
|
||||
freemem(aet, sizeof(pedge) * numpoints);
|
||||
System.freemem(et, sizeof(tedge) * numpoints);
|
||||
System.freemem(get, sizeof(pedge) * numpoints);
|
||||
System.freemem(aet, sizeof(pedge) * numpoints);
|
||||
end;
|
||||
|
||||
|
||||
@ -474,9 +474,9 @@ var
|
||||
PatternLine (x1,x2,y);
|
||||
End; { end while }
|
||||
|
||||
FreeMem (s1,(ViewWidth+1)*2);
|
||||
FreeMem (s2,(ViewWidth+1)*2);
|
||||
FreeMem (s3,(ViewWidth+1)*2);
|
||||
System.FreeMem (s1,(ViewWidth+1)*2);
|
||||
System.FreeMem (s2,(ViewWidth+1)*2);
|
||||
System.FreeMem (s3,(ViewWidth+1)*2);
|
||||
CleanUpDrawnList;
|
||||
CurrentColor := BackUpColor;
|
||||
End;
|
||||
|
@ -1394,7 +1394,7 @@ end;
|
||||
{ save state of arc information }
|
||||
{ because it is not needed for }
|
||||
{ a circle call. }
|
||||
move(ArcCall,OriginalArcInfo, sizeof(ArcCall));
|
||||
System.move(ArcCall,OriginalArcInfo, sizeof(ArcCall));
|
||||
if LineInfo.Thickness = Normwidth then
|
||||
begin
|
||||
OldWriteMode := CurrentWriteMode;
|
||||
@ -1404,7 +1404,7 @@ end;
|
||||
if LineInfo.Thickness = Normwidth then
|
||||
CurrentWriteMode := OldWriteMode;
|
||||
{ restore arc information }
|
||||
move(OriginalArcInfo, ArcCall,sizeof(ArcCall));
|
||||
System.move(OriginalArcInfo, ArcCall,sizeof(ArcCall));
|
||||
end;
|
||||
|
||||
procedure SectorPL(x1,x2,y: smallint); {$ifndef fpc}far;{$endif fpc}
|
||||
@ -2060,7 +2060,7 @@ end;
|
||||
for c := 1 to installedfonts do
|
||||
with fonts[c] Do
|
||||
If assigned(instr) Then
|
||||
Freemem(instr,instrlength);
|
||||
System.Freemem(instr,instrlength);
|
||||
{ release memory allocated for modelist }
|
||||
list := ModeList;
|
||||
while assigned(list) do
|
||||
|
@ -89,6 +89,64 @@
|
||||
{ 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;
|
||||
var
|
||||
@ -292,30 +350,37 @@ end;
|
||||
hp:=pchar(font);
|
||||
{ Move to EOF in prefix header }
|
||||
while (hp[i] <> chr($1a)) do Inc(i);
|
||||
move(hp[i+1],FHeader,sizeof(FHeader));
|
||||
move(hp[Prefix_Size],header,sizeof(Header));
|
||||
System.move(hp[i+1],FHeader,sizeof(FHeader));
|
||||
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? }
|
||||
i:=Prefix_Size+sizeof(Header);
|
||||
for b:=1 to installedfonts do
|
||||
begin
|
||||
if fonts[b].name=FHeader.Font_name then
|
||||
begin
|
||||
move(FHeader,fonts[b].PHeader,sizeof(FHeader));
|
||||
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(FHeader,fonts[b].PHeader,sizeof(FHeader));
|
||||
System.move(Header,fonts[b].Header,sizeof(Header));
|
||||
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));
|
||||
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));
|
||||
counter:=Fonts[b].PHeader.font_size+PREFIX_SIZE-i;
|
||||
{ allocate also space for null }
|
||||
GetMem(FontData,Counter+1);
|
||||
move(hp[i],FontData^,Counter);
|
||||
System.move(hp[i],FontData^,Counter);
|
||||
{ Null terminate the string }
|
||||
FontData[counter+1] := #0;
|
||||
if fonts[b].header.Signature<> SIGNATURE then
|
||||
begin
|
||||
_graphResult:=grInvalidFont;
|
||||
Freemem(FontData, Counter+1);
|
||||
System.Freemem(FontData, Counter+1);
|
||||
exit;
|
||||
end;
|
||||
fonts[b].instr:=FontData;
|
||||
@ -743,10 +808,17 @@ end;
|
||||
hp:=Prefix;
|
||||
i:=0;
|
||||
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 *)
|
||||
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));
|
||||
{$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. *}
|
||||
BlockRead(F,Fonts[font].Widths[Fonts[font].Header.First_Char],Fonts[font].Header.Nr_chars*sizeof(byte));
|
||||
{* Determine the length of the stroke database. *}
|
||||
@ -765,7 +837,7 @@ end;
|
||||
begin
|
||||
_graphResult:=grInvalidFont;
|
||||
Currenttextinfo.font:=DefaultFont;
|
||||
Freemem(FontData, Length+1);
|
||||
System.Freemem(FontData, Length+1);
|
||||
exit;
|
||||
end;
|
||||
fonts[font].instr:=FontData;
|
||||
@ -776,7 +848,7 @@ end;
|
||||
begin
|
||||
_graphresult:=grInvalidFont;
|
||||
Currenttextinfo.font:=DefaultFont;
|
||||
Freemem(FontData, Length+1);
|
||||
System.Freemem(FontData, Length+1);
|
||||
end;
|
||||
close(f);
|
||||
end;
|
||||
|
@ -158,7 +158,7 @@ end;
|
||||
if not assigned(ModeList) then
|
||||
begin
|
||||
new(ModeList);
|
||||
move(mode, ModeList^, sizeof(Mode));
|
||||
System.move(mode, ModeList^, sizeof(Mode));
|
||||
end
|
||||
else
|
||||
begin
|
||||
@ -168,7 +168,7 @@ end;
|
||||
list:=list^.next;
|
||||
new(NewLst);
|
||||
list^.next := NewLst;
|
||||
move(mode, NewLst^, sizeof(Mode));
|
||||
System.move(mode, NewLst^, sizeof(Mode));
|
||||
end;
|
||||
|
||||
end;
|
||||
|
@ -373,7 +373,7 @@ CONST
|
||||
|
||||
procedure GetDefaultPalette(var Palette: PaletteType);
|
||||
begin
|
||||
move(DefaultColors, Palette.Colors, sizeof(DefaultColors));
|
||||
System.move(DefaultColors, Palette.Colors, sizeof(DefaultColors));
|
||||
{ The default palette always has 256 entries, but in reality }
|
||||
{ it depends on the number of colors possible. }
|
||||
Palette.Size := PaletteSize;
|
||||
|
Loading…
Reference in New Issue
Block a user