fpfont.inc 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2003 by the Free Pascal development team
  4. Implementation of TFPCustomFont
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. { FPCustomFont }
  12. procedure TFPCustomFont.SetName (AValue:string);
  13. begin
  14. FName := AValue;
  15. end;
  16. procedure TFPCustomFont.SetSize (AValue:integer);
  17. begin
  18. FSize := AValue;
  19. end;
  20. procedure TFPCustomFont.SetOrientation (AValue:integer);
  21. begin
  22. FOrientation := AValue;
  23. end;
  24. function TFPCustomFont.GetOrientation : Integer;
  25. begin
  26. Result := FOrientation;
  27. end;
  28. procedure TFPCustomFont.DoCopyProps (From:TFPCanvasHelper);
  29. begin
  30. if From is TFPCustomFont then
  31. with from as TFPCustomFont do
  32. begin
  33. self.FName := FName;
  34. self.FSize := FSize;
  35. self.FOrientation := FOrientation
  36. end;
  37. Inherited;
  38. end;
  39. function TFPCustomFont.CopyFont : TFPCustomFont;
  40. begin
  41. result := TFPCustomFont(self.ClassType.Create);
  42. result.DoCopyProps (self);
  43. end;
  44. procedure TFPCustomFont.GetTextSize (text:string; var w,h:integer);
  45. begin
  46. if inheritsFrom (TFPCustomDrawFont) then
  47. TFPCustomDrawFont(self).DoGetTextSize (text,w,h)
  48. else
  49. FCanvas.DoGetTextSize (text, w,h);
  50. end;
  51. function TFPCustomFont.GetTextHeight (text:string) : integer;
  52. begin
  53. if inheritsFrom (TFPCustomDrawFont) then
  54. result := TFPCustomDrawFont(self).DoGetTextHeight (text)
  55. else
  56. if assigned(FCanvas) then
  57. result := FCanvas.GetTextHeight (text)
  58. else
  59. result :=16; // *some* default better than none.
  60. end;
  61. function TFPCustomFont.GetTextWidth (text:string) : integer;
  62. begin
  63. if inheritsFrom (TFPCustomDrawFont) then
  64. result := TFPCustomDrawFont(self).DoGetTextWidth (text)
  65. else
  66. if assigned(FCanvas) then
  67. result := FCanvas.GetTextWidth (text)
  68. else
  69. result :=16; // *some* default better than none.
  70. end;