Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 

307 řádky
9.4 KiB

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