fpfont.inc 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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.DoCopyProps (From:TFPCanvasHelper);
  21. begin
  22. with from as TFPCustomFont do
  23. begin
  24. self.FName := FName;
  25. self.FSize := FSize;
  26. self.FFPColor := FFPColor;
  27. self.FFlags := FFlags;
  28. end;
  29. end;
  30. function TFPCustomFont.CopyFont : TFPCustomFont;
  31. begin
  32. result := TFPCustomFont(self.ClassType.Create);
  33. result.DoCopyProps (self);
  34. end;
  35. procedure TFPCustomFont.GetTextSize (text:string; var w,h:integer);
  36. begin
  37. if inheritsFrom (TFPCustomDrawFont) then
  38. TFPCustomDrawFont(self).DoGetTextSize (text,w,h)
  39. else
  40. FCanvas.DoGetTextSize (text, w,h);
  41. end;
  42. function TFPCustomFont.GetTextHeight (text:string) : integer;
  43. begin
  44. if inheritsFrom (TFPCustomDrawFont) then
  45. result := TFPCustomDrawFont(self).DoGetTextHeight (text)
  46. else
  47. if assigned(FCanvas) then
  48. result := FCanvas.GetTextHeight (text)
  49. else
  50. result :=16; // *some* default better than none.
  51. end;
  52. function TFPCustomFont.GetTextWidth (text:string) : integer;
  53. begin
  54. if inheritsFrom (TFPCustomDrawFont) then
  55. result := TFPCustomDrawFont(self).DoGetTextWidth (text)
  56. else
  57. if assigned(FCanvas) then
  58. result := FCanvas.GetTextWidth (text)
  59. else
  60. result :=16; // *some* default better than none.
  61. end;