Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function CreateNewFontSet(var MM: TMemoryManagement): Integer;
- begin
- Result := (High(MM.font_set) + 1);
- SetLength(MM.font_set, (Result + 1));
- end;
- function AddFontToSet(var MM: TMemoryManagement; font_set_ID: Integer; p_s, n_s: string): Boolean;
- var
- h: Integer;
- begin
- h := High(MM.font_set);
- if (not InRange(font_set_ID, 0, hh) or not DirectoryExists(p_s + n_s + '\')) then
- Exit;
- h := High(MM.font_set[font_set_ID].chars);
- SetLength(MM.font_set[font_set_ID].chars, (h + 2));
- MM.font_set[font_set_ID].font[(h + 1)].path := p_s;
- MM.font_set[font_set_ID].font[(h + 1)].name := n_s;
- Result := True;
- end;
- function LoadFontFromSetToMemory(var MM: TMemoryManagement; font_set_ID, font_ID: Integer): Boolean;
- var
- d: string;
- begin
- if (InRange(font_set_ID, 0, High(MM.font_set)) and InRange(font_ID, 0, High(MM.font_set[font_set_ID].font))) then
- if not MM.DTM_set[font_set_ID].font[font_ID].loaded then
- try
- d := (MM.font_set[font_set_ID].font[font_ID].path + MM.font_set[font_set_ID].font[font_ID].name + '\');
- if not DirectoryExists(d) then
- Exit;
- MM.font_set[font_set_ID].font[font_ID].chars := LoadChars2();
- MM.font_set[font_set_ID].DTM[DTM_ID].loaded := True;
- Result := True;
- except
- try
- FreeChars2(MM.font_set[font_set_ID].font[font_ID].chars);
- except
- end;
- MM.font_set[font_set_ID].DTM[DTM_ID].loaded := False;
- Result := False;
- end;
- end;
- function FreeFontFromMemoryBySet(var MM: TMemoryManagement; font_set_ID, font_ID: Integer): Boolean;
- begin
- if (InRange(font_set_ID, 0, High(MM.font_set)) and InRange(font_ID, 0, High(MM.font_set[font_set_ID].font))) then
- if MM.font_set[font_set_ID].font[font_ID].loaded then
- try
- FreeChars2(MM.font_set[font_set_ID].font[font_ID].chars);
- MM.font_set[font_set_ID].font[font_ID].loaded := False;
- Result := True;
- except
- MM.font_set[font_set_ID].font[font_ID].loaded := True;
- Result := False;
- end;
- end;
- function FreefontsFromMemoryBySet(var MM: TMemoryManagement; font_set_ID: Integer): Boolean;
- var
- h, i, e: Integer;
- begin
- if InRange(font_set_ID, 0, High(MM.font_set)) then
- begin
- h := High(MM.font_set[font_set_ID].font);
- Result := (h > -1);
- for i := 0 to h do
- try
- if MM.font_set[font_set_ID].font[i].loaded then
- begin
- FreeChars2(MM.font_set[font_set_ID].font[i].chars);
- MM.font_set[font_set_ID].font[i].loaded := False;
- end;
- except
- Inc(e);
- WriteLn('WARNING[' + IntToStr(e) + ']: Failed to free font "' + MM.font_set[font_set_ID].font[i].name + '" (font_set[' + IntToStr(font_set_ID) + '] - font[' + IntToStr(i) + '])!');
- MM.font_set[font_set_ID].font[i].loaded := True;
- Result := False;
- end;
- end;
- end;
- procedure FreeFontsFromMemory(var MM: TMemoryManagement);
- var
- h, i: Integer;
- begin
- h := High(MM.font_set);
- for i := 0 to h do
- FreeFontsFromMemoryBySet(MM, i);
- end;
Advertisement
Add Comment
Please, Sign In to add comment