Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 

285 строки
9.1 KiB

  1. unit ultsFont;
  2. {$mode objfpc}{$H+}
  3. interface
  4. uses
  5. Classes, SysUtils,
  6. utsTextSuite,
  7. ultsTypes;
  8. function ltsFontGetPostProcessor (const aHandle: TltsFontHandle): TltsPostProcessorHandle; stdcall;
  9. function ltsFontGetTabWidth (const aHandle: TltsFontHandle; var aValue: Integer): TltsErrorCode; stdcall;
  10. function ltsFontGetCharSpacing (const aHandle: TltsFontHandle; var aValue: Integer): TltsErrorCode; stdcall;
  11. function ltsFontGetLineSpacing (const aHandle: TltsFontHandle; var aValue: Single): TltsErrorCode; stdcall;
  12. function ltsFontGetMetric (const aHandle: TltsFontHandle; var aValue: TtsFontMetric): TltsErrorCode; stdcall;
  13. function ltsFontGetFontname (const aHandle: TltsFontHandle): PAnsiChar; stdcall;
  14. function ltsFontGetFacename (const aHandle: TltsFontHandle): PAnsiChar; stdcall;
  15. function ltsFontGetStylename (const aHandle: TltsFontHandle): PAnsiChar; stdcall;
  16. function ltsFontGetFullname (const aHandle: TltsFontHandle): PAnsiChar; stdcall;
  17. function ltsFontGetCopyright (const aHandle: TltsFontHandle): PAnsiChar; stdcall;
  18. function ltsFontSetPostProcessor (const aHandle: TltsFontHandle; const aValue: TltsPostProcessorHandle): TltsErrorCode; stdcall;
  19. function ltsFontSetTabWidth (const aHandle: TltsFontHandle; const aValue: Integer): TltsErrorCode; stdcall;
  20. function ltsFontSetCharSpacing (const aHandle: TltsFontHandle; const aValue: Integer): TltsErrorCode; stdcall;
  21. function ltsFontSetLineSpacing (const aHandle: TltsFontHandle; const aValue: Single): TltsErrorCode; stdcall;
  22. implementation
  23. uses
  24. ultsUtils;
  25. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  26. //Font//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  27. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  28. function ltsFontGetPostProcessor(const aHandle: TltsFontHandle): TltsPostProcessorHandle; stdcall;
  29. var
  30. f: TtsFont;
  31. begin
  32. try
  33. if CheckFontHandle(aHandle, f)
  34. then result := f.PostProcessor
  35. else result := nil;
  36. except
  37. on ex: Exception do begin
  38. SetLastError(ex);
  39. result := nil;
  40. end;
  41. end;
  42. end;
  43. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  44. function ltsFontGetTabWidth(const aHandle: TltsFontHandle; var aValue: Integer): TltsErrorCode; stdcall;
  45. var
  46. f: TtsFont;
  47. begin
  48. try
  49. result := ltsErrNone;
  50. if CheckFontHandle(aHandle, f)
  51. then aValue := f.TabWidth
  52. else result := LastErrorCode;
  53. except
  54. on ex: Exception do begin
  55. SetLastError(ex);
  56. result := LastErrorCode;
  57. end;
  58. end;
  59. end;
  60. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  61. function ltsFontGetCharSpacing(const aHandle: TltsFontHandle; var aValue: Integer): TltsErrorCode; stdcall;
  62. var
  63. f: TtsFont;
  64. begin
  65. try
  66. result := ltsErrNone;
  67. if CheckFontHandle(aHandle, f)
  68. then aValue := f.CharSpacing
  69. else result := LastErrorCode;
  70. except
  71. on ex: Exception do begin
  72. SetLastError(ex);
  73. result := LastErrorCode;
  74. end;
  75. end;
  76. end;
  77. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  78. function ltsFontGetLineSpacing(const aHandle: TltsFontHandle; var aValue: Single): TltsErrorCode; stdcall;
  79. var
  80. f: TtsFont;
  81. begin
  82. try
  83. result := ltsErrNone;
  84. if CheckFontHandle(aHandle, f)
  85. then aValue := f.LineSpacing
  86. else result := LastErrorCode;
  87. except
  88. on ex: Exception do begin
  89. SetLastError(ex);
  90. result := LastErrorCode;
  91. end;
  92. end;
  93. end;
  94. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  95. function ltsFontGetMetric(const aHandle: TltsFontHandle; var aValue: TtsFontMetric): TltsErrorCode; stdcall;
  96. var
  97. f: TtsFont;
  98. begin
  99. try
  100. result := ltsErrNone;
  101. if CheckFontHandle(aHandle, f)
  102. then aValue := f.Metric
  103. else result := LastErrorCode;
  104. except
  105. on ex: Exception do begin
  106. SetLastError(ex);
  107. result := LastErrorCode;
  108. end;
  109. end;
  110. end;
  111. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  112. function ltsFontGetFontname(const aHandle: TltsFontHandle): PAnsiChar; stdcall;
  113. var
  114. f: TtsFont;
  115. begin
  116. try
  117. if CheckFontHandle(aHandle, f)
  118. then result := PAnsiChar(f.Names.Fontname)
  119. else result := nil;
  120. except
  121. on ex: Exception do begin
  122. SetLastError(ex);
  123. result := nil;
  124. end;
  125. end;
  126. end;
  127. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  128. function ltsFontGetFacename(const aHandle: TltsFontHandle): PAnsiChar; stdcall;
  129. var
  130. f: TtsFont;
  131. begin
  132. try
  133. if CheckFontHandle(aHandle, f)
  134. then result := PAnsiChar(f.Names.FaceName)
  135. else result := nil;
  136. except
  137. on ex: Exception do begin
  138. SetLastError(ex);
  139. result := nil;
  140. end;
  141. end;
  142. end;
  143. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  144. function ltsFontGetStylename(const aHandle: TltsFontHandle): PAnsiChar; stdcall;
  145. var
  146. f: TtsFont;
  147. begin
  148. try
  149. if CheckFontHandle(aHandle, f)
  150. then result := PAnsiChar(f.Names.StyleName)
  151. else result := nil;
  152. except
  153. on ex: Exception do begin
  154. SetLastError(ex);
  155. result := nil;
  156. end;
  157. end;
  158. end;
  159. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  160. function ltsFontGetFullname(const aHandle: TltsFontHandle): PAnsiChar; stdcall;
  161. var
  162. f: TtsFont;
  163. begin
  164. try
  165. if CheckFontHandle(aHandle, f)
  166. then result := PAnsiChar(f.Names.FullName)
  167. else result := nil;
  168. except
  169. on ex: Exception do begin
  170. SetLastError(ex);
  171. result := nil;
  172. end;
  173. end;
  174. end;
  175. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  176. function ltsFontGetCopyright(const aHandle: TltsFontHandle): PAnsiChar; stdcall;
  177. var
  178. f: TtsFont;
  179. begin
  180. try
  181. if CheckFontHandle(aHandle, f)
  182. then result := PAnsiChar(f.Names.Copyright)
  183. else result := nil;
  184. except
  185. on ex: Exception do begin
  186. SetLastError(ex);
  187. result := nil;
  188. end;
  189. end;
  190. end;
  191. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  192. function ltsFontSetPostProcessor(const aHandle: TltsFontHandle; const aValue: TltsPostProcessorHandle): TltsErrorCode; stdcall;
  193. var
  194. f: TtsFont;
  195. p: TtsPostProcessor;
  196. begin
  197. try
  198. result := ltsErrNone;
  199. if CheckFontHandle(aHandle, f) and CheckPostProcessorHandle(aValue, TtsPostProcessor, p)
  200. then f.PostProcessor := p
  201. else result := LastErrorCode;
  202. except
  203. on ex: Exception do begin
  204. SetLastError(ex);
  205. result := LastErrorCode;
  206. end;
  207. end;
  208. end;
  209. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  210. function ltsFontSetTabWidth(const aHandle: TltsFontHandle; const aValue: Integer): TltsErrorCode; stdcall;
  211. var
  212. f: TtsFont;
  213. begin
  214. try
  215. result := ltsErrNone;
  216. if CheckFontHandle(aHandle, f)
  217. then f.TabWidth := aValue
  218. else result := LastErrorCode;
  219. except
  220. on ex: Exception do begin
  221. SetLastError(ex);
  222. result := LastErrorCode;
  223. end;
  224. end;
  225. end;
  226. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  227. function ltsFontSetCharSpacing(const aHandle: TltsFontHandle; const aValue: Integer): TltsErrorCode; stdcall;
  228. var
  229. f: TtsFont;
  230. begin
  231. try
  232. result := ltsErrNone;
  233. if CheckFontHandle(aHandle, f)
  234. then f.CharSpacing := aValue
  235. else result := LastErrorCode;
  236. except
  237. on ex: Exception do begin
  238. SetLastError(ex);
  239. result := LastErrorCode;
  240. end;
  241. end;
  242. end;
  243. ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  244. function ltsFontSetLineSpacing(const aHandle: TltsFontHandle; const aValue: Single): TltsErrorCode; stdcall;
  245. var
  246. f: TtsFont;
  247. begin
  248. try
  249. result := ltsErrNone;
  250. if CheckFontHandle(aHandle, f)
  251. then f.LineSpacing := aValue
  252. else result := LastErrorCode;
  253. except
  254. on ex: Exception do begin
  255. SetLastError(ex);
  256. result := LastErrorCode;
  257. end;
  258. end;
  259. end;
  260. end.